#
#     Le makefile de camlisp pour sun4
#     make -f make_camlispbin pour refaire camlisp
#     make -f camlispbig pour refaire un camlisp avec plus de code
#              (necessaire de refaire caml dans ce cas)
#
SYSTEM= sun4
LELISP=lelisp
SIZEF31= -float 0
#SIZEF= $(SIZEF31)
SIZEF= -float 1
BIG=big
COMMON=common$(SYSTEM)

# For optimization use -O
COPT= -O

LLINCLUDE=-I`pwd`/../$(COMMON)

# On ajoute la taille de Caml
SZCAML= -stack 24 -code 2500 -heap 1000 -number 0 \
	-vector 30 -string 40 -symbol 6  -cons 15  $(SIZEF)
# Caml avec une giigaanntesque zone de code
SZBIGCAML= -stack 24 -code 1900 -heap 1000 -number 0 \
	-vector 30 -string 40 -symbol 6  -cons 15  $(SIZEF)

# On continue avec les variables du makefile
XLIB=-L/usr/lib
XINCLUDE=/usr/include
LDFLAGS= -x -Bstatic
LDLIBS= -lm -lc
FOREIGN=-DFOREIGN
# Save-core does not work in EXECORE mode on Sun4
#EXECORE=-DEXECORE
EXECORE=
# a partir de 4.0.1, sur sun4
SUNOS= -DSUNOS40 -Bstatic -sun4 

FILEINI=-DFILEINI=\"../llib15.23/startup.ll\"
CFLAGS= $(CDEBUG) $(COPT) $(FOREIGN) $(EXECORE)\
	-DSUN4 -DNBSYST=35 -DBSD42 -DBSD4x -DTIMEUNIT=60. \
	 $(SUNOS) $(FILEINI) $(LLINCLUDE) 

cobj=   o/llmain.o o/caml.o o/camlstdio.o o/llfloat.o o/llnumb.o

obj= lelispbin.o $(cobj)

# 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)

camlispbin: $(obj)
	cc $(CFLAGS) $(obj) $(LDLIBS) $(LDFLAGS) -o camlispbin

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)/camlstdio.c
	cc -DMAXCHAR=1024 $(CFLAGS) -c ../$(COMMON)/camlstdio.c
	mv camlstdio.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

o/llnumb.o:  c/llnumb.c
	cc $(CFLAGS) -c $?
	mv llnumb.o o

