#
# GMP3 Makefile
#
# This thing ain't pretty, but it does the job... autoconf is the next thing
# I need to learn...
#

VERSION=0.08

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

PLATFORM = LINUX

### Path options

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

### Options for Gmp3

RCFILENAME=gmp3rc

# Relative to home directory.
RCFILEDIR=/.gmp3

ROOTNAME=MP3\'s

### Options for mpg123

MPG123=/usr/local/bin/mpg123
SOUNDDEV=/dev/dsp
HTTP_PROXY=
HTTP_AUTH_STRING=

### Uncomment to add debugging support

# DEBUG=1 

########################## Do not edit below here. ##########################

CC=gcc

CFLAGS=-Wall $(DEFINES) -I/usr/local/lib/glib/include
LDFLAGS=-L/usr/X11R6/lib

ifdef DEBUG
  CFLAGS+=-g -D__DEBUG__
else
  CFLAGS+=-O2
endif

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

DEFINES=-D__$(PLATFORM)__ \
	-DPIXMAPDIR="\"$(LIBDIR)\"" \
	-DVERSION="\"$(VERSION)\"" \
        -DRCFILENAME="\"$(RCFILENAME)\"" \
	-DRCFILEDIR="\"$(RCFILEDIR)\"" \
        -DMPG123_NAME="\"$(MPG123)\"" \
	-DROOTNAME="\"$(ROOTNAME)\"" \
	-DSOUND_DEV="\"$(SOUNDDEV)\"" \
        -DHTTP_PROXY="\"$(HTTP_PROXY)\"" \
	-DHTTP_AUTH_STRING="\"$(HTTP_AUTH_STRING)\""

gmp3 : $(OBJS) convlist
	gcc -o gmp3 $(LDFLAGS) $(OBJS) $(LIBS)

convlist : $(CONVERT_OBJS)
	gcc -o convlist $(LDFLAGS) $(CONVERT_OBJS) $(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

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 :
	rm -f $(OBJS) $(CONVERT_OBJS)

cleanall : clean
	rm -f convlist gmp3
