#
# Makefile for utils for Atari Cross Compilers
# - adjust CROSSDIR below for your setup
# - define CC to be the path to your hosts C compiler (gcc preferred except on sparc
#	    on the sparc cc is the preferred host C compiler).
# - If you are going to run the cross linker on a machine that aligns structures
#   at longword boundaries (machines such as Sun-Sparc, Convex etc) add
#   -DWORD_ALIGNED to CFLAGS
# - If you are going to run the cross linker on a machine that has the opposite
#    byte sex to a m68k, ie a little endian host, the add -DBYTE_SWAP to CFLAGS.
#
#
CROSSDIR = /net/acae127/home/bammi/atari.hp-ux/cross-gcc
CROSSBIN = $(CROSSDIR)/bin
CROSSLIB = $(CROSSDIR)/lib
CROSSINC = $(CROSSDIR)/include

# Host GCC
CC=cc
# Host include dir
HOSTINC = /usr/include

CFLAGS = -O +Obb1000 -DUSE_C_ALLOCA -I. -I$(HOSTINC) -I$(CROSSINC) -DCROSSATARI=1 \
-DCROSSDIR=\"$(CROSSDIR)\" -DCROSSLIB=\"$(CROSSLIB)\" -DWORD_ALIGNED=1 -DCROSSHPUX

ALLOCA = /net/acae127/home/bammi/lib.hp-ux/alloca.o
MALLOC1 = /net/acae127/home/bammi/lib.hp-ux/malloc_new6.o

LIBS = $(ALLOCA) $(MALLOC1)

ALL = ld sym-ld nm car size size68 tnm xstrip  fixstk printstk toglclr

all: $(ALL)
#
# the 'regular' linker, produces atari executables
#
ld : ld.o cplusdem.o
	$(CC) -o ld ld.o cplusdem.o $(LIBS)

#
# the 'other' linker, produces atari gdb compat symb files
#
sym-ld : sym-ld.o  cplusdem.o
	$(CC) -o sym-ld sym-ld.o cplusdem.o $(LIBS)

#
# obj file describer?
#
nm : nm.o cplusdem.o
	$(CC) -o nm nm.o cplusdem.o  $(LIBS)

# 
# Object file sizes
#
size: size.o
	$(CC) -o size size.o $(LIBS)

#
# ar - archiver/librarian
#
car : ar.o
	$(CC) -o car ar.o $(LIBS)

#
# TOS executable file sizes
#
size68: size68.o
	$(CC) -o size68 size68.o $(LIBS)

#
# TOS format symbol dumper
#
tnm: cnm.o
	$(CC) -o tnm cnm.o $(LIBS)

#
# TOS format symbol table stripper
#
xstrip: strip.o
	$(CC) -o xstrip strip.o $(LIBS)

#
# TOS format flags manipulator
#
toglclr: toglclr.o
	$(CC) -o toglclr toglclr.o

install: $(ALL)
	cp ld $(CROSSLIB)/gcc-ld
	cp nm $(CROSSBIN)/cnm
	cp car $(CROSSBIN)/car
	cp size $(CROSSBIN)/csize
	cp size68 $(CROSSBIN)/csize68
	cp tnm $(CROSSBIN)/tnm
	cp xstrip $(CROSSBIN)/xstrip
	cp sym-ld $(CROSSBIN)/sym-ld
	cp  fixstk printstk toglclr $(CROSSBIN)

clean:
	rm -f *.o

realclean: clean
	rm -f $(ALL) core report
