
# Sound Tools Makefile
# 	builds libst.a and sox

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 wve.c maud.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 dyn.c cut.c map.c split.c pick.c mask.c \
	resample.c 
PSRC= sox.c

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

HEADERS   = st.h libst.h sfheader.h sfircam.h patchlvl.h version.h wav.h \
	g72x.h resdefs.h resampl.h

TESTS     = tests.sh testall.sh monkey.au monkey.voc

MISC      = README README2 INSTALL TODO TIPS CHEAT sox.man sox.txt st.man \
	    Makefile.unx Makefile.bor Makefile.b30 Makefile.c70 \
	    sbprog.doc voc.info sox.sh

SKEL	  = skel.c skeleff.c

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

NT 	  = sox.nt

OS2	  = MakeOS2 MakeOS2.dep

OS9	  = Makefile.os9

AMIGA	  = Makefile.ami amiga.c amiga.h

ACORN	  = Makefile.arc Setup armfloor.c armceil.c

FILES     = $(MISC) $(HEADERS) $(SOURCES) \
		$(VMS) $(AMIGA) $(NT) $(OS2) $(OS9) $(ACORN) \
		$(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 wve.o maud.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 dyn.o cut.o map.o split.o pick.o mask.o \
	resample.o 

SOUNDLIB  = libst.a
LIBOBJS   = $(FOBJ) $(EOBJ) handlers.o libst.o misc.o util.o getopt.o

#
# System dependency parameters
# 	not many, we don't mess with devices
#
# include -DSYSV for AT&T Unix System V

# SHELL	  = /bin/sh	# You may need this.

# define -DNEED_GETOPT to use the enclosed getopt() library.
# To use the system getopt() and getopt.h, don't define NEED_GETOPT

# define -DNEED_STRERROR if you don't have a built-in strerror().

# define -DBLASTER to use the Sound Blaster device driver
# on a 386 AT&T Unix with it installed

# define -DSBLAST to use Steve Haenichen's SBLAST
# driver on any BSD-derived Unix for 386/486 PC's
# BSDI's BSD386, Jolitz 386BSD, or Mt Xinu's Mach-386

# define -DDOS  to compile on PC
# defines .snd to mean a DOS soundtool file (starts with SOUND)

# define -DNeXT on a NeXT workstation
# defines .snd to mean a NeXT sound format file
#  	only knows a few real sound formats.

# define -DMAC on a MacIntosh
# defines .snd to mean a Mac-style headerless unsigned byte
#  	sample, probably at 11050 hertz.  You'll have to set 
#	the speed on the command line.

RM	    = rm -f

# My AT&T System V/386 development parameters

# O=-g		# optimization flags
# CFLAGS    = $O -DSYSV -DBLASTER -Di386 -DNEED_GETOPT -DNEED_STRERROR
# CC	    = cc -Dunix
# CC        = gcc -fpcc-struct-return -ansi -Dunix
# AR        = ar r
# RANLIB    = ar ts

# AT&T System V

# CFLAGS    = $O -DSYSV  -DNEED_GETOPT -DNEED_STRERROR
# Gcc is better, of course, if you have it
# CC        = gcc -ansi -Dunix -fpcc-struct-return 
# CC        = cc -Dunix
# AR        = ar r
# RANLIB    = ar ts

# IBM AIX 3.2

# CFLAGS    = $O -DSYSV 
# CC        = xlc -D_ALL_SOURCE -Dunix
# AR        = ar r
# RANLIB    = ar ts

# BSD-ish, salt to taste
# Sun, NeXT, Vax, Ultrix uses these

CFLAGS    = $O -DNEED_GETOPT 
#  maybe -DNEED_STRERROR
CC        = shlicc -ansi -Dunix 
# CC        = cc -Dunix
AR        = ar r
RANLIB    = ranlib

# BSD-386, Mach 386, 386BSD, use for SBLAST driver

# CFLAGS    = $O -I/usr/src/sys -DSBLAST -DNEED_GETOPT
#  maybe -DNEED_STRERROR
# CC        = /usr/local/bin/gcc -ansi -Dunix 
# AR        = ar r
# RANLIB    = ranlib

# linux (with soundcard support -DLINUXSOUND)

# CFLAGS	= -O -DLINUXSOUND -DNEED_GETOPT
# CC		= gcc -fpcc-struct-return -Dunix -ansi
# AR		= ar r
# RANLIB	= ranlib

# HPUX (no hardware support, though)
# include -Aa in CFLAGS if the source ever supports ANSI C

# CFLAGS      = -O -D_HPUX_SOURCE
# CC          = cc
# AR          = ar r
# RANLIB      = ranlib

# GCC on DOS based systems (DJGPP)

# CC      = gcc
# CFLAGS  = -DDOS -ansi -I./sox
# AR      = ar r
# RANLIB  = ar ts
# RM  = del /q


all: sox sox.0 st.0

sox: sox.o $(SOUNDLIB)
	$(CC) $(CFLAGS) -o sox sox.o $(SOUNDLIB) -lm

$(SOUNDLIB): $(LIBOBJS)
	$(RM) $(SOUNDLIB)
	$(AR) $(SOUNDLIB) $(LIBOBJS)
	$(RANLIB) $(SOUNDLIB)

sox.o:		sox.c st.h

$(LIBOBJS):	st.h version.h patchlvl.h

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

clean:
	$(RM) *.o
	$(RM) *.raw
	$(RM) *.sf
	$(RM) core

# Shar: -F (prefix all lines with X), 
# 	-s addr (set return addr of poster)
shar: $(FILES)
	/usr2/tools/shar/shar -M -F -l 50 -o shar -n soundtools_v11 -s thinman@netcom.com $(FILES)

tar:
	$(RM) sox.tar
	tar cf sox.tar $(FILES)

cleandir: clean
	$(RM) libst.a sox st.0 sox.0

depend:

obj:

tags:

objdir:

mansourceinstall:
	install -c -o bin -g bin -m 0444 sox.man ${DESTDIR}/usr/contrib/man/man1/sox.1
	install -c -o bin -g bin -m 0444 st.man ${DESTDIR}/usr/contrib/man/man3/st.3

install: sox sox.0 st.0
	strip sox
	install -c -o bin -g bin -m 0555 sox ${DESTDIR}/usr/contrib/bin
	install -c -o bin -g bin -m 0444 libst.a ${DESTDIR}/usr/lib
	install -c -o bin -g bin -m 0444 sox.0 ${DESTDIR}/usr/contrib/man/cat1
	install -c -o bin -g bin -m 0444 st.0 ${DESTDIR}/usr/contrib/man/cat3

sox.0:	sox.man
	nroff -man sox.man > sox.0

st.0:	st.man
	nroff -man st.man > st.0
