#
#  Le Makefile du systeme Le←Lisp [sun4] #
#
SYSTEM=sun4
#
# Le directory racine du syste`me
#
# Mis a jour par la commande  newdir
#

#
# Les tailles par de'faut des zones de donne'es
#

SIZE=  -stack 6 -code 800 -heap 256 -number 0 -float 1 \
        -vector 4 -string 5 -symbol 5 -cons 10

SIZEX=  -stack 6 -code 800 -heap 256 -number 0 -float 1 \
        -vector 5 -string 4 -symbol 4 -cons 7

SIZEP=  -stack 6 -code 800 -heap 256 -number 0 -float 1 \
        -vector 8 -string 6 -symbol 6 -cons 4

SIZEH= -stack 12 -code 1200 -heap 512 -number 0 -float 1 \
       -vector 8 -string 12 -symbol 10 -cons 8

# For debugging use -g
CDEBUG= 
# For optimization use -O
COPT= -O

LLINCLUDE=`pwd`/../common

SUNOS= -DSUNOS40 -Bstatic 
CFLAGS= $(CDEBUG) $(COPT) \
	-DSUN4 -DNBSYST=35 -DBSD42 -DBSD4x -Dx11r2 -DTIMEUNIT=60. -DINRIA \
	 $(SUNOS) -I$(LLINCLUDE) \
        -DFILEINI=\"../llib/startup.ll\" 

cobj= o/llmain.o o/lelisp.o o/llstdio.o o/llfloat.o o/llnumb.o

obj= lelispbin.o $(cobj)

xobj= o/x11.o o/cstruct.o $(cobj)

testextobj= o/testf.o o/testext.o lelispbin.o o/cstruct.o $(cobj)

lelispbin: $(obj)
	cc $(LDFLAGS) $(obj) $(LDLIBS) -o lelispbin

BITMAP=X11
leX11bin: $(xobj) lelispbin.o
	cc $(LDFLAGS) lelispbin.o $(xobj) \
	$(XLDLIBS) -o leX11bin

letestextbin: $(testextobj)
	cc $(testextobj) $(LDLIBS) $(LDFLAGS) -o letestextbin

# -X to keep local symbols in the executable. -x to save space.
LDFLAGS= -x

LDLIBS= -lm -lc

XLDLIBS= -lX11 $(LDLIBS)

# Entry to create 3 standard memory images
all: lelisp cmplc lelispX11

# Entry to create standard binaries
tout: lelispbin leX11bin 

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

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

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

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

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

o/cstruct.o: ../common/cstruct.c
	cc $(CFLAGS) -c ../common/cstruct.c
	mv cstruct.o o/cstruct.o

o/x11.o: ../virbitmap/X11/x11.c
	(CFLAGS="$(CFLAGS)"; \
	cd ../virbitmap/X11 ; \
	$(MAKE) ../../$(SYSTEM)/o/x11.o SYSTEM=$(SYSTEM) CFLAGS="$$CFLAGS")

o/testext.o:  ../lltest/testext.c
	cc $(CFLAGS) -c ../lltest/testext.c
	mv testext.o o


#
# Le point d'entre'e permettant de faire le syste`me
# 

lelisp: makefile conf/lelispconf.ll  lelispbin
	./config lelisp lelispbin lelispconf.ll $(SIZE)

lelisp-: makefile conf/lelisp-conf.ll  lelispbin
	./config lelisp- lelispbin lelisp-conf.ll $(SIZE)

lelisp+: makefile conf/lelispconf.ll  lelispbin
	./config lelisp+ lelispbin lelispconf.ll $(SIZEP)

lelisp++: makefile conf/lelispconf.ll  lelispbin
	./config lelisp++ lelispbin lelispconf.ll $(SIZEH)

cmplc: makefile conf/cmplcconf.ll  lelispbin
	./config cmplc lelispbin cmplcconf.ll $(SIZE)

cmplc++: makefile conf/cmplcconf.ll  lelispbin
	./config cmplc++ lelispbin cmplcconf.ll $(SIZEH)

lelispX11: makefile conf/lelispX11conf.ll  leX11bin
	./config  lelispX11 leX11bin lelispX11conf.ll $(SIZEX)

# make target that removes all the files that can be regenerated by the
# user.
clean:
	rm -f $(cobj) $(xobj) lelisp cmplc lelispX11 lelispbin leX11bin

include makesop