if GCC_PCH
AM_CXXFLAGS = -Winvalid-pch -include allsys.h
endif

# this has all of the subdirectories that make will recurse into.  if
# there are none, comment this out
SUBDIRS = taglibext

# this is the program that gets installed.  it's name is used for all
# of the other Makefile.am variables
bin_PROGRAMS = kid3

# set the include path for X, qt and KDE
INCLUDES = $(all_includes) $(TAGLIB_INCLUDES) $(MP4V2_INCLUDES)

# the library search path. 
kid3_LDFLAGS = $(KDE_RPATH) $(all_libraries)

# the libraries to link against.
if CONFIG_USE_KDE
kid3_LDADD   = $(LIB_KFILE) $(LIB_ID3LIB) $(LIB_TUNEPIMP) $(LIB_VORBIS) $(LIB_FLAC) $(LIB_TAGLIB) $(LIB_MP4V2)
else
kid3_LDADD   = $(LIB_QT) $(LIB_ID3LIB) $(LIB_TUNEPIMP) $(LIB_VORBIS) $(LIB_FLAC) $(LIB_TAGLIB) $(LIB_MP4V2)
endif

if HAVE_TAGLIB
kid3_LDADD += taglibext/libtaglibext.la
endif

# which sources should be compiled for kid3
kid3_SOURCES = filelist.cpp filelistitem.cpp frame.cpp framelist.cpp frametable.cpp genres.cpp id3form.cpp kid3.cpp main.cpp m4afile.cpp mp3file.cpp standardtags.cpp configdialog.cpp exportdialog.cpp formatconfig.cpp formatbox.cpp importdialog.cpp importselector.cpp importparser.cpp generalconfig.cpp importconfig.cpp miscconfig.cpp freedbdialog.cpp freedbconfig.cpp freedbclient.cpp rendirdialog.cpp dirlist.cpp taggedfile.cpp musicbrainzdialog.cpp musicbrainzconfig.cpp musicbrainzclient.cpp numbertracksdialog.cpp oggfile.cpp vcedit.c flacfile.cpp commandstable.cpp taglibfile.cpp importsourceconfig.cpp importsourcedialog.cpp importsourceclient.cpp discogsdialog.cpp discogsclient.cpp discogsconfig.cpp musicbrainzreleasedialog.cpp musicbrainzreleaseclient.cpp externalprocess.cpp importtrackdata.cpp stringlistedit.cpp tracktypedialog.cpp tracktypeclient.cpp

# these headers are automatically built
BUILT_SOURCES =
CLEANFILES = allsys.h allsys.h.gch

# these are the headers for your project that won't be installed
noinst_HEADERS = configdialog.h exportdialog.h filelist.h filelistitem.h formatbox.h formatconfig.h frame.h framelist.h frametable.h freedbclient.h freedbconfig.h freedbdialog.h generalconfig.h genres.h id3form.h importconfig.h importdialog.h importparser.h importselector.h kid3.h miscconfig.h m4afile.h mp3file.h rendirdialog.h standardtags.h dirlist.h taggedfile.h musicbrainzclient.h musicbrainzconfig.h musicbrainzdialog.h numbertracksdialog.h oggfile.hpp vcedit.h flacfile.hpp commandstable.h taglibfile.h importsourceconfig.h importsourcedialog.h importsourceclient.h discogsdialog.h discogsclient.h discogsconfig.h musicbrainzreleasedialog.h musicbrainzreleaseclient.h qtcompatmac.h dirinfo.h externalprocess.h stringlistedit.h tracktypedialog.h tracktypeclient.h

# additional files in distribution
EXTRA_DIST = kid3.desktop kid3ui.rc hi16-app-kid3.png hi32-app-kid3.png hi48-app-kid3.png hisc-app-kid3.svgz de_qt.po ru_qt.po es_qt.po fr_qt.po

# generate precompiled header allsys.h.gch for GCC 3.4
pch:
if CONFIG_USE_KDE
	cat $(patsubst %,$(srcdir)/%,$(kid3_SOURCES)) | grep "#include *<" | grep -v "<taglib" | sort | uniq >allheaders.h
else
	cat $(patsubst %,$(srcdir)/%,$(kid3_SOURCES)) | grep "#include *<" | grep -v "<taglib" | grep -v "<k" | sort | uniq >allheaders.h
endif
	$(CXX) -E $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -Winvalid-pch $(CXXFLAGS) $(KDE_CXXFLAGS) allheaders.h -o /dev/null 2>&1 | grep "No such file" | sed -e 's/^.*error: \(.*\): No such file.*$$/#include <\1>/' >missingheaders.h
	echo "/* automatically generated by Makefile */" >allsys.h
	echo "#ifndef ALLSYS_H" >>allsys.h
	echo "#define ALLSYS_H" >>allsys.h
	cat allheaders.h missingheaders.h | sort | uniq -u >>allsys.h
	echo "#endif" >>allsys.h 
	$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) -Winvalid-pch $(CXXFLAGS) $(KDE_CXXFLAGS) allsys.h
	echo "#error precompiled header not used!" >>allsys.h
	rm allheaders.h missingheaders.h

# let automoc handle all of the meta source files (moc)
METASOURCES = AUTO

messages: rc.cpp
	$(XGETTEXT) *.cpp -o $(podir)/kid3.pot

KDE_ICON = kid3

# this is where the kdelnk file will go 
xdg_apps_DATA = kid3.desktop

# this is where the XML-GUI resource file goes
rcdir = $(kde_datadir)/kid3
rc_DATA = kid3ui.rc
