# $Header: /4-CH Echo Cancel Bd (P-OEM)/Software/Component/hc11/source/make/makefile 1     5/15/01 1:45p Jwalther $
#*****************************************************************#
# PECHO.MAK - Makefile for PECHO project HC68HC11A1 uProcessor    #
#*****************************************************************#
#                                                                 #
#         Author: Dennis J. Crocker, L.L.C.                       #
#                 04-Dec-1996                                     #
#                                                                 #
#       Copyright: 1996                                           #
#						   										  #
#       Gentner Electronics Corporation                           #
#       1825 Research Way                                         #
#       Salt Lake City, Utah  84119                               #
#                                                                 #
#*****************************************************************#
# $History: makefile $
# 
# *****************  Version 1  *****************
# User: Jwalther     Date: 5/15/01    Time: 1:45p
# Created in $/4-CH Echo Cancel Bd (P-OEM)/Software/Component/hc11/source/make
# Initial check in for the PECHO project
# 
# *****************  Version 4  *****************
# User: Rscott       Date: 7/18/00    Time: 2:07p
# Updated in $/AP800/Software/hc11/Ver1/make
# Made changes to generate both the E1 and the A1 system files
# 
# *****************  Version 3  *****************
# User: Rscott       Date: 1/07/99    Time: 10:20a
# Updated in $/AP800/Software/hc11/Ver1/make
# Fixed makefile to create directories needed to make project from
# archive.
#
# MKS Revision History:                                             
#
# Log: /ap800/software/hc11/Ver1/Make/makefile
# 
# 2     1/06/99 2:24p Jwalther
# 
# 1     4/14/98 1:16p Jwalther
# Revision 1.8  1998/03/12 16:11:24  JayWalther
# Revision 1.7  1998/03/10 21:31:39  JayWalther
# This is the real thing-  sent out to beta
# Revision 1.6  1997/12/16 19:07:50  JayWalther
# Revision 1.5  1997/11/18 18:51:45  JayWalther
# Revision 1.4  1997/10/23 14:09:26  JayWalther
# Revision 1.3  1997/09/30 17:01:09  JayWalther
# Revision 1.2  1997/09/13 17:08:09  JayWalther
# Revision 1.1  1997/06/24 22:28:58  JayWalther
# Initial revision
#***************************************************************#

# Command to run the mks make utility.
#	MAKE = MKS macro: value "make"

MAKEFLAGS = --win32

# S-record address offsets:
# bank 0 - interrupt vectors
	V0_OFFSET = 0x0ffd6
# bank 1 - interrupt vectors
	V1_OFFSET = 0x1ffd6
# bank 0 - boot code
	B0_OFFSET = 0x02000
# bank 1 - applications code
	A1_OFFSET = 0x12000
	R1_OFFSET = 0x0e822
# EEPROM
	E0_OFFSET = 0x0B600

# =====================================================================
# Directory definitions
# =====================================================================
#
#\projects\pecho\Software\hc11\source # for DOS
DHOME = .
TOOLS = f:\tools

# 68HC11 library ".e" and ".h" files.
SYSINCDIR = ..\68hc11.lib
# 68HC11 library ".s" and ".c" files.
SYSLIBDIR = ..\68hc11.lib
# 68HC11 library macro files.
SYSMACDIR = ..\68hc11.lib
# 68HC11 library "make" file.
SYSMAKDIR = ..\68hc11.lib

# location of include ".e" files.
EQUDIR = .

# location of include ".h" files
INCDIR = .

# loc. of list files created.
LSTDIR = .\lst

# loc. of object files created.
OBJDIR = .\obj

# location of source (current directory)
SRCDIR = .

# location of WhiteSmith C compiler, etc. 
WSCDIR = $(TOOLS)\cc4.1\cx11

# location of WhiteSmith C library. 
WSCLIBDIR = $(WSCDIR)\lib

# location of WhiteSmith C headers. 
WSCHDRDIR = $(WSCDIR)\h6811

# =====================================================================
# Define filenames and extensions.
# =====================================================================
ECHO = $(COMSPEC) /c  ECHO
MD = $(COMSPEC) /c MD
CP = $(COMSPEC) /c COPY
RM = $(COMSPEC) /c DEL

#VPATH = ..\source obj lst
#vpath %.s ..\source
#vpath %.c ..\source
vpath %.e ..\source	$(SYSINCDIR)
vpath %.mac $(SYSMACDIR)
vpath %.h ..\source $(WSCHDRDIR) $(SYSINCDIR)
vpath %.o obj ..\68hc11.lib\obj
vpath %.ls lst

# =====================================================================
# Define the assembler and assembler flags. 
# =====================================================================

# HC11 assembler (backslashes for DOS).
AS      = ca6811
## debug ASFLAGS = -l -e
ASFLAGS = -i $(SYSINCDIR) -x +l $*.ls

#PS      = $(WSCDIR)\cp1h11			# C parser (backslashes for DOS).
PSFLAGS = -u +xdebug -b0 
##PSFLAGS = -m -u +strict -b0 -err

# C compiler (backslashes for DOS).
CC      = cx6811
##CCFLAGS = -v -dl2 +list  -err
CCFLAGS = -co $(OBJDIR) -cl $(LSTDIR) -v -l	+debug -i$(SYSINCDIR)

#OZ      = $(WSCDIR)\opth11			# C optimizer (backslashes for DOS).
OZFLAGS = -c -v

# linker (backslashes for DOS).
LK      = clnk

# hex output (backslashes for DOS).
HX = chex

# to 695 for debugger
TO695	= cv695

# =====================================================================
# Source files.
# =====================================================================

# Assembly source files.
ASRCS=\
		dsp.s			\
		io_dflts.s		\
		lcd.s			\
		stop.s			\
		sys_init.s		\
		syscrash.s		\
		eeprom.s		\
		arrycmp.s		\
		flashb.s

#		fpga.s			\
#		uart.s			\

# C source files.
CSRCS=\
		main.c          \
		button.c		\
		command.c		\
		err_msgs.c		\
		panic.c			\
		bitstrm.c		\
		serial.c		\
		switch.c		\
		unit.c			\
		control.c		\
		version.c		\
		presets.c		\
		flash.c			\
		DSP_Com.c

#		menu.c			\
#		monitor.c		\
#		burn.c			\
#		io_cmd.c		\
#		gpio.c			\
#		gpioinit.c			\
#		glink.c			\
#
# =====================================================================
# Object files.
# =====================================================================

.SOURCE.o :- $(OBJDIR)		# where to find object files.

# NoRMal object files which can be linked anywhere.
LOCALOBJS=\
		arrycmp.o		\
		button.o		\
		command.o		\
		control.o		\
		dsp.o 			\
		DSP_Com.o		\
		eeprom.o		\
		err_msgs.o      \
		flash.o			\
		flashb.o		\
 		lcd.o           \
		main.o			\
 		panic.o         \
		presets.o		\
		bitstrm.o		\
 		serial.o        \
		switch.o		\
		stop.o			\
		sys_init.o		\
		sys_main.o		\
		syscrash.o		\
		txt_parse.o		\
		unit.o			\
		version.o		

#		burn.o			\
#		menu.o			\
#		monitor.o		\
# 		fpga.o          \
#		io_cmd.o		\
#		gpio.o			\
#		gpioinit.o		\
#		glink.o			\
# 		uart.o          \


NRMOBJS = $(LOCALOBJS)

# Object files from the "68hc11 library".
LIBOBJS = \
		$(SYSLIBDIR)/adc.o		\
		$(SYSLIBDIR)/clock.o	\
		$(SYSLIBDIR)/ints.o		\
		$(SYSLIBDIR)/pai.o		\
		$(SYSLIBDIR)/porta.o	\
		$(SYSLIBDIR)/portc.o	\
		$(SYSLIBDIR)/portd.o	\
		$(SYSLIBDIR)/q_drvr.o	\
		$(SYSLIBDIR)/rti.o		\
		$(SYSLIBDIR)/sci.o		\
		$(SYSLIBDIR)/spi.o		\
		$(SYSLIBDIR)/sys_cloc.o	\
		$(SYSLIBDIR)/sys_flgs.o	\
		$(SYSLIBDIR)/sys_subs.o	\
		$(SYSLIBDIR)/sys_test.o	\
		$(SYSLIBDIR)/tic1.o		\
		$(SYSLIBDIR)/tic2.o		\
		$(SYSLIBDIR)/tic3.o		\
		$(SYSLIBDIR)/toc1.o		\
		$(SYSLIBDIR)/toc2.o		\
		$(SYSLIBDIR)/toc3.o		\
		$(SYSLIBDIR)/toc4.o		\
		$(SYSLIBDIR)/toc5.o

### Not using these library object files:
##		$(SYSLIBDIR)/fdiv.o		\
##		$(SYSLIBDIR)/hex_lib.o	\
##		$(SYSLIBDIR)/bcd_lib.o	\



# Objects requiring special linking: current directory.
SPOBJS=\
		io_dflts.o

# Objects requiring special linking: library directory (not built here).
SPLIBOBJS=\
		$(SYSLIBDIR)/crts.o		\
		$(SYSLIBDIR)/io_equ.o	\
		$(SYSLIBDIR)/reset.o	\
		$(SYSLIBDIR)/vectors.o

# All object files to be built by this makefile.
OBJS = $(LOCALOBJS) $(SPOBJS)


# =====================================================================
# Rules for compilation and assembly.
# NOTE: when compiling, 'filename'.s is temporarily created, so do not
#       use this name for any assembly programs.
# =====================================================================
%.o : %.c
	@$(ECHO) ---------------------------------------------- COMPILE $*
	@$(CC) $(CCFLAGS) $*.c

%.o : %.s
	@$(ECHO) ---------------------------------------------- ASM $*
	@$(AS) -o $(OBJDIR)\$*.o $(ASFLAGS) $*.s
	@$(CP) *.ls $(LSTDIR)
	@$(RM) *.ls

# *********************************************************************
# Start building ...
# *********************************************************************

# =====================================================================
# make doit dependent on this to create ROM file: pecho.h11
# =====================================================================
doit: setup pecho_e.s
#	$(ECHO) Check for errors in error file in make directory.
	@$(ECHO) Make PECHO done.

setup:
	@$(ECHO) Verifying directories...
	@$(MD) $(DHOME)\obj
	@$(MD) $(DHOME)\lst

# =====================================================================
# This target runs the linker.  These command lines should be modified
# to reflect the target machine's memory architecture.
# =====================================================================
pecho_e.s : pecho_e.h11
	@$(ECHO) ---------------------------------------------- CREATE S-RECORDS
	@$(ECHO) Build HC11E1 S-records
#	$(HX) -s -o $*.eml $*.h11
	@$(HX) -s -o $*.s $*.h11
	$(TO695) $*.h11

# Create object file
pecho_e.h11 : syslib OBJECTS linkere.cmd
	@$(ECHO) ---------------------------------------------- LINKING
	@$(ECHO) Linking 68HC11E1 software
	$(LK) -o pecho_e.h11 -m pecho_e.map linkere.cmd

# =====================================================================
# Make sure that the 68HC11 system library is up-to-date.
# =====================================================================

syslib:
	@$(ECHO) ---------------------------------------------- Make System Library
	@$ make  $(SYSMAKDIR)


# =====================================================================
# Make all object files, but do not link them.
# =====================================================================

OBJECTS : PRE_CLEANUP $(OBJS)
	@$(ECHO) ----------------------------------------------------
	@$(ECHO) All 68hc11 object-files now up-to-date.
	@$(ECHO) ----------------------------------------------------

# =====================================================================
# Create new empty error logging files.
# =====================================================================

PRE_CLEANUP :
	@$(ECHO) ********************************************************************
	@$(ECHO) ********************************************************** Make PECHO
	@$(ECHO) ********************************************************************
	@$(ECHO) Building 68HC11 software
	@$(RM) pecho_e.*



# =====================================================================
# Target application dependencies
# =====================================================================
main.o : main.c	$(SYSINCDIR)\clock.h version.h

version.o : version.c version.h

arrycmp.o : arrycmp.s

flashb.o : flashb.s

button.o : button.c 	\
		sys.h			\
		button.h 		\
		$(SYSINCDIR)\boolean.h 	\
		$(SYSINCDIR)\sys_cloc.h \
		$(SYSINCDIR)\sys_subs.h

command.o : command.c \
		sys.h	\
		command.h 	\
		main.h 		\
		serial.h 	\
		$(SYSINCDIR)\boolean.h \
		$(SYSINCDIR)\ints.h

dsp.o : dsp.s 	\
		dsp.e 	\
		dv_flgs.e 	\
		syscrash.e 	\
		$(SYSINCDIR)\68hc11.mac 	\
		$(SYSINCDIR)\global.e 		\
		$(SYSINCDIR)\io_equ.e

err_msgs.o : err_msgs.c		\
		sys.h					\
		err_msgs.h			\
		lcd.h

io_dflts.o : io_dflts.s		\
		config.e				\
		run_flgs.e			\
		$(SYSINCDIR)\global.e			\
		$(SYSINCDIR)\io_dflts.e			\
		$(SYSINCDIR)\io_equ.e			\
		$(SYSINCDIR)\timebase.e

lcd.o : lcd.s					\
		lcd.e					\
		dv_flgs.e				\
		syscrash.e			\
		$(SYSINCDIR)\68hc11.mac			\
		$(SYSINCDIR)\global.e			\
		$(SYSINCDIR)\io_equ.e			\
		$(SYSINCDIR)\qcb.e

#.o : monitor.c			\
#		monitor.h				\
#		command.h				\
#		serial.h				\
#		sys.h					\
#		$(SYSINCDIR)\boolean.h

panic.o : panic.c				\
		panic.h				\
		led.h					\
		sys.h					\
		$(SYSINCDIR)\sys_subs.h

serial.o : serial.c			\
		serial.h				\
		command.h				\
		sys.h					\
		$(SYSINCDIR)\boolean.h			\
		$(SYSINCDIR)\ints.h				\
		$(SYSINCDIR)\sci.h				\
		$(SYSINCDIR)\vectors.h

stop.o : stop.s				\
		$(SYSINCDIR)\68hc11.mac			\
		$(SYSINCDIR)\global.e			\
		$(SYSINCDIR)\mc68hc11.e			\
		$(SYSINCDIR)\sys_flgs.e

sys_init.o : sys_init.s		\
		dsp.e					\
		lcd.e					\
		$(SYSINCDIR)\68hc11.mac			\
		$(SYSINCDIR)\cmp_flgs.e			\
		$(SYSINCDIR)\global.e			\
		$(SYSINCDIR)\io_equ.e			\
		$(SYSINCDIR)\sys_cloc.e

sys_main.o : sys_main.s		\
		$(SYSINCDIR)\68hc11.mac			\
		$(SYSINCDIR)\cmp_flgs.e			\
		$(SYSINCDIR)\global.e			\
		main.c				\
		$(SYSINCDIR)\io_equ.e

syscrash.o : syscrash.s		\
		syscrash.e			\
		run_flgs.e			\
		$(SYSINCDIR)\68hc11.mac			\
		$(SYSINCDIR)\cmp_flgs.e			\
		$(SYSINCDIR)\global.e			\
		$(SYSINCDIR)\io_equ.e			\
		$(SYSINCDIR)\mc68hc11.e			\
		$(SYSINCDIR)\sys_flgs.e

eeprom.o : eeprom.s	  		\
		$(SYSINCDIR)\68hc11.mac			\
		$(SYSINCDIR)\global.e			\
		$(SYSINCDIR)\vectors.e

presets.o : presets.c eeprom.h

version.o : version.c         \
		version.h

unit.o : unit.c         \
		unit.h		  \
		command.h

switch.o : switch.c     \
		switch.h		  \
		command.h

flash.o	: flash.c		 \
		flash.h

#burn.o	: burn.c		 \
#		flash.h

#menu.o: menu.c	 \
#		menu.h	 \
#		eeprom.h	 \
#		button.h

control.o : control.c   \
		control.h		  \
		command.h

#io_cmd.o : io_cmd.c     \
#		io_cmd.h		  \
#		eeprom.h	 \
#		command.h

#gpio.o : gpio.c		\
#		gpio.h

#gpioinit.o : gpioinit.c		\
#		gpioinit.h

#glink.o : glink.c		\
#		glink.h		\
#		syscrash.h

DSP_Com.o : DSP_Com.c		\
		DSP_Com.h

txt_parse.o : txt_parse.c txt_parse.h

bitstrm.o : bitstrm.c bitstrm.h

# =====================================================================
# END OF MAKEFILE PECHO.MAK
# =====================================================================
