SYSTEM= next
COMMON=common$(SYSTEM)
LELISP=lelisp
SIZEF31= -float 0
SIZEF= $(SIZEF31)
BIG=big

# On ajoute la taille de Caml
SZCAML= -stack 24 -code 1000 -heap 1000 -number 0 \
	-vector 30 -string 40 -symbol 6  -cons 15  $(SIZEF)
# Caml avec une giigaanntesque zone de code
SZBIGCAML= -stack 24 -code 1500 -heap 1000 -number 0 \
	-vector 30 -string 40 -symbol 6  -cons 15  $(SIZEF)
# On change all en camlisp:
all:    camlisp
# On change clear en:
clear:
	rm -f *bin
	rm -f camlisp$(BIG)
	rm -f conf/lelispconf.ll conf/cmplcconf.ll

# On ajoute de quoi faire camlisp
### camlispbig (+ de code)
camlisp$(BIG): conf/camlconf.ll  camlispbin
	./config camlisp$(BIG) camlispbin camlconf.ll $(SZBIGCAML)

camlisp: conf/camlconf.ll  camlispbin
	./config camlisp camlispbin camlconf.ll $(SZCAML)

conf/camlconf.ll: conf/camlsoftconf.ll
	@rm -f conf/camlconf.ll
	ln conf/camlsoftconf.ll conf/camlconf.ll

# On continue avec les variables du makefile
XLIB=-L/usr/lib
XINCLUDE=/usr/include
LOCALVARS=-x
LDFLAGS=  $(LOCALVARS) -L$(XLIB)
LDLIBS= -lm -lc
LLINCLUDE=-I`pwd`/../$(COMMON) -I.
FOREIGN=-DFOREIGN
EXECORE=
#-DEXECORE
# For sun OS 4.*
#SUNOS=-DSUNOS40 -Bstatic
# Otherwise
SUNOS=
#FILEINI=-DFILEINI=\"/usr/local/caml/V2-6.1/llib15.23/startup.ll\"
CFLAGS= -O -DNBSYST=45 -DBSD4x -DBSD42 -DNEXT -DTIMEUNIT=60. \
	-DINRIA $(SUNOS) $(FOREIGN) $(FILEINI) $(EXECORE) \
	$(LLINCLUDE) -I$(XINCLUDE)
cobj=   o/llmain.o o/caml.o o/camlstdio.o o/llfloat.o

o/llmain.o: ../$(COMMON)/llmain.c
	$(CC) $(CFLAGS) -c ../$(COMMON)/llmain.c
	mv llmain.o o

o/caml.o: ../$(COMMON)/caml.c
	$(CC) $(CFLAGS) -c ../$(COMMON)/caml.c
	mv caml.o o/caml.o

o/camlstdio.o: ../$(COMMON)/llstdio.c
	$(CC) -DMAXCHAR=1024 $(CFLAGS) -c ../$(COMMON)/llstdio.c
	mv llstdio.o o/camlstdio.o

o/llfloat.o: ../$(COMMON)/llfloat.c
	$(CC) $(CFLAGS) -c ../$(COMMON)/llfloat.c
	mv llfloat.o o

o/cstruct.o: ../$(COMMON)/cstruct.c
	$(CC) $(CFLAGS) -c ../$(COMMON)/cstruct.c
	mv cstruct.o o

camlispbin: casoft31bin
	@rm -f camlispbin
	ln casoft31bin camlispbin

casoft31bin: $(cobj) lesoft31bin.o
	cc $(CFLAGS) $(LDFLAGS) $(cobj) lesoft31bin.o \
	$(LDLIBS) -o casoft31bin
