#
# 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 = /share/gcc-cross/atari
CROSSBIN = $(CROSSDIR)/bin
CROSSLIB = $(CROSSDIR)/lib
CROSSINC = $(CROSSDIR)/include

# Host GCC
CC=/usr/local/bin/gcc
# Host include dir
#HOSTINC = /usr/local/lib/gcc-lib/sparc-sun-sunos4.1/2.2.2/include
HOSTINC = /usr/include

CFLAGS = -O2 -I. -I$(HOSTINC) -I$(CROSSINC) -DCROSSATARI=1 \
-DCROSSDIR=\"$(CROSSDIR)\" -DCROSSLIB=\"$(CROSSLIB)\" -DWORD_ALIGNED=1

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

#
# 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

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

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

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

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

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

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

#
# 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 $(CROSSBIN)
	cp  toglclr $(CROSSBIN)

clean:
	rm -f *.o

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