
SHELL	=	/bin/sh

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

TARGET		=	PPC
CODETYPE	=	PPC
VERSION		=	0

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

#-I/ade/ppc-amigaos/include/
#-Iinclude:
# -I/ade/include   -I../../../emulinclude/includenew/
G_IPATH		=	-I../../../emulinclude/includegcc/ -I../../../include/
G_DEFINES	=	-D$(CODETYPE)
G_OPTFLAGS	=	-O2			\
			-fomit-frame-pointer	\
			-fverbose-asm		\
			-mstrict-align		\
			-mno-prototype		\
			-mcpu=604		\
			-mregnames		\
			-Wformat		\
			-Wunused		\
			-Wuninitialized		\
			-Wconversion		\
			-Wstrict-prototypes	\
			-Werror-implicit-function-declaration


APATH		=	-iinclude/
AFLAGS		=	-M4000

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

all:	ppcexample.library.elf	\
	lib_inline.h

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

.SUFFIXES: .o$(TARGET) .asm

.c.o$(TARGET):
	ppc-amigaos-gcc $(G_CFLAGS) $(G_OPTFLAGS) $(G_DEBUG) $(G_DEFINES) $(G_IPATH) -S -o $*.s $*.c
	ppc-amigaos-as -v -o$*.o$(TARGET) $*.s

.s.o$(TARGET):
	ppc-amigaos-as -o$*.o$(TARGET) $*.s


.asm.o$(TARGET):
	basm $(AFLAGS) $(APATH) -o$*.o$(TARGET) $*.asm

##############################################################################
##############################################################################
##############################################################################
##############################################################################
##############################################################################
##############################################################################
##############################################################################
#
# amiga Emulation
#

LIB		=	../../../lib

SRC		=

GLOBAL		=	libdata.h

lib.o$(TARGET):			$(SRC)lib.c			$(GLOBAL)
libend.o$(TARGET):		$(SRC)libend.c
libfunctions.o$(TARGET):	$(SRC)libfunctions.c		$(GLOBAL)
libfunctable.o$(TARGET):	$(SRC)libfunctable.c		$(GLOBAL)

OBJS		=	lib.o$(TARGET)\
			libfunctions.o$(TARGET)\
			libfunctable.o$(TARGET)\
			libend.o$(TARGET)

lib_inline.h:	lib.fd lib_protos.h
		../../../emultools/fd2inline/fd2inline --new --powerup lib.fd lib_protos.h $@

#####################################################################
#
# Link Project
#

#####################################################################
#
# Project ppcexample.library.library
#

ppcexample.library.elf:	$(OBJS)			\
			$(LIB)/libsyscall.a
		ppc-amigaos-ld -v -L./lib -r $(OBJS) $(LIB)/libsyscall.a -o ppcexample.library.elf -lm


BUMP:
	bumprev2 VERSION=$(VERSION) FILE=$(SRC)ppcexample.library_VERSION TAG=ppcexample.library ADD="© 2000 by Ralph Schmidt, written by Ralph Schmidt"


DUMP:
	ppc-amigaos-objdump --section-headers --all-headers --reloc --disassemble-all ppcexample.library.elf >ppcexample.library.elf.dump

##############################################################################
.PHONY: all
