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

# edit the following definitions according to need:

DEFINES = -DXWINDOWS -DSFIRCAM -DSFREMOTE
# 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 X window system calls
#	-DSFIRCAM:  read/write IRCAM-format soundfiles, with 1024-byte header;
#			else read/write sound with no headers
#	-DSFREMOTE: enable remote soundfile access using rexec

CFLAGS = -O -f $(DEFINES)
#	-f		compile single-precision floats (4.3, VAX)
# 	-fsingle	as above, for SUN Unix
#	-f68881		employ the 68881 co-processor
#	-fpa		employ the SUN fl-pt accelerator
#	+x		generate HP inline 68020 and 68881 code
#	+Nd1200		expand SYS5 pass3 tablesize

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

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

DISPOBJS = dispX.o disp0.o
# choose
#	dispX.o		if XWINDOWS enabled in DEFINES
# and one of -
#	disp125.o	for Regis Graphics on VT125 displays
#    or	disp98.o	for Starbase Graphics on HP98700 displays
#    or disp0.o		if neither of the above

# 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 \
	fft_net.o disprep.o display.o $(DISPOBJS) \
	sfcodes.o sfname.o soundio.o auxfd.o

PROGS = perf csound
SUBDIRS = anals utils

all:		$(PROGS) $(SUBDIRS)

includes:
		cp sfheader.h soundfile.h util/cscore/cscore.h $(INCLUDE)

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 \
		ugens4.h lp.h ugens5.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 lp.h

ugens5.o:	ugens5.h

fft_net.o:	fft.h

disprep.o:	disprep.h

sfcodes.o:	$(INCLUDE)/sfheader.h

main.o fgens.o soundio.o:  $(INCLUDE)/sfheader.h soundio.h


MAKE = make -f Makef  "CFLAGS=$(CFLAGS)" "DESTDIR=$(DESTDIR)" "INCLUDE=$(INCLUDE)" "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) $@

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;
