INCLUDE = `pkg-config --cflags gthread-2.0` `pkg-config --cflags gtk+-2.0` -Ilibusb
LIBS = `pkg-config --libs gthread-2.0` `pkg-config --libs gtk+-2.0`
export LOCALE_PACKAGE=mplinuxman
export LOCALE_DIR=/usr/local/share/locale
# remove -D NLS=1 if you want to disable international language support (gettext)
COMPILERFLAGS = -O -D MP_VERSION='"1.5"' -D PACKAGE='"$(LOCALE_PACKAGE)"' -D LOCALE_DIR='"$(LOCALE_DIR)"' -D NLS="1"
CC = gcc
CFLAGS = $(COMPILERFLAGS) $(INCLUDE)

HEADERFILES = dirdialog.h mplinux.h useful.h mputil3.h 
OBJECTFILES = dirdialog.o main.o mainwindow.o useful.o mp3util.o playlist.o waitdialog.o mplist.o miscwindow.o 

mplinuxman : $(OBJECTFILES) f60lib.o ini.o  usb.o error.o descriptors.o linux.o
	$(CC) -o mplinuxman $(CFLAGS) $(LIBS) $(OBJECTFILES) f60lib.o ini.o  usb.o error.o descriptors.o linux.o ; echo -e "\nDone\nTo install mplinuxman use (this requires root privileges): make install\n" 


f60lib.o : f60lib/f60lib.c
	$(CC) -c $(CFLAGS) f60lib/f60lib.c

ini.o	: ini/ini.c
	$(CC) -c $(CFLAGS) ini/ini.c

linux.o : libusb/linux.c
	$(CC) -c $(CFLAGS) libusb/linux.c

descriptors.o : libusb/descriptors.c
	$(CC) -c $(CFLAGS) libusb/descriptors.c

error.o : libusb/error.c
	$(CC) -c $(CFLAGS) libusb/error.c

usb.o : libusb/usb.c
	$(CC) -c $(CFLAGS) libusb/usb.c


$(OBJECTFILES) :  %.o: %.c
	$(CC) -c $(CFLAGS)  $<

clean:
	rm mplinuxman *.o *~ ; exit 0

#create message template file mplinuxman.pot in the po dir, then merge in any changes to the translated message files in po dir
pot:
	xgettext  -k_ -kN_ -ppo -o mplinuxman.pot main.c dirdialog.c miscwindow.c mainwindow.c waitdialog.c
	cd po;\
	for name in `find *.po 2> /dev/null`; do\
		msgmerge -o tmp $$name mplinuxman.pot ;\
		mv tmp $$name;\
	done;\
	
#compile/install all translated message files in po dir
install-po:
	sh  po/install.sh
	
install-launcher:
	cp logo.xpm /usr/local/share/pixmaps/mplinuxman.xpm
	cp mplinuxman.desktop /usr/local/share/applications

install:
	mkdir -p /usr/local/bin/
	cp mplinuxman /usr/local/bin
	cd extra/mp_util && make && cp mputil /usr/local/bin && cd ../..
	mkdir -p /usr/local/share/pixmaps/
	cp logo.xpm /usr/local/share/pixmaps/mplinuxman.xpm
	mkdir -p /usr/local/share/applications/
	cp mplinuxman.desktop /usr/local/share/applications
	mkdir -p /usr/local/share/locale/de/LC_MESSAGES/
	mkdir -p /usr/local/share/locale/es/LC_MESSAGES/
	mkdir -p /usr/local/share/locale/fr/LC_MESSAGES/
	mkdir -p /usr/local/share/locale/ja/LC_MESSAGES/
	mkdir -p /usr/local/share/locale/nl/LC_MESSAGES/
	sh  po/install.sh
	
uninstall:
	rm /usr/local/bin/mplinuxman
	rm /usr/local/bin/mputil
	rm /usr/local/share/pixmaps/mplinuxman.xpm
	rm /usr/local/share/applications/mplinuxman.desktop
	rm /usr/local/share/locale/de/LC_MESSAGES/mplinuxman.mo
	rm /usr/local/share/locale/es/LC_MESSAGES/mplinuxman.mo
	rm /usr/local/share/locale/fr/LC_MESSAGES/mplinuxman.mo
	rm /usr/local/share/locale/ja/LC_MESSAGES/mplinuxman.mo
	rm /usr/local/share/locale/nl/LC_MESSAGES/mplinuxman.mo
