# Cheapo makefile for generic boot files
.SUFFIXES:
.SUFFIXES: .em .sc 

#Configuration
SOCKETS=t
STRIPMODULES=t
#where to install things
FEEL_PATH=../..

FEEL_IMAGE=#-boot ../Compiler/loader

#Don't want to pick up _any_ default paths...
FEEL_IMAGE=#-boot ../Compiler/compiler
FEEL_ENV = \
	FEEL_LOAD_PATH=..:.:../Compiler \
	FEEL_INTF_PATH=.:../Interfaces  \
	FEEL_START_MODULE=eulisp0	

FEELC= ../../Src/you -procs 1 -heap 7 ${FEEL_IMAGE}
#FEELC=FEEL_IMAGE=loader feel80b -heap 8

#For cross-transfers
#HACKPATH=add-load-path
#RELOAD=!>>
#for building self
HACKPATH=xx-add-load-path
RELOAD=!>
MODMAP=../you.mods

#BOOTOBJS= boot.sc init.sc macros0.sc extras0.sc defs.sc \
#	  numbers.sc telos1.sc streams1.sc error0.sc standard.sc semaphores.sc standard0.sc
#BOOTSRCS= boot.em init.em macros0.em extras0.em defs.em \
#  	  numbers.em telos1.em streams1.sc error0.sc standard.em semaphores.em standard0.em

BOOTOBJS = boot.sc init.sc macros0.sc extras0.sc defs.sc gens.sc numbers.sc null.sc pair.sc \
	   list.sc telos1.sc streams1.sc error0.sc thread.sc lock.sc table.sc character.sc  \
	   vector.sc string.sc copy.sc collect.sc condition.sc eulisp0.sc standard.sc standard0.sc

BOOTSRCS = boot.em init.em macros0.em extras0.em defs.em gens.em numbers.em null.em pair.em \
	   list.em telos1.em streams1.em error0.em thread.em lock.em table.em character.em  \
	   vector.em string.em copy.em collect.em condition.em eulisp0.em standard.sc standard0.sc

TESTOBJS1 =
TESTSRCS1 =
TESTSRCS = ${BOOTSRCS} ${TESTSRCS1}
TESTOBJS = ${BOOTOBJS} ${TESTOBJS1}

IMAGE=image.ebc image.est

image: image.ebc
init: init.em
test: test.ebc
ncc: ncc-image.ebc

init.em: gen-init.em class-defs.em class-macs.em
	echo '(!> class-macs)(set-sockets ${SOCKETS})(!> gen-init)(write-c-code)(exit)' | ${FEEL_ENV} ${FEELC} 


image.ebc: ${BOOTOBJS}
	(echo '(!> combine)(combine-mods-with-file (quote image) "${MODMAP}" (quote (' ; \
	(echo ${BOOTOBJS} | sed -e 's/\.sc/ /g') ; echo ')))(exit)') | ${FEEL_ENV}  ${FEELC}
	test -f image.ebc

ncc-image.ebc: ${BOOTOBJS}
	(echo '(!> combine)(combine-mods-with-file (quote ncc-image) "you.mods.ncc" (quote (' ; \
	(echo ${BOOTOBJS} | sed -e 's/\.sc/ /g') ; echo ')))(backtrace)(exit)') | ${FEEL_ENV} ${FEELC}
	test -f ncc-image.ebc

test.ebc: ${TESTOBJS}
	(echo '(!> combine)(combine-mods-with-file (quote test) "../you.mods" (quote (' ; \
	(echo ${TESTOBJS} | sed -e 's/\.sc/ /g') ; echo ')))(backtrace)(exit)') | ${FEEL_ENV} ${FEELC}
	test -f test.ebc

.em.sc: 
	rm -f $*.sc
	echo '(!> compile)(!> compile)(!> mod-hack)(${HACKPATH} "Xfer")(${RELOAD} macros0)\
	      (${RELOAD} defs) (!> compile) (if t (progn ((setter optimize-code) t)\
	  ((setter strip-module) ${STRIPMODULES})) nil)(comp2sc (quote $*))(backtrace) (exit)' | ${FEEL_ENV} ${FEELC}
	test -f $*.sc

install: ${IMAGES}
	cp image.ebc image.est ${FEEL_PATH}/Images
		
# I deliberately do not delete documentation files

clean:
	rm -f *.sc core *.i *.fm

# I don't put all the dependencies in -- just things that build fast

standard0.sc: standard.sc 
standard.sc: macros0.sc extras0.sc telos1.sc defs.sc error0.sc init.sc
