
# @(#)makefile	4.4	20/5/92
# @(#)Copyright (C) 1991 National Semiconductor Corp.

.MEMSWAP

NBURN = nburn
AS = nasm 
CC = nmcc 
LD = nmeld
RM = del
RAM = -DRAM
GNXDIR=

DIAG_BOARD_DEF=cg160lx.h

DIAG_DEVICE_SRC= icu_diag.c  sio_diag.c ram_diag.c epr_diag.c led_diag.c \
       cpu_diag.c fpu_diag.c  lcd_diag.c eep_diag.c cnt_diag.c
DIAG_DEVICE_OBJ1= icu_diag.o  sio_diag.o ram_diag.o epr_diag.o led_diag.o
DIAG_DEVICE_OBJ2= cpu_diag.o fpu_diag.o  lcd_diag.o eep_diag.o cnt_diag.o
DIAG_DEVICE_OBJ= $(DIAG_DEVICE_OBJ1) $(DIAG_DEVICE_OBJ2)

CDIAG= diag.c $(DIAG_DEVICE_SRC) 
ADIAG=diag_ext.s
ODIAG1= diag.o diag_ext.o $(DIAG_DEVICE_OBJ1)
ODIAG2= $(DIAG_DEVICE_OBJ2)
ODIAG= $(ODIAG1) $(ODIAG2)

DIAG_INC_FILES   = global.h cc_def.h $(DIAG_BOARD_DEF) diag.h

DIAG_CFLAGS  = -I.\ "-DBOARD_FILE=<${DIAG_BOARD_DEF}>" -DDIAG
DIAG_ASFLAGS = -I.\ "-DBOARD_FILE=<${DIAG_BOARD_DEF}>" -DDIAG -DASEM -n

CPRG= date.o $(ODIAG)
CFLAGS = -KCCG160 -KF181 -KB2 -J1 -c -R -KW
ASFLAGS = -KCCG160 -KF181 -KB2 -KW -c


all	: cg160lx.hx0 cg160lx.hx1

ram		: cg160lx.ram

cg160lx.hx0 : cg160lx
	$(NBURN) -w2 -b0  -n -x0x00400000 -l64 -i -o cg160lx.hx0  cg160lx

cg160lx.hx1: cg160lx
	$(NBURN) -w2 -b1 -n  -x0x00400000 -l64 -i -o cg160lx.hx1  cg160lx


.s.o: $(HEADERS)
	$(AS)  $(ASFLAGS) $*.s 

.c.o: $(HEADERS)
	$(CC) $(CFLAGS) $(DIAG_CFLAGS) -O  $*.c

diag_ext.o:
	$(AS) $(ASFLAGS) $(DIAG_ASFLAGS) diag_ext.s

cg160lx.o:  cgcore.s def.s
	$(AS) $(ASFLAGS) -DBOARD=SWIFT -c  -o cg160lx.o cgcore.s

cg160lx :  cg160lx.o $(APRG) $(CPRG)
	echo cg160lx.o $(APRG) $(ETHER_CPRG) date.o > link.op
	echo $(ODIAG1) >> link.op
	echo $(ODIAG2) >> link.op
	$(LD) -o cg160lx -d linkfile.rom @link.op -lc -m > cg160lx.map

cg160lx.ram:  cgcore.s def.s $(APRG) $(CPRG)
	$(AS) $(ASFLAGS) $(RAM) -g -o cg160lx.o cgcore.s
	echo cg160lx.o $(APRG) $(ETHER_CPRG) date.o > link.op
	echo $(ODIAG1) >> link.op
	cho $(ODIAG2) >> link.op
	$(LD) -o cg160lx.ram -e reset -m -d linkfile.ram @link.op -lc > cg160lx.map

date.o: date.c
	$(CC)  $(CFLAGS) -Wa,-r -Wa,-n  date.c  
	

diag_ext.o	    : diag_ext.s $(DIAG_INC_FILES)
diag.o		    : diag.c  $(DIAG_INC_FILES)
icu_diag.o	    : icu_diag.c $(DIAG_INC_FILES)
sio_diag.o	    : sio_diag.c z8530.h $(DIAG_INC_FILES)
ram_diag.o	    : ram_diag.c $(DIAG_INC_FILES)
epr_diag.o	    : epr_diag.c $(DIAG_INC_FILES)
eep_diag.o	    : eep_diag.c $(DIAG_INC_FILES)
cnt_diag.o	    : cnt_diag.c $(DIAG_INC_FILES)
lan_diag.o	    : lan_diag.c $(DIAG_INC_FILES)
led_diag.o	    : led_diag.c $(DIAG_INC_FILES)
cpu_diag.o	    : cpu_diag.c $(DIAG_INC_FILES)
fpu_diag.o	    : fpu_diag.c $(DIAG_INC_FILES)
lcd_diag.o	    : lcd_diag.c $(DIAG_INC_FILES)
other_diag.o	    : other_diag.c $(DIAG_INC_FILES)

clean : 
	$(RM) *.o

clobber : clean
	$(RM) cg160lx.map
	$(RM) cg160lx
	$(RM) cg160lx.hex
	$(RM) cg160lx.hx0
	$(RM) cg160lx.hx1

.SCCS_GET:
