# 
#  Makefile for CLX
#  (XV11.R3 release, Franz Common Lisp version)
#

# *************************************************************************
# * Change the next line to point to where you have Common Lisp installed *
# *************************************************************************
CL	= /usr/local/cl

RM	= /bin/rm
ECHO	= /bin/echo
TAGS	= /usr/local/lib/emacs/etc/etags

# Name of dumped lisp
CLX	= CLX

CLOPTS	= -qq
CFLAGS	= -O -DUNIXCONN

# Lisp optimization for compiling
SPEED	= 3
SAFETY	= 0


C_SRC	= excldep.c socket.c
C_OBJS	= excldep.o socket.o

L_OBJS	= defsystem.fasl depdefs.fasl clx.fasl dependent.fasl \
	macros.fasl bufmac.fasl buffer.fasl display.fasl gcontext.fasl \
	requests.fasl input.fasl fonts.fasl graphics.fasl text.fasl \
	attributes.fasl translate.fasl keysyms.fasl manager.fasl image.fasl \
	resource.fasl

L_SRC	= defsystem.cl depdefs.cl clx.cl dependent.cl \
	macros.cl bufmac.cl buffer.cl display.cl gcontext.cl \
	requests.cl input.cl fonts.cl graphics.cl text.cl \
	attributes.cl translate.cl keysyms.cl manager.cl image.cl \
	resource.cl


all : $(C_OBJS) compile-CLX cat


CLX : $(C_OBJS) compile-CLX load-CLX


c:	$(C_OBJS)


lisp:	compile-CLX


compile-CLX : $(C_OBJS)
	$(ECHO)	 "(proclaim '(optimize (speed $(SPEED)) (safety $(SAFETY))))" \
		 "#+allegro-v3.0 (setq comp::*dynamic-extent* t)" \
		 '(compile-file-if-needed "excldep")' \
		 '(compile-file-if-needed "defsystem")' \
		 '(load "defsystem")' \
		 "#+allegro (compile-system 'xlib::clx)" \
		 "#-allegro (xlib::compile-clx)" \
		 '(exit)' | $(CL) $(CLOPTS)


cat:
	-cat excldep.fasl $(L_OBJS) > CLX.fasl


load-CLX :
	$(ECHO)  '(load "defsystem")' \
		 "(let (#+allegro (spread (sys:gsgc-parameter :generation-spread)))" \
		 "  #+allegro (setf (sys:gsgc-parameter :generation-spread) 1)" \
		 "  #+allegro (load-system 'xlib::clx)" \
		 "  #-allegro (xlib::load-clx)" \
		 "  #+allegro (gc :tenure)" \
		 "  #+allegro (setf (sys:gsgc-parameter :generation-spread) spread)" \
		 ")" \
		 '#+allegro (gc t)' \
		 '(dumplisp :name "$(CLX)" #+allegro :checkpoint #+allegro nil)' \
		 '(exit)' | $(CL) $(CLOPTS)


clean :
	$(RM) -f *.fasl $(CLX) core $(C_OBJS)


tags :
	$(TAGS) $(L_SRC) $(C_SRC)
