#****************************************************************************/
#*																			*/
#*	cogito Gesellschaft fr Elektronikentwicklung mbH						*/
#*		info@cogito.de		http://www.cogito.de/							*/
#*	  																		*/
#*		gnu C makefile for mc68xxx single-board-computer startup library	*/
#*																			*/
#*				File			: Makefile									*/
#*				Author			: Frank Sautter								*/
#*				First Byte		: 12.06.96									*/
#*				Latest Change	: 18.06.96									*/
#*																			*/
#****************************************************************************/

INCLUDE	= 	-I../include
CPU		= 	68332

CDFLAGS	=	-O -g -D_REENT_ONLY
ADFLAGS =

TARGETS =	crt0.o romboot.o libreader.a librobot.a

LIBOBJS =	fstat.o getpid.o isatty.o kill.o lseek.o open.o \
			sbrk.o stat.o unlink.o exit.o close.o

############################################################################
CC	= gcc-m68k
CFLAGS  = -m${CPU} ${INCLUDE} ${CDFLAGS}

AS	= as-m68k
AFLAGS	= -m${CPU} ${INCLUDE} --register-prefix-optional ${ADFLAGS}

AR	= ar-m68k
RANLIB = ranlib-m68k

LD	= ld-m68k

DEST	= ../lib

######## Suffix Rules
.s.o:
	${AS} ${AFLAGS} -o $@ $<

############################################################################
all:  ${TARGETS}

####### Robot controller
librobot.a: ${LIBOBJS} read.c write.c
	${CC} ${CFLAGS} -imacros hwdesc-robot.h -c read.c
	${CC} ${CFLAGS} -imacros hwdesc-robot.h -c write.c
	${AR} r $@ ${LIBOBJS} read.o write.o
	cp $@ ../lib

####### Chipcard unit
libreader.a: ${LIBOBJS} read.c write.c
	${CC} ${CFLAGS} -imacros hwdesc-reader.h -c read.c
	${CC} ${CFLAGS} -imacros hwdesc-reader.h -c write.c
	${AR} r $@ ${LIBOBJS} read.o write.o
	cp $@ ../lib

####### common targets
clean:				
	rm *.o *.a

install: all
	@echo Install detination is: ${DEST} ; \
	for i in ${TARGETS} *.ld ; do \
		echo $$i; cp $$i ${DEST} ; \
	done
