#
# GMP3 Makefile
#
# I made this by hand... you like? ;)
# It could use a nicer install script, but it works... *shrug*
#

# DEBUG=1 # Uncomment this to enable -g compilation and debugging output.

#
# Platform is one of:
# 
# LINUX
# FREEBSD
# SOLARIS
# GENERIC (if you're not one of the above)
#

PLATFORM = LINUX

OBJS=about.o \
     common.o \
     control_funcs.o \
     gmp3.o \
     handlers.o \
     list.o \
     listutils.o \
     mixer.o \
     mixerpanel.o \
     mp3tag.o \
     opt_dialog.o \
     pixmap.o \
     rc_parser.o \
     shape.o \
     themerc.o \
     xpmbutton.o

LIBS=-lgif -ljpeg -ltiff -lpng -lz \
     -lX11 -lXext -lXi \
     -lgdk -lgtk -lglib -lgdk_imlib -lm \

CONVERT_OBJS=convlist.o \
             listutils.o \
             mp3tag.o

CONVERT_LIBS=-lglib

INSTALLDIR=/usr/local
BINDIR=$(INSTALLDIR)/bin
LIBDIR=$(INSTALLDIR)/lib/gmp3

RCFILENAME="\"gmp3rc\""
RCFILEDIR="\"/.gmp3\""
MPG123="\"/usr/local/bin/mpg123\""
VERSION="\"0.074a\""
ROOTNAME="\"MP3\'s\""

DEFINES=-D__$(PLATFORM)__ -DPIXMAPDIR="\"$(LIBDIR)\"" -DVERSION=$(VERSION) \
        -DRCFILENAME=$(RCFILENAME) -DRCFILEDIR=$(RCFILEDIR) \
        -DMPG123_NAME=$(MPG123) -DROOTNAME=$(ROOTNAME)
CC=gcc

ifdef DEBUG
  CFLAGS=-g -Wall -D__DEBUG__ $(DEFINES)
else
  CFLAGS=-O2 -Wall $(DEFINES)
endif

gmp3 : $(OBJS) convlist
	gcc -o gmp3 $(OBJS) -L/usr/X11R6/lib $(LIBS)

convlist : $(CONVERT_OBJS)
	gcc -o convlist $(CONVERT_OBJS) $(DEFINE) $(CONVERT_LIBS)

about.o : about.c about.h
common.o : common.c common.h
control_funcs.o : control_funcs.c control_funcs.h
convlist.o : convlist.c listutils.h listtypes.h
gmp3.o : gmp3.c gmp3.h
handlers.o : handlers.c handlers.h
list.o : list.c list.h listtypes.h
listutils.o : listutils.c listutils.h listtypes.h
mixer.o : mixer.c mixer.h
mixerpanel.o : mixerpanel.c mixerpanel.h
mp3tag.o : mp3tag.c mp3tag.h
opt_dialog.o : opt_dialog.c opt_dialog.h
pixmap.o : pixmap.c pixmap.h
rc_parser.o : rc_parser.c rc_parser.h
shape.o : shape.c shape.h
songlist.o : songlist.c songlist.h
themerc.o : themerc.c themerc.h
xpmbutton.o : xpmbutton.c xpmbutton.h

clean :
	rm -f $(OBJS)

install-binary :
	cp -f gmp3 $(BINDIR)
	cp -f convlist $(BINDIR)
	chmod a+rx $(BINDIR)/gmp3
	chmod a+rx $(BINDIR)/convlist

install-libs :
	-@mkdir -p $(LIBDIR)
	cp -Rf default $(LIBDIR)/
	cp -f gmp3logo.jpg $(LIBDIR)/

	chmod a+rx $(LIBDIR)/default
	chmod -R a+r $(LIBDIR)/default
	chmod a+r $(LIBDIR)/gmp3logo.jpg

install : install-binary install-libs
install-bin : install-binary

clean_conv :
	rm -f $(CONVERT_OBJS) convlist

cleanall : clean_conv
	rm -f $(OBJS) gmp3
