#**************************************************************************
#* FILE NAME: $RCSfile: makefile,v $         COPYRIGHT (c) FREESCALE 2009 *
#* DESCRIPTION:                                     All Rights Reserved   *
#* This is the makefile for eTPU FUEL example programs.                   *
#*========================================================================*
#* MAKE: GNU make        VERSION: 3.80                                    *
#* ORIGINAL AUTHOR: Mihal Princ [prnm001]                                 *
#* $Log: makefile,v $
#* Revision 1.1  2009/01/15 12:44:32  prnm001
#* Initial revision
#*
#*........................................................................*
#*************************************************************************/
VPATH = ../etpu_set2 ../utils ../mpc5500 ../etpu_set2/cpu ../tooth_gen ../eng_pos

CC = dcc
AS = das
LD = dld
DEL = c:/cygwin/bin/rm -f

CFLAGS = -tPPC5554EF -c -g -Xnested-interrupts -Xdebug-dwarf2 -I "../etpu_set2" -I "../mpc5500" -I "../utils" -I "../etpu_set2/cpu" -I "../tooth_gen" -I "../eng_pos"
LDFLAGS = -m2 -tPPC5554EF MPC563M_intram.dld
ASFLAGS = -tPPC5554EF
LIBS = -li -lchar -lc -lg

INC = ../mpc5500/mpc563m.h ../mpc5500/typedefs.h ../utils/etpu_util.h makefile ../mpc5500/mpc5500_ccdcfg.h ../mpc5500/mpc5500_usrccdcfg.h
OBJS = ../utils/etpu_util.o etpu_fuel.o ../mpc5500/fs_gpio.o ../mpc5500/crt0.o ../tooth_gen/etpu_toothgen.o ../eng_pos/etpu_app_eng_pos.o fuel_etpu_gct_example.o ../mpc5500/IntcIsrVectors.o ../mpc5500/intc_sw_handlers.o

all: fuel_example.elf

fuel_example.elf : fuel_example.o $(OBJS) $(INC) MPC563M_intram.dld etpu_util.o
	cd ../utils && $(MAKE)
	cd ../tooth_gen && $(MAKE)
	cd ../eng_pos && $(MAKE)
	cd ../mpc5500 && $(MAKE) gpio
	$(LD) $(LDFLAGS) fuel_example.o $(OBJS) $(LIBS) -o ${@F} > fuel_example.map
#	ddump -R fuel_example.elf -o fuel_example.s19

fuel_example.o : fuel_example.c fuel_etpu_gct_example.c fuel_etpu_gct_example.h etpu_fuel.h ../etpu_set2/etpu_set2.h $(INC)
	$(CC) $(CFLAGS) $<

crt0.o : crt0.s makefile
	$(AS) $(ASFLAGS) -o $@ $<

etpu_util.o: ../utils/etpu_util.c ../mpc5500/typedefs.h
	$(CC) $(CFLAGS) -c  "$<" -o $@

etpu_fuel.o : etpu_fuel.c etpu_fuel.h etpu_fuel_auto.h $(INC) etpu_util.o
	cd ../utils && $(MAKE)
	$(CC) $(CFLAGS) $<

fuel_etpu_gct_example.o : fuel_etpu_gct_example.c fuel_etpu_gct_example.h $(INC)
	$(CC) $(CFLAGS) $<

../mpc5500/IntcIsrVectors.o : ../mpc5500/IntcIsrVectors.c $(INC)
	$(CC) $(CFLAGS) -c  "$<" -o $@

../mpc5500/intc_sw_handlers.o : ../mpc5500/intc_sw_handlers.s makefile ../mpc5500/mpc5500_defs.inc ../mpc5500/mpc5500_usrdefs.inc
	$(AS) $(ASFLAGS) -o $@ $<

clean:
	$(DEL) *.db *.ou1 *.blk *.db2 *.map *.hex *lst *.err *.elf __*.* *.o

clean_all:
	cd ../tooth_gen && $(MAKE) clean
	cd ../eng_pos && $(MAKE) clean
	cd ../utils && $(MAKE) clean
	cd ../mpc5500 && $(MAKE) clean
	$(DEL) *.db *.ou1 *.blk *.db2 *.map *.hex *lst *.err *.elf __*.* *.o




