# $Header$

#PARAMS		do not remove this line!

#requires a definition for SRC_DIR; not to be called directly.

EM = $(TARGET_HOME)
CEG = $(EM)/lib.bin/ceg

AS   = $(CEG)/as_parser
DEF = $(CEG)/defaults

IFILES	= -I. -I$(SRC_DIR) -I.. -I$(AS) -I$(EM)/h -I$(EM)/modules/h -I../back -I$(SRC_HOME)/mach

CFLAGS = $(COPTIONS) $(IFILES)

.c.$(SUF):
	cd ce ; $(CC) -c $(CFLAGS) ../$*.c ; cd ..

all:	ce.$(LIBSUF)

ce.$(LIBSUF):	ce/dummy
	$(AR) r ce.$(LIBSUF) ce/*.$(SUF)
	$(RANLIB) ce.$(LIBSUF)

ce/dummy:	ce/dummy1 back.$(LIBSUF)
	cd ce ; $(CC) -c $(CFLAGS) *.c ; touch dummy ; cd ..

ce/dummy1:	ceg/ceg $(SRC_DIR)/EM_table $(SRC_DIR)/mach.c
	-mkdir ce
	-cp $(SRC_DIR)/mach.c ce/mach.c
	cd ce ; ../ceg/ceg -l < $(DEF)/not_impl/not_impl_table ; cp $(DEF)/*.c . ; cp $(DEF)/*/*.c . ; cd ..
	-if [ -d $(SRC_DIR)/ce.src ] ; then cd ce ; cp $(SRC_DIR)/ce.src/*.c . ; cd .. ; fi
	cd ce ; $(EM)/lib.bin/cpp -P $(SRC_DIR)/EM_table | ../ceg/ceg -l ; touch dummy1 ; cd ..
