#**************************************************************************
#* FILE NAME: makefile                        COPYRIGHT (c) MOTOROLA 2000 *
#* VERSION: 1.1                                                           *
#*                                                                        *
#* DESCRIPTION: This is the makefile for the MPC565 header example files. *
#*    This makefile build the three examplr files (example1.elf,          *
#*    example2.elf and example3.elf). The example files show the three    *
#*    different ways to use the header files.                             *
#*========================================================================*
#* MAKE: GNU make        VERSION: 3.75                                    *
#* AUTHOR: Jeff Loeliger                                                  *
#*                                                                        *
#* HISTORY                                                                *
#* REV      AUTHOR      DATE       DESCRIPTION OF CHANGE                  *
#* ---   -----------  ---------    ---------------------                  *
#* 1.0   J. Loeliger  19/Jan/99    Initial version of file.               *
#* 1.1   J. Loeliger  03/Oct/00    Fixed several typos.                   *
#**************************************************************************

CC = dcc
AS = das
LD = dld 
CFLAGS = -tPPC555EH -g3 -c
ASFLAGS = -tPPC555EH 
LDFLAGS = -tPPC555EH mpc565.dld -m2
LIBS = -li -lchar

OBJS = crt0m500.o 

all: build1 example1.elf build2 example2.elf build3 example3.elf

example1.elf : example1.o mpc565.o $(OBJS) makefile mpc565.dld
	$(LD) $(LDFLAGS) $(OBJS) mpc565.o example1.o $(LIBS) -o ${@F} > memory1.map

example1.o : example1.c mpc565.h makefile
	$(CC) $(CFLAGS) $< -o $@

example2.elf : example2.o mpc565s.o $(OBJS) makefile mpc565.dld 
	$(LD) $(LDFLAGS) $(OBJS) mpc565s.o example2.o $(LIBS) -o ${@F} > memory2.map

example2.o : example2.c mpc565.h makefile
	$(CC) $(CFLAGS) -DDIAB_SECTIONS $< -o $@

example3.elf : example3.o mpc565.o $(OBJS) makefile mpc565.dld 
	$(LD) $(LDFLAGS) $(OBJS) mpc565.o example3.o $(LIBS) -o ${@F} > memory3.map

example3.o : example3.c mpc565.h makefile
	$(CC) $(CFLAGS) -DHEADER_POINTERS $< -o $@

mpc565.o : mpc565.c makefile
	$(CC) $(CFLAGS) $< -o $@

mpc565s.o : mpc565.c makefile
	$(CC) $(CFLAGS) -DDIAB_SECTIONS $< -o mpc565s.o

crt0m500.o : crt0m500.s makefile
	$(AS) $(ASFLAGS) $< 

ex_funcs.o : ex_funcs.c m_common.h makefile
	$(CC) $(CFLAGS) -Xnested-interrupts $< -o $@

build1:
	rem ***
	rem *** Build Example number 1
	rem ***

build2:
	rem ***
	rem *** Build Example number 2
	rem ***

build3:
	rem ***
	rem *** Build Example number 3
	rem ***

mpc565.h : m_common.h m_dptram.h m_uc3f.h m_mios14.h m_qadc.h m_qsmcm.h \
           m_calram.h m_toucan.h m_tpu3.h m_uimb.h m_usiu.h m_dlcmd2.h makefile

# Dummy targets needed by some versions of make
makefile :
m_qadc.h :
m_uc3f.h :

clean:
	rm -f *.o *.elf *.map
	rm -f *.ou1 *.db *.db2 *.blk
	rm -f *.?~ a.out



