# Greg Lee, lee@uhunix.uhcc.hawaii.edu
# Revision 1.9  93/03/29  00:00:00  lee

# Change this to the directory where you want to keep patch library files.
PATCHHOME = -DPDIR=\"/usr/midi/Plib\"

# Below are definitions for compiling four versions of
# glib with SoundBlaster support: versions with and
# without support for for the Kawaii K1, and a version
# for X Windows versus one for curses.
# Other possibly useful compiler flags are:
#	-DNOSOUND to disable the Linux/sounddriver specific code
#		(and also do not use -DMIDIIN)
#	-DNOGLSS to disable the graphics that require Slingshot, with
#		which you would want to use:
#			LDLIBS = $(LIBS) -lxview -lolgx -lX11 
#	(I must confess that I haven't tested NOGLSS.)
#	-DXKEYS -DMIDIIN allow playing notes from an external
#		keyboard
#	-DGUSPATDIR=\"/dos/ultrasnd\midi\"
#		(modified appropriately) to make the directory where
#		gus .pat files are found something other than the
#		default /dos/ultrasnd/midi.

# Remove '#' from next 3 lines for Opl-3 boards:
#SYNTHS = -DOPL3
#SYNTHOBJ = opl3.o linux_io.o
#SYNTHC = opl3.c

# Remove '#' from next 3 lines for SoundBlaster:
#SYNTHS = -DSBLAST
#SYNTHOBJ = sblast.o linux_io.o
#SYNTHC = sblast.c

# Remove '#' from next 3 lines for both K1 and SoundBlaster:
# (midi input is required for handshaking with the K1)
#SYNTHS = -DKAWAIK1 -DSBLAST -DMIDIIN
#SYNTHOBJ = k1vis.o k1multi.o k1single.o sblast.o linux_io.o
#SYNTHC = k1multi.c k1single.c sblast.c

# Remove '#' from next 3 lines for Ultrasound:
#SYNTHS = -DGUS -DMIDIIN -DXKEYS
#SYNTHOBJ = gus.o linux_io.o
#SYNTHC = gus.c

# Remove '#' from next 3 lines for both Ultrasound and SoundBlaster:
#SYNTHS = -DGUS -DSBLAST -DMIDIIN -DXKEYS
#SYNTHOBJ = gus.o sblast.o linux_io.o
#SYNTHC = gus.c sblast.c

# Remove '#' from next 3 lines for both Ultrasound and Opl3:
#SYNTHS = -DOPL3 -DGUS -DMIDIIN -DXKEYS
#SYNTHOBJ = opl3.o gus.o linux_io.o
#SYNTHC = opl3.c gus.c

# Remove '#' from next 3 lines for Ultrasound, SoundBlaster, and Opl3:
SYNTHS = -DOPL3 -DGUS -DSBLAST -DMIDIIN -DXKEYS
SYNTHOBJ = opl3.o gus.o sblast.o linux_io.o
SYNTHC = opl3.c gus.c sblast.c

# Remove '#' from next 3 lines for K1, Ultrasound, SoundBlaster, and Opl3:
#SYNTHS = -DOPL3 -DGUS -DSBLAST -DKAWAIK1 -DMIDIIN -DXKEYS
#SYNTHOBJ = k1vis.o k1multi.o k1single.o opl3.o gus.o sblast.o linux_io.o
#SYNTHC = k1multi.c k1single.c opl3.c gus.c sblast.c

# Remove '#' from next 4 lines for the X Windows version
VERSIONFLAGS = -DXGL
LDLIBS = -lsspkg -lxview -lolgx -lX11 -lm
OBJ = machdep.o glib.o list.o $(SYNTHOBJ)
all: menutoc xgl

# Remove '#' from next 4 lines for the curses version
#VERSIONFLAGS = -DARROW #-DSSS
#LDLIBS = -lcurses -ltermcap -lm
#OBJ = machdep.o glib.o list.o $(SYNTHOBJ)
#all: menutoc glib

CC = gcc
CFLAGS = -O -DBSD $(VERSIONFLAGS) $(SYNTHS) $(PATCHHOME)
LEX = flex
LEXLIB =
LDFLAGS = -s


.SUFFIXES: .mnu


xgl:	$(OBJ)
	$(CC) $(LDFLAGS) $(OBJ) $(LDLIBS) -o xgl

glib:	$(OBJ)
	$(CC) $(LDFLAGS) $(OBJ) $(LDLIBS) -o glib

pat2gl: pat2gl.o
	$(CC) $(LDFLAGS) pat2gl.o -o pat2gl

machdep.c: unix-mach.c machdep.h
	rm -f machdep.c
	ln -s unix-mach.c machdep.c

machdep.h: unix-mach.h
	rm -f machdep.h
	ln -s unix-mach.h machdep.h

machdep.o : machdep.c glib.h /usr/include/ctype.h \
	/usr/include/curses.h

.mnu.c:
	@rm -f $@
	menutoc $*.mnu >$@

gus.c:		gus.mnu
sblast.c:	sblast.mnu
opl3.c:		opl3.mnu
k1single.c:	k1single.mnu
k1multi.c:	k1multi.mnu

menutoc:  menutoc.l
	$(LEX) menutoc.l
	$(CC) -s lex.yy.c -o menutoc
	rm lex.yy.c

reallyclean:
	rm -f *.o lex.yy.c $(SYNTHC) xgl \
		machdep.c machdep.h menutoc menutoc.c core

clean:
	rm -f *.o lex.yy.c $(SYNTHC) \
		machdep.c machdep.h core

shar:
	rm -f glib.shar.*
	makekit -m -nglib.shar.

glib.h:		machdep.h
glib.o:		glib.h
xgl.o:		glib.h
list.o:		glib.h
machdep.o:	glib.h
k1multi.o:	glib.h k1vis.h
k1single.o:	glib.h k1vis.h
k5multi.o:	glib.h
k5single.o:	glib.h
sblast.o:	glib.h sblast.h
tx81p.o:	glib.h
tx81z.o:	glib.h
linux_io.o:	glib.h sblast.h ultra.h midicode.h
