#
# Sound Tools Makefile
#
# 	builds libst.a and sox
#
# Last updated on 02/24/97 - by Chris Bagwell (cbagwell@sprynet.com)
#   Inhanced Makefile to install software and documented a little better.
#   Remember, make is here to help out not slow you down. :-)

# These things are site dependant so you may want to change.
BINDIR    = /usr/local/bin
MANDIR    = /usr/man

SRCDIR	  = sox-11gamma-cb3

FSRC 	  = 8svx.c aiff.c au.c auto.c cdr.c cvsd.c dat.c g711.c g721.c \
	    g723_24.c g723_40.c g72x.c hcom.c maud.c oss.c raw.c sbdsp.c \
	    sf.c smp.c sndrtool.c sunaudio.c voc.c wav.c wve.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.1 sox.txt libst.3 \
	    libst.txt Makefile.unx Makefile.bor Makefile.b30 Makefile.c70 \
	    sbprog.doc sox.sh play rec

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	  = 8svx.o aiff.o au.o auto.o cdr.o cvsd.o dat.o g711.o g721.o \
	    g723_24.o g723_40.o g72x.o hcom.o maud.o oss.o raw.o sbdsp.o \
	    sf.o smp.o sndrtool.o sunaudio.o voc.o wav.o wve.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
#   Starting to grow.  Find your system and uncomment defines.
#
# Your system  may need to define which shell to use.
# SHELL	  = /bin/sh
#
# Define how to delete a file on your system.
RM	    = rm -f
# For DOS uses this.
#RM	     = del /q

# include -DSYSV for AT&T Unix System V and Solaris
#
# 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 -DOSS_PLAYER to use OSS Unix sound driver on any
# unix platform that supports it (Linux, Sun, others)
#
# define -DSUNAUDIO_PLAYER to use Sun Audio driver on a SunOS 4.x.x
# or Solaris 2.x (SunOS 5.x.x) system.
#
# 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.

# My AT&T System V/386 development parameters

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

# AT&T System V

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

# IBM AIX 3.2

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

# BSD-ish, salt to taste
# Sun, NeXT, Vax, Ultrix uses these
# Sun's can add -DSUNAUDIO_PLAYER for playing sounds

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

# Solaris 2.x systems
# Can add -DSUNAUDIO_PLAYER for playing sounds

# CC        = gcc -ansi -Dunix 
# CC        = cc -Dunix
# O         = -O2
# CFLAGS    = $O -DSYSV -DNEED_STRERROR -DSUNAUDIO_PLAYER
# AR        = ar -r
# RANLIB    = true

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

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

# linux (with soundcard support -DOSS_PLAYER)

CC	    = gcc -fpcc-struct-return -Dunix -ansi
O           = -O2
CFLAGS	    = $0 -DOSS_PLAYER -DNEED_GETOPT
AR	    = ar r
RANLIB	    = ranlib

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

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

# GCC on DOS based systems (DJGPP)

# CC      = gcc
# O         = -O2
# CFLAGS  = $O -DDOS -ansi -I./sox
# AR      = ar r
# RANLIB  = ar ts

all: sox

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

man: sox.1 libst.3
	$(RM) sox.txt libst.txt
	nroff -man sox.1 | col > sox.txt
	nroff -man libst.3 | col > libst.txt

install: sox
	-install -c -o root -m 755 sox play rec $(BINDIR)
	-install -c -o root -m 644 sox.1 $(MANDIR)/man1
	-install -c -o root -m 644 libst.3 $(MANDIR)/man3

clean:
	$(RM) *~ *.o *.raw *.sf core sox libst.a

# 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:	clean
	$(RM) ../$(SRCDIR).tar
	cd ..; tar cvf $(SRCDIR).tar $(SRCDIR)
