# wrapper makefile for taglib
include $(shell while [ "`pwd`" != / -a \! -r options.mk ]; do cd .. ; done ; pwd )/options.mk

MODULE := taglib

INSTALL := $(ROOT_MODULES_DIR)/$(MODULE)
INSTALL_DIR_INC := $(INSTALL)/usr/include
BOM := $(CURDIR)/BOM

STAGEDHEADERS:=	$(CURDIR)/$(MODULE)/bindings/c/tag_c.h 

HEADERS_ORIGIN:=$(CURDIR)/$(MODULE)/taglib/

STAGEDHEADERS_TAGLIB:=\
	$(HEADERS_ORIGIN)/audioproperties.h \
	$(HEADERS_ORIGIN)/fileref.h \
	$(HEADERS_ORIGIN)/tag.h \
	$(HEADERS_ORIGIN)/taglib_export.h \
	$(HEADERS_ORIGIN)/tagunion.h \
	$(HEADERS_ORIGIN)/ape/apefooter.h \
	$(HEADERS_ORIGIN)/ape/apeitem.h \
	$(HEADERS_ORIGIN)/ape/apetag.h \
	$(HEADERS_ORIGIN)/flac/flacfile.h \
	$(HEADERS_ORIGIN)/flac/flacproperties.h \
	$(HEADERS_ORIGIN)/mpc/mpcfile.h \
	$(HEADERS_ORIGIN)/mpc/mpcproperties.h \
	$(HEADERS_ORIGIN)/mpeg/mpegfile.h \
	$(HEADERS_ORIGIN)/mpeg/mpegheader.h \
	$(HEADERS_ORIGIN)/mpeg/mpegproperties.h \
	$(HEADERS_ORIGIN)/mpeg/xingheader.h \
	$(HEADERS_ORIGIN)/mpeg/id3v1/id3v1genres.h \
	$(HEADERS_ORIGIN)/mpeg/id3v1/id3v1tag.h \
	$(HEADERS_ORIGIN)/mpeg/id3v2/id3v2extendedheader.h \
	$(HEADERS_ORIGIN)/mpeg/id3v2/id3v2footer.h \
	$(HEADERS_ORIGIN)/mpeg/id3v2/id3v2frame.h \
	$(HEADERS_ORIGIN)/mpeg/id3v2/id3v2framefactory.h \
	$(HEADERS_ORIGIN)/mpeg/id3v2/id3v2header.h \
	$(HEADERS_ORIGIN)/mpeg/id3v2/id3v2synchdata.h \
	$(HEADERS_ORIGIN)/mpeg/id3v2/id3v2tag.h \
	$(HEADERS_ORIGIN)/mpeg/id3v2/frames/attachedpictureframe.h \
	$(HEADERS_ORIGIN)/mpeg/id3v2/frames/commentsframe.h \
	$(HEADERS_ORIGIN)/mpeg/id3v2/frames/generalencapsulatedobjectframe.h \
	$(HEADERS_ORIGIN)/mpeg/id3v2/frames/relativevolumeframe.h \
	$(HEADERS_ORIGIN)/mpeg/id3v2/frames/textidentificationframe.h \
	$(HEADERS_ORIGIN)/mpeg/id3v2/frames/uniquefileidentifierframe.h \
	$(HEADERS_ORIGIN)/mpeg/id3v2/frames/unknownframe.h \
	$(HEADERS_ORIGIN)/mpeg/id3v2/frames/unsynchronizedlyricsframe.h \
	$(HEADERS_ORIGIN)/mpeg/id3v2/frames/urllinkframe.h \
	$(HEADERS_ORIGIN)/ogg/oggfile.h \
	$(HEADERS_ORIGIN)/ogg/oggpage.h \
	$(HEADERS_ORIGIN)/ogg/oggpageheader.h \
	$(HEADERS_ORIGIN)/ogg/xiphcomment.h \
	$(HEADERS_ORIGIN)/ogg/flac/oggflacfile.h \
	$(HEADERS_ORIGIN)/ogg/speex/speexfile.h \
	$(HEADERS_ORIGIN)/ogg/speex/speexproperties.h \
	$(HEADERS_ORIGIN)/ogg/vorbis/vorbisfile.h \
	$(HEADERS_ORIGIN)/ogg/vorbis/vorbisproperties.h \
	$(HEADERS_ORIGIN)/toolkit/taglib.h \
	$(HEADERS_ORIGIN)/toolkit/tbytevector.h \
	$(HEADERS_ORIGIN)/toolkit/tbytevectorlist.h \
	$(HEADERS_ORIGIN)/toolkit/tdebug.h \
	$(HEADERS_ORIGIN)/toolkit/tfile.h \
	$(HEADERS_ORIGIN)/toolkit/tlist.h \
	$(HEADERS_ORIGIN)/toolkit/tlist.tcc \
	$(HEADERS_ORIGIN)/toolkit/tmap.h \
	$(HEADERS_ORIGIN)/toolkit/tmap.tcc \
	$(HEADERS_ORIGIN)/toolkit/tstring.h \
	$(HEADERS_ORIGIN)/toolkit/tstringlist.h \
	$(HEADERS_ORIGIN)/toolkit/unicode.h \
	$(HEADERS_ORIGIN)/trueaudio/trueaudiofile.h \
	$(HEADERS_ORIGIN)/trueaudio/trueaudioproperties.h \
	$(HEADERS_ORIGIN)/wavpack/wavpackfile.h \
	$(HEADERS_ORIGIN)/wavpack/wavpackproperties.h \



GPLRESULTS := $(CURDIR)/gplresults

GPLCLEAN := $(CURDIR)/GPLCLEAN

MODULE_PKG := `readlink $(MODULE)`


build:
	$(MAKE) -C $(MODULE)
	$(call COPY,$(CURDIR)/$(MODULE)/bindings/c/.libs/libtag_c.so $(CURDIR)/$(MODULE)/taglib/.libs/libtag.so $(STAGING_LIBDIR)/.)

configure:
	cd $(MODULE) && sh ./configure STRIP="${STRIP}" CXX="${CXX}" CC="${CC}" CFLAGS="${CFLAGS}" CPPFLAGS="${CPPFLAGS} ${CXXFLAGS}" LDFLAGS="${LDFLAGS}" LDLIBS="${LDLIBS}" --host="arm-linux" --target="arm-linux" --prefix=/usr 

clean-install:
	$(call RM, $(INSTALL))

install: clean-install build
	$(call RECMAKE, $(MODULE), install-strip "DESTDIR=$(INSTALL)")
	$(call MKDIR,$(INSTALL_DIR_INC)/taglib)
	$(call COPY,$(STAGEDHEADERS),$(INSTALL_DIR_INC))
	$(call COPY,$(STAGEDHEADERS_TAGLIB) $(INSTALL_DIR_INC)/taglib)


buildresults: install

clean: clean-install
	$(call RECMAKE, $(MODULE),clean)

distclean: clean
	$(call RECMAKE, $(MODULE) ,distclean)
	$(call RM, $(GPLRESULTS) $(CURDIR)/$(MODULE)/examples/Makefile $(CURDIR)/$(MODULE)/examples/.deps $(CURDIR)/$(MODULE)/taglib/taglib-config.in $(CURDIR)/$(MODULE)/taglib/taglib.pc.in $(CURDIR)/$(MODULE)/autom4te.cache $(CURDIR)/$(MODULE)/aclocal.m4 $(CURDIR)/$(MODULE)/config.log)
	find $(CURDIR)/$(MODULE)/ -name .deps | xargs rm -fr
	find $(CURDIR)/$(MODULE)/ -name Makefile | xargs rm -f

stage: 
	mkdir -p $(STAGING_INCDIR)/taglib/

gplresults: distclean
	cat $(GPLCLEAN) | xargs rm -rf
	mkdir $(GPLRESULTS)
	tar cjvf $(GPLRESULTS)/$(MODULE_PKG).tar.bz2 --exclude=.svn $(MODULE_PKG)/
	@echo gplresults tree is in $(GPLRESULTS)

all: distclean configure build install buildresults


.PHONY: build configure clean-install install buildresults clean distclean gplresults all

