##
## Sound Tools Makefile for AMIGA with SAS/C 6.1
## 	builds libst.lib and sox
##
## This must be redone to compile with DICE, GCC, etc.
##
## Choose the version you wish to compile with:
## <make-tool> -f Makefile.ami			(for basic version)
## <make-tool> -f Makefile.ami CPU=030		(for 68030 version)
## <make-tool> -f Makefile.ami FPU=881		(for 68881 FPU version)
## <make-tool> -f Makefile.ami CPU=030 FPU=881	(for 030/881 version)
##
## Note: This makefile does not work with SAS's 'smake' utility, because
## 'smake' is weak.  Get yourself a real 'make' tool, such as the port of
## 'dmake'.  If you can't find one, use the commented-out section below to
## rewrite this makefile for 'smake'.
##

FSRC= raw.c voc.c au.c sf.c aiff.c hcom.c 8svx.c sndrtool.c wav.c \
	smp.c sbdsp.c auto.c cdr.c dat.c \
	g711.c g72x.c g721.c g723_24.c g723_40.c

ESRC= copy.c avg.c pred.c stat.c vibro.c echo.c rate.c band.c lowp.c \
	highp.c reverse.c
PSRC= sox.c

SOURCES   = $(PSRC) $(FSRC) $(ESRC) handlers.c libst.c misc.c getopt.c

HEADERS   = st.h libst.h sfheader.h version.h patchlvl.h 

TESTS     = tests.sh monkey.au monkey.voc

MISC      = README INSTALL TODO sox.man sox.txt st.man Makefile.unx \
	    sb.prog.doc Makefile.bor Makefile.ami

SKEL	  = skel.c skeleff.c
VMS       = descrip.mms sound2au.com sound2sun.c sound2sun.opt \
	    sox.opt tests.com vms.lis

AMIGA	  = Makefile.ami amiga.h

FILES     = $(MISC) $(HEADERS) $(SOURCES) $(VMS) $(AMIGA) $(SKEL) $(TESTS)

FOBJ= raw.o voc.o au.o sf.o aiff.o hcom.o 8svx.o sndrtool.o wav.o \
	smp.o sbdsp.o auto.o cdr.o dat.o \
	g711.o g72x.o g721.o g723_24.o g723_40.o

EOBJ= copy.o avg.o pred.o stat.o vibro.o echo.o rate.o band.o lowp.o \
	highp.o reverse.o

##SOUNDLIB is defined below
LIBOBJS   = $(FOBJ) $(EOBJ) handlers.o libst.o misc.o getopt.o

##
## System dependency parameters
##
##
## Amiga vars for SAS 6.1.
## Lots of funky stuff here.  Unnecessary, but keeps it neat.
## Also matches unix makefile more closely.
##
CC	= sc DEF=__STDC__ DEF=AMIGA
##IGNore some warnings due to lack of prototyping in SOX code
O	= IGN=85 IGN=93 IGN=100 IGN=154 IGN=161 OPTIMIZE OPTIMIZERINLINELOCAL OPTIMIZERTIME OPTIMIZERALIAS
AR	= oml
AR_ARGS	= a
RM	= delete
MATH	= 
MATH881	= MATH=68881
CPUF	= 
CPUF030	= CPU=68030
MATHLIB	= lib:scm.lib
MATHLIB881	= lib:scm881.lib
DEFS	= 
DEFS881	= DEF=AMIGA_MC68881
DEFS030	= DEF=AMIGA_MC68030
##
SOX	= sox$(CPU)$(FPU)
SOUNDLIB= libst$(CPU)$(FPU).lib
CFLAGS	+= $(O) DEF=AMIGA $(DEFS$(FPU)) $(DEFS$(CPU)) $(MATH$(FPU)) $(CPUF$(CPU))
LIBS	= $(MATHLIB$(FPU)) lib:sc.lib lib:amiga.lib
##

###################################################
##This is unnecessary if you have a serious 'make'.
##If you don't, use it as a guide to building your
##own makefile.
###################################################
##
## 68000, no FPU
#SOX	= sox
#SOUNDLIB= libst.lib
#MATHLIB	= lib:scm.lib
#CFLAGS	+= $(O) DEF=AMIGA
##
## 68000, 68881 FPU
#SOX	= sox881
#SOUNDLIB= libst881.lib
#MATHLIB	= lib:scm881.lib lib:scm.lib
#CFLAGS	+= $(O) MATH=68881 DEF=AMIGA DEF=AMIGA_MC68881
##
## 68030, no FPU
#SOX	= sox030
#SOUNDLIB= libst030.lib
#MATHLIB	= lib:scm.lib
#CFLAGS	+= $(O) CPU=68030 DEF=AMIGA
##
## 68030, 68881 FPU
#SOX	= sox030881
#SOUNDLIB= libst030881.lib
#MATHLIB	= lib:scm881.lib lib:scm.lib
#CFLAGS	+= $(O) MATH=68881 CPU=68030 DEF=AMIGA DEF=AMIGA_MC68881

##
## start your engines
##
all: $(SOX)

$(SOX): sox.o $(SOUNDLIB)
	slink lib:c.o sox.o to $(SOX) lib $(SOUNDLIB) $(LIBS) SMALLCODE SMALLDATA STRIPDEBUG NOICONS

$(SOUNDLIB): $(LIBOBJS)
	$(AR) $(SOUNDLIB) $(AR_ARGS) $(LIBOBJS)

sox.o:		sox.c st.h

sox.txt: sox.man
	$(RM) sox.txt
	nroff -man sox.man > sox.txt
	nroff -man st.man > st.txt

clean:
	$(RM) #?.o
