# Generated automatically from Makefile.in by configure.
#-----------------------------------------------------------------------------#
# player by Peter Burns
#-----------------------------------------------------------------------------#
# To make a debian package :
# make dist
# tar -zvxf player-(stick version here).tar.gz
# cd player-(version)
# deb-make
# ./configure
# sudo build
# and you should have debian binary and source packages

# it is possible to redefine the root of the installation
# make DESTDIR=/opt/player-1.1 install

## SYSTEM DEPENDENT STUFF
SHELL       = /bin/sh

subdirs     = @subdirs@
top_srcdir  = .
srcdir      = .
prefix      = /usr/local
exec_prefix = ${prefix}
bindir      = $(exec_prefix)/bin
xbindir     = $(exec_prefix)/X11/bin
infodir     = $(prefix)/info
libdir      = $(prefix)/lib/gnudl
mandir      = $(prefix)/man/man1

CC          = gcc

LDFLAGS     =-L/usr/X11R6/lib -L.
LIBS        =-lgtk -lgdk -lglib -lXext -lX11 -lm 
DEFS        =-DHAVE_CONFIG_H #-DDEBUG
MFLAGS      =-m486 -malign-double -malign-loops=2 -malign-jumps=2 -malign-functions=2 #-mrtd
FFLAGS      =-ffast-math -funroll-loops -finline-functions #-fhandle-exceptions
WFLAGS      = -Wall 
CFLAGS      = $(WFLAGS) $(MFLAGS) -O6 $(FFLAGS) $(DEFS)

AR          = /usr/bin/ar 
TAR         = /bin/tar
RM          = /bin/rm
CP          = /bin/cp
LN          = /bin/ln
MKDIR       = /bin/mkdir
INSTALL     = /usr/bin/install

# 386 specific
# -m486

# -pg produces profile information for gprof
# -fstrength-reduce sometimes creates incorrect code

## END SYSTEM DEPENDENT STUFF

OBJ         = dsp.o sample.o instrument.o module.o player.o
PROGS       = moddisplay pmod ncmod gtkmod gtkplay
DISTFILES   = Makefile types.h formats.h patch.h dsp.h dsp.cc sample.h\
	      sample.cc instrument.h instrument.cc module.h module.cc \
	      player.h player.cc ncmod.cc gtkmod.cc moddisplay.cc pmod.cc \
	      gtkrc TODO autoconf/* configure configure.in config.status \
	      Makefile.in README copyright LGPL

all: $(PROGS)

## object files
sample.o: sample.cc sample.h formats.h patch.h types.h
	$(CC) $(CFLAGS) -c sample.cc
instrument.o: instrument.cc instrument.h sample.h formats.h patch.h types.h
	$(CC) $(CFLAGS) -c instrument.cc
module.o: module.cc module.h instrument.h sample.h formats.h patch.h
	$(CC) $(CFLAGS) -c module.cc
dsp.o: dsp.h dsp.cc
	$(CC) $(CFLAGS) -c dsp.cc
player.o: player.cc player.h dsp.h module.h instrument.h sample.h
	$(CC) $(CFLAGS) -DUSE_FORK -c player.cc
#	$(CC) $(CFLAGS) -c player.cc
## the following objects are not in the library, but they might be useful
timer.o: timer.cc timer.h
	$(CC) $(CFLAGS) -c timer.cc
gtkgraph.o:gtkgraph.c gtkgraph.h
	$(CC) $(CFLAGS) -c gtkgraph.c

## player library
libplayer.a: $(OBJ)
	$(AR) r $@ $(OBJ)

## executables
gtkmod: libplayer.a gtkmod.cc
	$(CC) $(CFLAGS) $(LDFLAGS) $@.cc -o $@ -lplayer $(LIBS)
moddisplay: $(OBJ) moddisplay.cc
	$(CC) $(CFLAGS) $(OBJ) $@.cc -o $@
play: dsp.o sample.o instrument.o play.cc
	$(CC) $(CFLAGS) instrument.o sample.o dsp.o $@.cc -o $@
gtkplay: dsp.o sample.o gtkgraph.o gtkplay.cc
	$(CC) $(CFLAGS) $(LDFLAGS) gtkgraph.o sample.o dsp.o $@.cc -o $@ $(LIBS)
pmod: libplayer.a pmod.cc
	$(CC) $(CFLAGS) -L. $@.cc -o $@ -lplayer -lm
ncmod: libplayer.a ncmod.cc
	$(CC) $(CFLAGS) -L. $@.cc -o $@ -lncurses -lplayer -lm 

## installation
install: gtkmod ncmod
	$(INSTALL) -d $(DESTDIR)$(bindir)
	$(INSTALL) -d $(DESTDIR)$(xbindir)
	$(INSTALL) ncmod $(DESTDIR)$(bindir)
	$(INSTALL) gtkmod $(DESTDIR)$(xbindir)

uninstall:
	$(RM) -f $(bindir)/ncmod
	$(RM) -f $(xbindir)/gtkmod

## distribution

dist: $(DISTFILES)
	echo player-`sed -e '/\player.cc,v /!d' \
		-e 's/[^0-9]*\([0-9.]*\).*/\1/' -e q player.cc` > .fname
	-$(RM) -rf `cat .fname`	
	$(MKDIR) `cat .fname`
	$(MKDIR) `cat .fname`/autoconf
	dst=`cat .fname`; for f in $(DISTFILES); do \
		$(LN) `pwd`/$$f $$dst/$$f || { echo copying $$f; \
		$(CP) -p `pwd`/$$f $$dst/$$f ; } \
	done

tar: dist
	$(TAR) --gzip -chf `cat .fname`.tar.gz `cat .fname`

zip: dist
	zip -r player.zip `cat .fname`

clean:
	@$(RM) -f *.o core .fname $(PROGS)

## AUTOCONF STUFF
# automatic re-running of configure if the ocnfigure.in file has changed
configure: autoconf/configure.in
	cd ${srcdir}; 
	autoconf --localdir=$(srcdir) autoconf/configure.in > configure
	chmod 755 configure
	./configure
# autoheader might not change config.h.in, so touch a stamp file
autoconf/config.h.in: stamp-h.in
stamp-h.in: autoconf/configure.in 
	cd ${srcdir};
	autoheader --localdir=$(srcdir) autoconf/configure.in > autoconf/config.h.in
	echo timestamp > ${srcdir}/stamp-h.in
	chmod 644 autoconf/config.h.in

config.h: stamp-h
stamp-h: config.h.in config.status
	./config.status
Makefile: autoconf/Makefile.in config.status
	./config.status
config.status: configure
	./config.status --recheck
