#
# playmidi makefile
# by Nathan Laredo
#
# I don't wish to assert any rights (copyright) for this file,
# but please give me credit if you use my code.
#
# if you're using gcc 2.6.0 or 2.6.1 or 2.6.2 you'll need -g probably
# to prevent segmentation faults 'cause of a bug, otherwise use 2.5.8
#
# 5/10/95 - Alex: I fixed a few bugs here and there, and -O2 now works fine.
#
#CFLAGS = -g
#LDFLAGS = -g
CFLAGS = -O2 -fforce-mem -mno-486 -Wall -s
LDFLAGS = $(CFLAGS)
INSTALLDIR = /usr/local/bin
OBJECTS = playmidi.o midifile.o playevents.o patchload.o emumidi.o multisig.o

all: playmidi resetmidi

playmidi: .depend $(OBJECTS)
	$(CC) $(LDFLAGS) -o playmidi $(OBJECTS)

resetmidi: .depend resetmidi.o
	$(CC) -N $(LDFLAGS) -o resetmidi resetmidi.o

scope: .depend scope.o
	$(CC) -N $(LDFLAGS) -o scope scope.o -lvga

$(INSTALLDIR)/playmidi: playmidi
	cp playmidi $(INSTALLDIR)

$(INSTALLDIR)/resetmidi: resetmidi
	cp resetmidi $(INSTALLDIR)

$(INSTALLDIR)/scope: scope
	cp scope $(INSTALLDIR)

install: $(INSTALLDIR)/playmidi $(INSTALLDIR)/resetmidi #$(INSTALLDIR)/scope

clean:
	rm -f *.o *~ *.bak playmidi resetmidi scope a.out

ifeq (.depend, $(wildcard .depend))
.depend depend dep:
	for i in *.c; do $(CPP) -M $$i; done >.depend

include .depend
else
depend dep:
	for i in *.c; do $(CPP) -M $$i; done >.depend

.depend:
	@echo
	@echo "Bad or missing .depend running 'make depend'"
	@echo
	$(MAKE) depend
	@echo
	@echo "Successful.  Now make again (ignore following error)"
	@exit 1
endif
