# ############################################################
# Makefile for MIDI2TEX
#
# Written by John Fitch (the makefile that is)
#            Unoiversity of Bath / Codemist Ltd
#
# ############################################################

## For Norcroft ANSI C Compiler###############################
# Optimisation is always on, and the libraries are true ANSI
CC = ncc
CFLAGS = -D__unix
LIBS =

## For SGI CC compiler #######################################
# CC = cc
# CFLAGS = -O2 -D__unix
# LIBS = -lm


## For GCC almost ANSI C######################################
# I have not yet completed the patch-ups for the non-ANSIness of gcc
# CC = gcc
# CFLAGS = -D__unix -Dfpos_t=long -DSEEK_SET=0
# LIBS = -lm
#

SHELL = /bin/sh

HDRS =	tp_debug.h  tp_heap1.h  tp_m2tf4.h  tp_misc.h   tp_decl.h   \
	tp_m2t16.h  tp_midi.h

SRC = 	tp_debug.c  tp_heap1.c  tp_m2tf4.c  tp_misc.c	tp_decl.c   \
	tp_m2t16.c  tp_midi.c

OBJS =	tp_debug.o  tp_heap1.o  tp_m2tf4.o  tp_misc.o	tp_decl.o   \
	tp_m2t16.o  tp_midi.o

midi2tex: ${OBJS}
	${CC} -o midi2tex ${OBJS} ${LIBS}

midi2tex.tar: ${HDRS} ${SRC} README example.mid manualc.tex manualc.bbl \
		manualc.ind refman.sty midi2tex.pic makefile
	tar cvf midi2tex.tar README makefile ${HDRS} ${SRC} example.mid \
		manualc.tex manualc.bbl manualc.ind refman.sty midi2tex.pic

.c.o:
	${CC} ${CFLAGS} -c $*.c

depend:
	  -rm makedep
	  for i in ${SRC}; do \
	      ${CC} -M ${CFLAGS} $$i | \
	      awk ' { if ($$1 != prev) \
		  { if (rec != "") print rec; rec = $$0; prev = $$1; } \
		  else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
		  else rec = rec " " $$2 } } \
		  END { print rec } ' >> makedep; done
	  cp Makefile makefile
	  echo '# DO NOT DELETE THIS LINE' >>makefile
	  cat makedep >> makefile
	  echo '# DEPENDENCIES MUST END AT END OF FILE' >> makefile
	  echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> makefile
	  echo '# see make depend above' >> makefile


# DO NOT DELETE THIS LINE
tp_debug.o:	tp_debug.c tp_debug.h tp_decl.h
tp_debug.o:	tp_misc.h
tp_heap1.o:	tp_heap1.c tp_heap1.h tp_decl.h tp_misc.h tp_debug.h
tp_m2tf4.o:	tp_m2tf4.c tp_m2tf4.h tp_decl.h tp_misc.h tp_debug.h
tp_misc.o:	tp_misc.c tp_misc.h tp_decl.h
tp_decl.o:	tp_decl.c tp_decl.h
tp_m2t16.o:	tp_m2t16.c tp_decl.h tp_misc.h tp_debug.h tp_m2tf4.h \
		tp_heap1.h tp_midi.h tp_m2t16.h
tp_midi.o:	tp_midi.c tp_midi.h tp_decl.h tp_misc.h tp_debug.h \
		tp_heap1.h tp_m2tf4.h

# DEPENDENCIES MUST END AT END OF FILE
# IF YOU PUT STUFF HERE IT WILL GO AWAY
# see make depend above
