
# Rewritten smakefile for amiga / sas/c. -Kjetil M.
# Don't use the cord-package if you define parm=both or parm=reg.


#----------------TOOLS--------------------------------
CC=sc
LINKER=slink
LIBER=oml

#----------------CPU OPTIONS--------------------------

CPU=68060

#----------------FPU OPTIONS--------------------------

MATH=8
MATHLIB=LIB:scm881.lib

#----------------COMPILER OPTIONS---------------------

IGNORE= IGNORE=85 IGNORE=154 IGNORE=161 IGNORE=100

OPTIMIZE=optimize optimizetime optglobal optimizerdepth=100 optimizerpeephole optloop OPTSCHED optimizerinlocal optimizerrecurdepth=100
# optimizerinline optimizercomplexity=100

OPT= $(OPTIMIZE) CPU=$(CPU) math=$(MATH) NOSTACKCHECK VERBOSE \
MAPHUNK NOVERSION NOICONS nodebug \
parm=reg \
DEFINE __USE_SYSBASE


SOPT= $(OPT) $(IGNORE) \
DEFINE AMIGA_SKIP_SEG \
DEFINE GC_ATOMIC_UNCOLLECTABLE \
DEFINE GC_AMIGA_FASTALLOC \
DEFINE GC_AMIGA_RETRY \
DEFINE GC_AMIGA_PRINTSTATS \
DEFINE GC_AMIGA_GC


#DEFINE ALL_INTERIOR_POINTERS \


SCOPT= $(SOPT) define GC_AMIGA_MAKINGLIB

CSCOPT= $(OPT) DEFINE AMIGA IGNORE=100 IGNORE=161

#------------------LINKING----------------------------


all: gc.lib cord.lib

clean:
	delete *.lib gctest setjmp_t *.o *.lnk cord/*.o cord/tests/*.o cordtest
	smake

check: setjmp_t gctest cordtest
	setjmp_t
	gctest
	cordtest

gctest: gc.lib GCAmigaOS$(CPU).lib test.o
	$(LINKER) LIB:c.o test.o TO gctest LIB gc.lib LIB:sc.lib $(MATHLIB)

setjmp_t: setjmp_t.o gc.h
	$(LINKER) LIB:c.o setjmp_t.o to setjmp_t lib LIB:sc.lib

cordtest: cord/tests/cordtest.o cord.lib gc.lib
	$(LINKER) LIB:c.o cord/tests/cordtest.o LIB $(MATHLIB) gc.lib cord.lib LIB:sc.lib TO cordtest


#------------------LIBBING----------------------------

OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dyn_load.o dbg_mlc.o malloc.o checksums.o typd_mlc.o ptr_chck.o mallocx.o fnlz_mlc.o

gc.lib: $(OBJS)
	$(LIBER) gc.lib r $(OBJS)


COBJS = cord/cordbscs.o cord/cordprnt.o cord/cordxtra.o

cord.lib: $(COBJS)
	$(LIBER) cord.lib r $(COBJS)

#------------------COMPILING--------------------------

INC=  gc_private.h gc_hdrs.h gc.h gcconfig.h

alloc.o : alloc.c $(INC)
	$(CC) alloc.c $(SCOPT) ignore=7

reclaim.o : reclaim.c $(INC)
	$(CC) reclaim.c $(SCOPT)

allchblk.o : allchblk.c $(INC)
	$(CC) allchblk.c $(SCOPT)

misc.o : misc.c $(INC)
	$(CC) misc.c $(SCOPT)

os_dep.o : os_dep.c $(INC) extra/AmigaOS.c
	$(CC) os_dep.c $(SCOPT)

mark_rts.o : mark_rts.c $(INC)
	$(CC) mark_rts.c $(SCOPT)

headers.o : headers.c $(INC)
	$(CC) headers.c $(SCOPT)

mark.o : mark.c $(INC)
	$(CC) mark.c $(SCOPT)

obj_map.o : obj_map.c $(INC)
	$(CC) obj_map.c $(SCOPT)

blacklst.o : blacklst.c $(INC)
	$(CC) blacklst.c $(SCOPT)

finalize.o : finalize.c $(INC)
	$(CC) finalize.c $(SCOPT) noopt
# Could sas/c still have problems with this one? Gctest sometimes fails to finalize all.

new_hblk.o : new_hblk.c $(INC)
	$(CC) new_hblk.c $(SCOPT)

dyn_load.o : dyn_load.c $(INC)
	$(CC) dyn_load.c $(SCOPT)

dbg_mlc.o : dbg_mlc.c $(INC)
	$(CC) dbg_mlc.c $(SCOPT)

fnlz_mlc.o : fnlz_mlc.c $(INC)
	$(CC) fnlz_mlc.c $(SCOPT)

malloc.o : malloc.c $(INC)
	$(CC) malloc.c $(SCOPT)

mallocx.o : mallocx.c $(INC)
	$(CC) mallocx.c $(SCOPT)

checksums.o : checksums.c $(INC)
	$(CC) checksums.c $(SCOPT)

typd_mlc.o: typd_mlc.c $(INC)
	$(CC) typd_mlc.c $(SCOPT)

mach_dep.o : mach_dep.c $(INC)
	$(CC) mach_dep.c $(SCOPT)

ptr_chck.o: ptr_chck.c $(INC)
	$(CC) ptr_chck.c $(SCOPT)

test.o : test.c $(INC)
	$(CC) test.c $(SOPT)

setjmp_t: tools/setjmp_t.c gc.h
	$(CC) tools/setjmp_t.c $(SOPT)

# cords:

cord/cordbscs.o: cord/cordbscs.c
	$(CC) cord/cordbscs.c $(CSCOPT)

cord/cordprnt.o: cord/cordprnt.c
	$(CC) cord/cordprnt.c $(CSCOPT)

cord/cordxtra.o: cord/cordxtra.c
	$(CC) cord/cordxtra.c $(CSCOPT)

cord/tests/cordtest.o: cord/tests/cordtest.c
	$(CC) cord/tests/cordtest.c $(CSCOPT)
