###########################################################################
# Makefile:	Makefile for Manx Aztec C, version 5.0.
#		Part of MP, the MIDI Playground.
#
# Author:	Daniel Barrett
# Version:	See the file "version.h".
# Copyright:	None!  This program is in the Public Domain.
#		Please share it with others.
###########################################################################

	
OPTIMIZE	= -so
DEBUGGING	= #-bs
LDEBUGGING	= #-g
	
LFLAGS		= $(LDEBUGGING) +Q
CFLAGS          = $(OPTIMIZE) -hi $(COMP_INC) $(DEBUGGING)
LIBS		= -lc
COMP_INC	= headers.comp
LIBS		= -lc

BACKUPDIR	= df1:sysex
	
##############################################################################
# Files used for all programs.
##############################################################################

PROG		= mp
MAINHEADER	= mp.h
HEADERS		= $(MAINHEADER) version.h midi.h
SRC		= text.c main.c serial.c getopt.c iofunctions.c help.c \
		  files.c wb.c cli.c amigados.c
OBJ		= text.o main.o serial.o getopt.o iofunctions.o help.o \
		  files.o wb.o cli.o amigados.o

##############################################################################
# The program.
##############################################################################

$(PROG):	$(COMP_INC) $(OBJ)
		@echo ""
		@echo "Ignore messages about _abort overriding library."
		@echo ""
		ln $(LFLAGS) $(OBJ) -o $(PROG) $(LIBS)

$(OBJ):		$(MAINHEADER)

##############################################################################
# Individual dependencies.
##############################################################################

help.o:		help.c        $(MAINHEADER) version.h
iofunctions.o:	iofunctions.c $(MAINHEADER) midi.h
serial.o:	serial.c      $(MAINHEADER) midi.h
	
##############################################################################
# Compiled headers.
##############################################################################

$(COMP_INC):	$(MAINHEADER)
		@echo "Compiling headers because of $?"
		cc $(OPTIMIZE) $(DEBUGGING) -ho $(COMP_INC) $(MAINHEADER)

#$(MAINHEADER):	$(HEADERS)

##############################################################################
# Clean up
##############################################################################

clean:
		delete \#?.o \#?.pro

veryclean:	clean
		delete $(COMP_INC) $(PROG) \#?.dbg

cbackup:
		copy \#?.c $(BACKUPDIR)
		copy \#?.h $(BACKUPDIR)
		copy Makefile $(BACKUPDIR)

backup:		cbackup
		copy README $(BACKUPDIR)
		copy \#?.DOC $(BACKUPDIR)
		copy Scripts $(BACKUPDIR)/Scripts   all
		copy Examples $(BACKUPDIR)/Examples all

zoo:		$(PROG)
		delete ram:mp.zoo quiet
		zoo a ram:mp.zoo Source/* Scripts/* Examples/* \
				 $(PROG) *.DOC README Makefile
