# Set the memory model
# -mx for 386, -mz for 286

MEMMOD = -mx -A
CC = ztc $(MEMMOD)

#								Csound Makefile
# edit the following definitions according to need:

DEST = e:\csound\beta386
DESTDIR = e:\csound\beta386
MANDIR = e:\man
MANL = $(MANDIR)\manl
CATL = $(MANDIR)\catl
ZIP = zip

DEFINES = -DSYS5 -DSFIRCAM -DWINDOWS -DWAV
# choose any of -
#	-DSYS5	    invoke System 5 headers (e.g. 'string.h' for 'strings.h')
#	-DWINDOWS   include window system calls (X11, SGI or Starbase graphics)
#	-DRTAUDIO   include real-time sound i/o via DEC or other audio-board
# at most one of -
#	-DSFIRCAM   read/write IRCAM-format soundfiles, with 1024-byte header;
#	-DSFSUN41   read/write SUN4.1-format soundfiles, with their own header;
#	-DNeXT      read/write NeXT-format soundfiles, with their own header;
#			(else read/write sound with no headers)
# and at most one of -
#	-DDEC		send rtaudio calls to DEC audio device handler
#	-DSGI		send rtaudio calls to SGI audio device handler
#	-Dsun		send rtaudio calls to sun audio device handler

CFLAGS = $(DEFINES) -O -w -D__STDC__
#	-O2		to be more specific about the optimization level
#	-f		compile single-precision floats (4.3,VAX,DEC-RISC)
# 	-fsingle	as above, for SUN Unix
# 	-float -ckkr 	as above, for SGI Unix
#	-f68881		employ the 68881 co-processor
#	-ffpa		employ the SUN fl-pt accelerator
#	+x		generate HP inline 68020 and 68881 code
#	+Nd1200		expand SYS5 pass3 tablesize
#	-I/usr/demo/SOUND		to find SUN4.1 audio includes
#	-I/usr/include/sys		to find NeXT malloc.h

LIBS =	fgp.lib
#	-L$(LIB) -lcsound -lm		required (for shared csound modules)
#	-lX11				for X window calls
#	-lfm_s -lgl_s 			for SGI graphics library
#	-lbsdipc -ldd98710 -lsb1 -lsb2	for HP Starbase Graphics
#	-l881				tell -lm to use 68881
#	-laudio				on SUN, for SFSUN41
#	-laudio				on SGI, to include rt devaudio library
#	-lmidi				on NeXT, to find the midi support

WINOBJ = winfg.obj
# ;if WINDOWS enabled in DEFINES, choose one of -
#	winX11.o	for X11 window graphics
#	winSGI.o	for SGI window graphics
#    	win98.o		for Starbase Graphics on HP98700 terminals

AUDOBJ = wave.obj
# ;if RTAUDIO enabled in DEFINES, include
#	rtaudio.o		general interface to audio handlers & libraries
# and at most one set of -
#	DECaudio.o DECplay.o	rt_handlers for DECaudio (with -DDEC)
#	[other things]		device handlers for other hardware

# do not edit below this line
# --------------------------------------------------------------------------

# macros passed to lower-level Makef files
#	CFLAGS INCLUDE LIBLIB DEST
M = "CFLAGS=$(CFLAGS)" "INCLUDE=$(INCLUDE)" "LIBLIB=$(LIBLIB)" "DEST=$(DEST)"

OBJS =	main.obj musmon.obj oload.obj rdorch.obj express.obj rdscor.obj \
	linevent.obj cscore.obj cscorefns.obj insert.obj entry.obj \
	aops.obj midiops.obj midirecv.obj fgens.obj ugens1.obj ugens2.obj \
	ugens3.obj ugens4.obj ugens5.obj ugens6.obj ugens7.obj ugens8.obj \
	spectra.obj disprep.obj window.obj winascii.obj $(WINOBJ) hetro.obj \
	lpanal.obj lptrkfns.obj pvanal.obj pvoc.obj fft.obj dsputil.obj \
	sndinfo.obj sfheaders.obj soundin.obj soundio.obj ulaw.obj aiff.obj \
	IEEE80.obj filopen.obj memalloc.obj memfiles.obj auxfd.obj windin.obj \
	dumpf.obj $(AUDOBJ)

SCOBJ = scot.obj

SOBJS = scsort.obj scxtract.obj sread.obj sort.obj extract.obj twarp.obj \
	swrite.obj

CSCM = cscore_main.obj

#I	= $(INCLUDE)\csound
#CSLIB	= $(LIBLIB)\csound.lib
PROGS   = csound.exe
SUBDIRS = anals utils1 utils2  #utils3		#utils3 not curr operative

all:	$(PROGS) $(SUBDIRS)		#must be run in this order
	echo done

csound.exe:	$(OBJS) $(SCOBJ) $(SOBJS) $(CSCM)
		$(CC) -ocsound $(OBJS) $(SCOBJ) $(SOBJS) $(LIBS) x32v.lib

$(SCOBJ):	scot.h
		$(CC) $(CFLAGS) -c $*.c

$(SOBJS):	sort.h
		$(CC) $(CFLAGS) -c $*.c

oload.obj:	oload.h ugens3.h ugens5.h ugens8.h soundio.h dumpf.h \
			sysdep.h prototypes.h cs.h oload.c
		$(CC) $(CFLAGS) -c $*.c

insert.obj:	insert.h aops.h midiops.h sysdep.h prototypes.h cs.h insert.c
		$(CC) $(CFLAGS) -c $*.c

entry.obj:	insert.h aops.h midiops.h ugens1.h ugens2.h ugens3.h ugens4.h \
		ugens5.h lpc.h ugens6.h ugens7.h ugens8.h dsputil.h \
		spectra.h window.h windin.h disprep.h soundio.h \
		sysdep.h prototypes.h cs.h entry.c
		$(CC) $(CFLAGS) -c $*.c

aops.obj:	aops.h sysdep.h prototypes.h cs.h aops.c
		$(CC) $(CFLAGS) -c $*.c

musmon.obj midiops.obj midirecv.obj:	sysdep.h prototypes.h cs.h midiops.h
		$(CC) $(CFLAGS) -c $*.c

ugens1.obj:	ugens1.h sysdep.h prototypes.h cs.h ugens1.c
		$(CC) $(CFLAGS) -c $*.c

ugens2.obj:	ugens2.h sysdep.h prototypes.h cs.h ugens2.c
		$(CC) $(CFLAGS) -c $*.c

ugens3.obj:	ugens3.h sysdep.h prototypes.h cs.h ugens3.c
		$(CC) $(CFLAGS) -c $*.c

ugens4.obj:	ugens4.h sysdep.h prototypes.h cs.h ugens4.c
		$(CC) $(CFLAGS) -c $*.c

ugens5.obj:	ugens5.h lpc.h sysdep.h prototypes.h cs.h ugens5.c
		$(CC) $(CFLAGS) -c $*.c

ugens6.obj:	ugens6.h sysdep.h prototypes.h cs.h ugens6.c
		$(CC) $(CFLAGS) -c $*.c

ugens7.obj:	ugens7.h sysdep.h prototypes.h cs.h ugens7.c
		$(CC) $(CFLAGS) -c $*.c

ugens8.obj:	ugens8.h soundio.h fft.h dsputil.h pvoc.h sysdep.h \
			prototypes.h cs.h ugens7.c
		$(CC) $(CFLAGS) -c $*.c

spectra.obj:	spectra.h window.h sysdep.h prototypes.h cs.h spectra.c
		$(CC) $(CFLAGS) -c $*.c

disprep.obj:	disprep.h window.h fft.h dsputil.h sysdep.h prototypes.h \
			cs.h disprep.c
		$(CC) $(CFLAGS) -c $*.c

window.obj:	window.h sysdep.h prototypes.h cs.h window.c
		$(CC) $(CFLAGS) -c $*.c

winascii.obj:	window.h sysdep.h prototypes.h cs.h winascii.c
		$(CC) $(CFLAGS) -c $*.c

winX11.obj:	window.h sysdep.h prototypes.h cs.h winX11.c
		$(CC) $(CFLAGS) -c $*.c

winSGI.obj:	window.h sysdep.h prototypes.h cs.h winSGI.c
		$(CC) $(CFLAGS) -c $*.c

windin.obj:	window.h windin.h sysdep.h prototypes.h cs.h windin.c
		$(CC) $(CFLAGS) -c $*.c

fgens.obj:	window.h soundio.h sysdep.h prototypes.h cs.h fgens.c
		$(CC) $(CFLAGS) -c $*.c

main.obj:  soundio.h sysdep.h prototypes.h cs.h main.c
		$(CC) $(CFLAGS) -c $*.c

musmon.obj:  soundio.h sysdep.h prototypes.h cs.h musmon.c
		$(CC) $(CFLAGS) -c $*.c

soundin.obj:  soundio.h sysdep.h prototypes.h cs.h soundin.c
		$(CC) $(CFLAGS) -c $*.c

soundio.obj:  soundio.h sysdep.h prototypes.h cs.h soundio.c
		$(CC) $(CFLAGS) -c $*.c

lpanal.obj:	soundio.h lpc.h lpanal.c sysdep.h prototypes.h cs.h
		$(CC) $(CFLAGS) -c $*.c

pvanal.obj:	soundio.h fft.h pvoc.h dsputil.h pvanal.c \
		sysdep.h prototypes.h cs.h
		$(CC) $(CFLAGS) -c $*.c

pvoc.obj: 	pvoc.h sysdep.h prototypes.h cs.h pvoc.c
		$(CC) $(CFLAGS) -c $*.c

fft.obj:  	fft.h fft.c sysdep.h prototypes.h cs.h
		$(CC) $(CFLAGS) -c $*.c

dsputil.obj:  	dsputil.h dsputil.c sysdep.h prototypes.h cs.h
		$(CC) $(CFLAGS) -c $*.c

sfheaders.obj:	soundio.h sfheader.h  sysdep.h prototypes.h cs.h sfheaders.c
		$(CC) $(CFLAGS) -c $*.c

aiff.obj: 	soundio.h sfheader.h aiff.h sysdep.h prototypes.h cs.h aiff.c
		$(CC) $(CFLAGS) -c $*.c

wave.obj:	soundio.h wav.h sysdep.h prototypes.h cs.h wave.c
		$(CC) $(CFLAGS) -c $*.c

rtaudio.obj:	soundio.h DECplay.h sysdep.h prototypes.h cs.h
		$(CC) $(CFLAGS) -c $*.c

DECaudio.obj:	DECaudio.h sysdep.h prototypes.h cs.h
		$(CC) $(CFLAGS) -c $*.c

DECplay.obj:	DECplay.h sysdep.h prototypes.h cs.h
		$(CC) $(CFLAGS) -c $*.c

winfg.obj:	winfg.c sysdep.h prototypes.h cs.h
		$(CC) $(CFLAGS) -c winfg.c

$(OBJS):	sysdep.h prototypes.h cs.h
		$(CC) $(CFLAGS) -c $*.c

cscore_main.obj:	cscore_main.c
		$(CC) $(CFLAGS) -c $*.c

ADSYNS = hetro 						#targets in anal\adsyn
LPCS = lpcanal						#targets in anal\lpc
PVOCS = pvanal 						#targets in anal\pvoc
ANALS = adsyns $(ADSYNS) lpcs $(LPCS) pvocs $(PVOCS)	#targets in anal
anals $(ANALS):
		cd anal
		make $@
		cd ..

SCOTS = scots						#targets in util1\scot
CSCORES = cscores					#targets in util1\cscore
SORTEXS = scsort extract				#targets in util1\sortex
UTILS1 = $(SCOTS) $(CSCORES) sortexs $(SORTEXS)		#targets in util1
utils1 $(UTILS1):
		cd util1
		make $@ 
		cd ..

UTILS2 = sndinfo scale					#targets in util2
utils2 $(UTILS2):
		cd util2
		make $@
		cd ..

SNDINS = sndin sndout   				#targets in util3\
UNDECS = undec vaxify   				#targets in util3\undecv
UTILS3 = sndins $(SNDINS) rescale undecs $(UNDECS)      #targets in util3
utils3 $(UTILS3):
		cd util3
		make $@
		cd ..

install:	$(PROGS)
		$(ZIP) $(DEST)\cs386 $(PROGS)
		cd anal
		make install
		cd ..
		cd util1
		make install
		cd ..
		cd util2
		make install DESTDIR=$(DEST)
		cd ..
	#	cd util3; make install		# currently inoperative

MANPP = csound hetro lpcanal pvanal
manpp:
		-for i in $(MANPP); do del -f $(CAT1)\$$i.1; done
		-for i in $(MANPP); do copy man\$$i.man $(MAN1)\$$i.1; done

clean:
		-del *.obj
		-del *.exe
		-del *.s
		cd anal
		make clean
		cd ..
		cd util1
		make clean
		cd ..
		cd util2
		make clean
		cd ..
		del testfiles\score.srt
		del testfiles\score.xtr
		del tutorfiles\score.srt
		del tutorfiles\score.xtr
		del scorefiles\score.srt
		del scorefiles\score.xtr
		del morefiles\score.srt
		del morefiles\score.xtr
		del midifiles\score.srt
		del midifiles\score.xtr

src.zip:
	$(ZIP) -a -r -p src.zip makefile makefile.* *.c *.h


