# Makefile for cmt on Mach/Unix
# Copyright 1989 Carnegie Mellon University
# Last modified date: 

CMTDIR = ../../lib
CMTLIB = $(CMTDIR)/libcmt.a

# Definition of Compiler, Linker, and Flags
CC     = cc
CFLAGS = -c -g 
LN     = ln
LFLAGS = -lm

# EVERYTHING is everything this makefile knows how to make (except umakefile)
EVERYTHING = libcmt.a moxc.o moxcmain.o

# CURRENT is the file we want to make now.
CURRENT = $(EVERYTHING) umakefile

MUOBJ1 = midifns.o userio.o cmdline.o cext.o timebase.o io.o mem.o
MUOBJ2 = seq.o excldesc.o record.o seqmread.o seqmwrite.o cleanup.o
MUOBJ3 = seqread.o seqextns.o cmtcmd.o seqwrite.o tempomap.o midifile.o 
MUOBJ  = $(MUOBJ1) $(MUOBJ2) $(MUOBJ3)

#-------------------------------------------------------------------------

current : $(CURRENT)
	echo "made $(CURRENT)"

everything : $(EVERYTHING)
	echo "made $(EVERYTHING)"

#copy latest changes to umakefile
umakefile : makefile
	cp makefile umakefile

uswitches.h : switches.h
	cp switches.h uswitches.h

cext.o : cext.c
	$(CC) $(CFLAGS) cext.c

cmdline.o : cmdline.c
	$(CC) $(CFLAGS) cmdline.c

excldesc.o : excldesc.c midicode.h
	$(CC) $(CFLAGS) -o excldesc.o excldesc.c 

moxc.o : midifns.h cmdline.h midicode.h moxc.c
	$(CC) $(CFLAGS) moxc.c

moxcmain.o : moxcmain.c
	$(CC) $(CFLAGS) -o moxcmain.o moxcmain.c

moxctest.o : moxctest.c
	$(CC) $(CFLAGS) moxctest.c

moxctest : moxctest.o libcmt.a moxc.o moxcmain.o
	$(LN) -W moxctest moxc.o moxcmain.o $(LFLAGS)

libcmt.a : $(MUOBJ)
	rm -f libcmt.a
	ar rv libcmt.a $(MUOBJ)
	ranlib libcmt.a

midifns.o : midifns.h midicode.h cmdline.h userio.h pitch.h midifns.c \
	switches.h
	$(CC) $(CFLAGS) midifns.c 

seqread.o : cmdline.h seqread.c seq.h
	$(CC) $(CFLAGS) seqread.c

seq.o : midifns.h userio.h seq.c seq.h
	$(CC) $(CFLAGS) seq.c

seq2.o : midifns.h userio.h seq2.c seq.h
	$(CC) $(CFLAGS) seq2.c

seqmwrite.o : midifns.h userio.h seqmwrite.c seq.h
	$(CC) $(CFLAGS) seqmwrite.c

record.o : midifns.h userio.h midicode.h record.c
	$(CC) $(CFLAGS) record.c

tuning : tuning.o $(CMTLIB)
	$(LN) tuning.o $(LFLAGS) 

userio.o : userio.h userio.c switches.h
	$(CC) $(CFLAGS) userio.c

# clean objects for library
clean :
	rm -f $(MUOBJ1)
	rm -f $(MUOBJ2)
	rm -f $(MUOBJ3)
	rm -f *.BAK *.CKP

recompile : clean
	rm -f $(EVERYTHING)


