##############################################################################
#
# Makefile for the mixview soundfile editing/processing program.
#
# If running Sun OS 3.5 or higher, see the note below for LXT make.
#
# If compiling under X11 Release 3, add -DR3 to the DEFINES macro
#
##############################################################################
#
VERSION=3.72
PATCH=37
#
# Set DESTDIR to the directory you wish to contain the binary file.
DESTDIR=/usr/local/bin
#
# Use this for Sun workstations
# ARCH=`/bin/arch`
## And this for others (set to your machine type)
ARCH=NeXT
# ARCH=SYSV
# ARCH=VAX
#
# Set LXTSRCLIB to the directory into which you have put the lxt source code
LXTSRCLIB=../lxt
# Set LXTINCLIB to the directory into which you have installed lxt.h
LXTINCLIB=../lxt
# Set LXTLIBLIB to the directory into which you have installed liblxt_*.a
LXTLIBLIB=../lxt
#
# Set this depending on your system and compiler
# Sun compiler
# FLAGS=-O
#
# Sun debugging
# FLAGS = -g -Ddebug
#
# SYSV Compiler
# FLAGS = -O -DSYSV
#
# Gnu compiler, for debugging
#FLAGS=-g -O -W
#
# Gnu compiler, optimized
#FLAGS=-O -fstrength-reduce -finline-functions
#
# Gnu 2.x compiler, optimized
FLAGS=-O2 -Wno-import -fno-caller-saves
#
# If you are running NeXT O.S. 1.0*, use the following:
# FLAGS=-O -bsd
#
CC=gcc
FC=/usr/lang/f77
#
# Set this to -lm for any system other than NeXT or i386
# SYSLIBS=-lm
# For NeXT
SYSLIBS=-lsys_s
# For i386:
#SYSLIBS=-lm -lPW -lmalloc
#
# Set LXTMAKEOPTS to nothing if running Sun OS > 3.5, otherwise consult lxt
# Makefiles to determine best one for make.
LXTMAKEOPTS=-f Makefile_3.2
# LXTMAKEOPTS=
#
# Set FORTFLAGS and FORTDEFINES to nothing if you do not have a fortran compiler
# Other option is for use on machines with the f2c libraries available.
# FORTFLAGS=
# FORTFLAGS=-lF77
FORTFLAGS=-lf2c
# FORTDEFINES=
# FORTDEFINES=-DHAS_F77
FORTDEFINES=-DHAS_F2C
#
# SNDFLAGS should be set to -DSPARC_AUDIO on Suns with audio capability and
# any Sun 4 or SPARC that will be used to read SPARC soundfile format files.
# It should not be set on NeXTs.
# If you wish to read NeXT-style headers on a SPARC, add -DUSE_NeXT_HEADERS
# SNDFLAGS=-DSPARC_AUDIO -DUSE_NeXT_HEADERS
SNDFLAGS=
# DACFLAGS should only be set on SPARCStations with the SOUND package
# It does not need to be set for NeXTs
# Sparc 1, 2
# DACFLAGS=-DSPARC_DACS
#
# Sparc 10 with 16-bit DACS
# DACFLAGS=-DSPARC_DACS -DSPARC_16_BIT
#
# Any machine with the ADS converter box
# DACFLAGS=-DADC_DACS
#
# Machines with the SoundBlaster Card
# DACFLAGS=-DSOUNDBLASTER
#
DACFLAGS=
#
# DACINCLUDES is set to the directory containing header files for dac code
# DACINCLUDES=-I/usr/local/src/adc
DACINCLUDES=
#
# SNDLIBS and SNDINCLUDES should only be set on SPARCStations with the SOUND 
# package (usually in /usr/demo/SOUND)
SNDLIBS=
# SNDLIBS=-L/usr/demo/SOUND -laudio
SNDINCLUDES=
# SNDINCLUDES=-I/usr/demo/SOUND
# COMMENTFLAGS determines whether BSD header format includes a comment
# (It is only set to nothing on IRCAM machines)
COMMENTFLAGS=-DHAS_SFCOMMENT
##############################################################################
#
OBJS = $(OBJECTS) $(DACOBJS)
DEFINES = $(COMMENTFLAGS) $(DACFLAGS) $(SNDFLAGS) $(FORTDEFINES)
INCLUDES = -I$(LXTINCLIB) $(SNDINCLUDES) $(DACINCLUDES)
LIBS = $(X11LIBS) $(SNDLIBS) $(SYSLIBS)
CFLAGS = $(FLAGS) $(DEFINES) $(INCLUDES)
#
###############################################################################
SOURCES = analysis.c cmd.c curves.c databuff.c datawin.c default.c dialog.c \
display.c events.c fft.c filts.c graphpoints.c gravy.c io.c keybd.c lpctools.c \
main.c mell.c menus.c mesg.c mixfuns.c panels.c phrase.c play.c ptrackfuns.c \
range.c record.c scale.c screen.c setell.c sfcodes.c soundfile.c trans.c \
text.c windows.c

OBJECTS = analysis.o cmd.o curves.o databuff.o datawin.o default.o dialog.o \
display.o events.o fft.o filts.o graphpoints.o gravy.o io.o keybd.o \
lpctools.o main.o mell.o menus.o mesg.o mixfuns.o panels.o phrase.o play.o \
ptrackfuns.o range.o record.o scale.o screen.o setell.o sfcodes.o soundfile.o \
trans.o text.o windows.o

# These are the objects for the ADS converter library 
# DACOBJS = /usr/local/src/adc/adclib.o
DACOBJS=

# These are for malloc debugging on Sun 4's only (for making testmixview)
# MALLOCDEBUGOBJECTS = /usr/lib/debug/malloc.o /usr/lib/debug/mallocmap.o
MALLOCDEBUGOBJECTS = 

LXT = $(LXTLIBLIB)/liblxt_$(ARCH).a
LXTLIBS = -L$(LXTLIBLIB) -llxt_$(ARCH)
LXSOURCES = $(LXTSRCLIB)/*.c
LXOBJS = $(LXTSRCLIB)/*.o
LINTLIBS = -lX11 
LXTLINTLIB = -llxt

X11LIBS=-lX11

# This next line is for i386 machines
#X11LIBS=-lX11_s -lc_s -lpt /usr/lib/X11/X386/etc/inetemul.o

mixview: $(OBJS) $(LXT)
	$(CC) $(CFLAGS) -o mixview $(OBJS) $(DEBUGLIBS) $(LXTLIBS) $(FORTFLAGS) $(LIBS) 

# *** NOTE:  Remove -bsd if you are not using a Gnu C compiler

$(LXT):
	cd $(LXTSRCLIB); $(MAKE) "CC=$(CC)" "ARCH=$(ARCH)" "FLOAT=$(CFLAGS)" $(LXTMAKEOPTS)
	
# Uncomment this if you have an F77 compiler -- use fortran version of setell
#setell.o: setell.f
#	$(FC) -O -c setell.f

# Use these next lines if you have FORTRAN libs from f2c that *work*
setell.o:
	rm -f setell.c
	ln -s setell.f2c.c setell.c
	$(CC) $(CFLAGS) -c setell.c

# Use these next lines if you have no FORTRAN capability at all
#setell.o:
#	rm -f setell.c
#	ln -s setell.fake.c setell.c
#	$(CC) $(CFLAGS) -c setell.c

install:
	cp mixview $(DESTDIR)

clean:
	cd $(LXTSRCLIB); rm -f *.o
	rm -f *.o mixview tags

lint: 
	lint -uvx $(SOURCES) $(DEFINES) $(LXTLINTLIB)

longlint: 
	lint -nuvxz $(SOURCES) $(DEFINES) $(LINTLIBS) $(LXTLINTLIB)

superlint: 
	lint -huvx $(SOURCES) $(DEFINES) 

mongolint: 
	lint -nuvxz $(SOURCES) $(LXSOURCES) $(DEFINES) $(LINTLIBS) $(LXTLINTLIB)

patch:
	-/bin/diff -c orig . > patch.tmp
	-sed '/^Only/d' patch.tmp | sed '/^Binary/d' > patch.$(PATCH)
	rm patch.tmp
	
tags: $(SOURCES) *.h
	ctags $(SOURCES) *.h

tar:
	tar cvf mixview.tar Makefile* mixview.doc B* RE* CH* *.c *.h *.f *.bitmap
	
dist: tar
	cat mixview.tar | compress >mixview-v$(VERSION).tar.Z
	uuencode mixview-v$(VERSION).tar.Z mixview-v$(VERSION).tar.Z >mixview.tar.Z.uue
	split -1500 mixview.tar.Z.uue uumail_
	rm mixview.tar.Z.uue mixview.tar

# all dependencies
analysis.o : analysis.c main.h sfheader.h decl.h dialog.h panels.h mesg.h \
  screen.h graphpoints.h scale.h databuff.h datawin.h lp.h fft.h 
cmd.o : cmd.c main.h sfheader.h decl.h dialog.h panels.h mesg.h cmd.h \
  menus.h nobug.h 
curves.o : curves.c main.h sfheader.h decl.h windows.h dialog.h panels.h \
  menus.h nobug.h 
databuff.o : databuff.c main.h sfheader.h decl.h dialog.h panels.h mesg.h \
  databuff.h screen.h graphpoints.h scale.h lp.h fft.h nobug.h 
datawin.o : datawin.c main.h sfheader.h decl.h dialog.h panels.h screen.h \
  graphpoints.h scale.h databuff.h datawin.h nobug.h 
default.o : default.c main.h sfheader.h decl.h windows.h 
dialog.o : dialog.c main.h sfheader.h decl.h dialog.h panels.h windows.h \
  soundfile.h nobug.h alert.bitmap query.bitmap 
display.o : display.c main.h sfheader.h decl.h debug.h 
events.o : events.c main.h sfheader.h decl.h cmd.h 
fft.o : fft.c main.h sfheader.h decl.h mesg.h fft.h 
filts.o : filts.c main.h sfheader.h decl.h dialog.h panels.h nobug.h 
graphpoints.o : graphpoints.c main.h sfheader.h decl.h graphpoints.h 
gravy.o : gravy.c main.h sfheader.h decl.h dialog.h panels.h nobug.h 
io.o : io.c main.h sfheader.h decl.h debug.h dialog.h panels.h mesg.h 
keybd.o : keybd.c main.h sfheader.h decl.h cmd.h 
lpctools.o : lpctools.c main.h sfheader.h decl.h dialog.h panels.h mesg.h \
  lpsf.h lp.h 
main.o : main.c main.h sfheader.h decl.h dialog.h panels.h windows.h \
  debug.h 
mell.o : mell.c main.h sfheader.h decl.h dialog.h panels.h nobug.h 
menus.o : menus.c main.h sfheader.h decl.h dialog.h panels.h mesg.h menus.h \
  cmd.h patchlevel.h lp.h fft.h nobug.h 
mesg.o : mesg.c main.h sfheader.h decl.h dialog.h panels.h mesg.h nobug.h 
mixfuns.o : mixfuns.c main.h sfheader.h decl.h nobug.h 
panels.o : panels.c main.h sfheader.h decl.h windows.h panels.h nobug.h 
phrase.o : phrase.c main.h sfheader.h decl.h dialog.h panels.h nobug.h 
play.o : play.c play.h main.h sfheader.h decl.h dialog.h panels.h mesg.h debug.h
ptrackfuns.o : ptrackfuns.c main.h sfheader.h decl.h lpsf.h 
range.o : range.c main.h sfheader.h decl.h range.h 
scale.o : scale.c main.h sfheader.h decl.h dialog.h panels.h screen.h \
  graphpoints.h scale.h nobug.h 
screen.o : screen.c main.h sfheader.h decl.h dialog.h panels.h screen.h \
  graphpoints.h scale.h databuff.h datawin.h nobug.h 
setell.o : setell.c 
setell.f2c.o : setell.f2c.c /usr/include/f2c.h 
setell.fake.o : setell.fake.c 
sfcodes.o : sfcodes.c main.h sfheader.h decl.h soundfile.h 
soundfile.o : soundfile.c main.h sfheader.h decl.h dialog.h panels.h \
  soundfile.h debug.h 
text.o : text.c main.h sfheader.h decl.h text.h dialog.h panels.h nobug.h 
trans.o : trans.c main.h sfheader.h decl.h dialog.h panels.h nobug.h 
windows.o : windows.c main.h sfheader.h decl.h windows.h 
