#								Csound Makefile
# macros passed to lower Makef files
#	CFLAGS DESTDIR INCLUDE LIBLIB

# edit the following definitions according to need:

DEFINES = -DSYS5
# choose any of -
#	-DSYS5:	    invoke System 5 headers (e.g. 'string.h' for 'strings.h')
#			(must also enable this in util/scot/Makef)
#	-DXWINDOWS: include X11 window system calls (does not work yet)
#	-DSFIRCAM:  read/write IRCAM-format soundfiles, with 1024-byte header;
#			else read/write sound with no headers
#	-DSFREMOTE: enable remote soundfile access using rexec
#	-DULAW:	    include code for -u flag to output ulaw-encoded bytes
#			(cannot be used with SFIRCAM)

LIBS =	-lm
#	-lX11					for X window calls
#	-lbsdipc -ldd98710 -lsb1 -lsb2		for HP Starbase Graphics
#	-l881					tell -lm to use 68881

INCLUDE = /usr/local/include
LIBLIB = /usr/local/lib/
DESTDIR = /usr/local/bin/
MANDIR = /usr/local/man
MANL = $(MANDIR)/manl
CATL = $(MANDIR)/catl

CFLAGS = -O2 -fomit-frame-pointer $(DEFINES) -I$(INCLUDE)
#	-f		compile single-precision floats (4.3,VAX, DEC-RISC)
# 	-fsingle	as above, for SUN 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

DISPOBJS = 
# choose
#	dispX11.o	if XWINDOWS enabled in DEFINES
# and one of -
#    	disp98.o	for Starbase Graphics on HP98700 terminals
#    or disp0.o		for standard character displays

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

SHELL = /bin/sh

OBJS =	main.o musmon.o oload.o rdorch.o express.o rdscor.o insert.o \
	entry.o fgens.o aops.o ugens1.o ugens2.o ugens3.o ugens4.o ugens5.o \
	ugens6.o fft_net.o disprep.o display.o $(DISPOBJS) \
	sfcodes.o sfname.o soundio.o memalloc.o memfiles.o auxfd.o

PROGS = perf csound
SUBDIRS = anals utils

all:		$(PROGS) $(SUBDIRS)

includes:
		-mkdir $(INCLUDE)/local
		cp lpc.h sfheader.h sfdir.h util/cscore/cscore.h $(INCLUDE)/local

perf:		perf.c
		cc $(CFLAGS) -o perf perf.c

csound:		$(OBJS)
		cc $(CFLAGS) -n -o csound $(OBJS) $(LIBS)

csound.a:	$(OBJS)		#this for development only
		-rm csound.a
		ar q csound.a $(OBJS)
		ranlib csound.a

$(OBJS):	sysdep.h cs.h

oload.o:	oload.h

insert.o:	insert.h aops.h

entry.o:	insert.h aops.h ugens1.h ugens2.h ugens3.h \
		dispX11.h \
		ugens4.h lpc.h ugens5.h ugens6.h fft.h disprep.h soundio.h

aops.o:		aops.h

ugens1.o:	ugens1.h

ugens2.o:	ugens2.h

ugens3.o:	ugens3.h

ugens4.o:	ugens4.h lpc.h

ugens5.o:	ugens5.h

ugens6.o:	ugens6.h

fft_net.o:	fft.h

disprep.o:	disprep.h dispX11.h

display.o:	dispX11.h

sfcodes.o:	sfheader.h

fgens.o:	sfheader.h soundio.h dispX11.h

main.o soundio.o:  sfheader.h soundio.h


MAKE = make -f Makef  "CFLAGS=$(CFLAGS)" "DESTDIR=$(DESTDIR)" "INCLUDE=$(INCLUDE)/local" "LIBLIB=$(LIBLIB)"

ADSYNS = hetro 						#targets in anal/adsyn
LPCS = ptrack anallpc lpinfo lpconcat lpdump lpinfed	#targets in anal/lpc
ANALS = adsyns $(ADSYNS) lpcs $(LPCS)			#targets in anal
anals $(ANALS):
		cd anal; $(MAKE) $@

SCOTS = scots						#targets in util/scot
CSCORES = cscores					#targets in util/cscore
SORTEXS = scsort extract				#targets in util/sortex
UTILS = $(SCOTS) $(CSCORES) sortexs $(SORTEXS)		#targets in util
utils $(UTILS):
		cd util; $(MAKE) $@

inst-csound:	csound
		mv csound $(DESTDIR)/

install:	$(PROGS)
		-strip $(PROGS)
		-rm $(DESTDIR)/perf $(DESTDIR)/csound
		cp $(PROGS) $(DESTDIR)
		cd anal; $(MAKE) install
		cd util; $(MAKE) install

MANPP = csound perf adsyn hetro lpc
manpp:
		-for i in $(MANPP); do rm -f $(CATL)/$$i.l; done
		cd man; cp csound.man $(MANL)/csound.l;
		cd man; cp perf.man $(MANL)/perf.l;
		cd anal/adsyn; cp adsyn.man $(MANL)/adsyn.l
		cd anal/adsyn; cp hetro.man $(MANL)/hetro.l
		cd anal/lpc; cp lp.man $(MANL)/lpc.l

clean:
		-rm $(OBJS) $(PROGS) csound.a
		cd anal; $(MAKE) clean
		cd util; $(MAKE) clean

rmbak:
		-rm *.bak *~
		cd anal; $(MAKE) rmbak
		cd util; $(MAKE) rmbak
		cd man; rm -f *.bak *~
		cd manual; rm -f *.bak *~
		cd testfiles; rm -f *.bak *~

SOURCE = /src/local
EXPORT = /src/local/export
PUBLIC = /projects/ftp/pub
export:
		cd $(EXPORT); rm -rf csound;
		cd $(SOURCE); tar cf - csound | (cd $(EXPORT); tar xf -);
		cd $(EXPORT)/csound; make rmbak; make clean;
		cd $(EXPORT); tar cf $(PUBLIC)/csound.tar csound; rm -rf csound;
		cd $(PUBLIC); cp csound.tar tmp; compress tmp; mv tmp.Z csound.tar.Z;
