#
# $Id: GNUmakefile.os4,v 1.13 2006-04-18 08:29:46 obarthel Exp $
#
# :ts=8
#

##############################################################################

CC = ppc-amigaos-gcc
DELETE = rm -r

##############################################################################

.c.o:
	@echo "Compiling $<"
	@$(CC) -c $(CFLAGS) $<

##############################################################################

WARNINGS = \
	-Wall -W -Wshadow -Wpointer-arith -Wsign-compare -Wmissing-prototypes \
	-Wundef -Wbad-function-cast -Wmissing-declarations -Wconversion

V = /V
INCLUDE = -I$(V)/include -I../library/include
#OPTIONS = -D__MEM_DEBUG
#OPTIONS = -DDEBUG
 OPTIONS = -DNDEBUG
#OPTIMIZE = -O3
#DEBUG = -ggdb

# Note: Because the matching startup code needs to be used for
#       correctly linking the test programs, you need to make sure
#       that the current development version of clib2 is visible
#       where the linker expects it (soft link). Some more tuning would be
#       required here because you really should not need to tinker
#       with the location of library and the options "-L. -L../library/lib"
#       should be sufficient.

CFLAGS = -mcrt=clib2 -fno-builtin $(WARNINGS) $(OPTIMIZE) $(DEBUG) $(OPTIONS) $(INCLUDE)
LFLAGS = -Wl,-d

##############################################################################

LIBS = -ldebug -lm -lc

##############################################################################

all: test fgets_test iotest sscanf_test printf_test sprintf_test \
	stack_size_test translate_test strtok_test uname simple \
	fstat_stdout_test simple_sprintf date_test sscanf_64 \
	factorial setlocale rand malloc-test slab-test

clean:
	$(DELETE) *.o *.map test fgets_test iotest sscanf_test printf_test \
		sprintf_test stack_size_test translate_test strtok_test \
		uname simple fstat_stdout_test simple_sprintf date_test \
		sscanf_64 factorial setlocale rand malloc-test slab-test

##############################################################################

setlocale : setlocale.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ setlocale.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

test : test.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ test.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

date_test : date_test.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ test.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

fgets_test : fgets_test.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ fgets_test.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

strtok_test : strtok_test.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ strtok_test.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

iotest : iotest.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ iotest.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

sscanf_test : sscanf_test.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ sscanf_test.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

printf_test : printf_test.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ printf_test.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

sprintf_test : sprintf_test.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ sprintf_test.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

stack_size_test : stack_size_test.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ stack_size_test.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

translate_test : translate_test.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ translate_test.o -lunix $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

uname : uname.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ uname.o -lunix $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

simple : simple.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ simple.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

fstat_stdout_test : fstat_stdout_test.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ fstat_stdout_test.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

simple_sprintf : simple_sprintf.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -nostdlib -o $@ simple_sprintf.o -lc -lgcc $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

sscanf_64 : sscanf_64.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ sscanf_64.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

factorial : factorial.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ factorial.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

rand : rand.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ rand.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

malloc-test : malloc-test.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ malloc-test.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map

slab-test : slab-test.o
	@echo "Linking $@"
	$(CC) $(CFLAGS) -o $@ slab-test.o $(LIBS) $(LFLAGS) -Wl,--cref,-M,-Map=$@.map
