# Makefile for CLISP module set clx

CC = @CC@
CFLAGS = -O
INCLUDES= ../../
CLISP = clisp -q -norc
MODPREP = ../../modprep.fas
LN = ln
SHELL = /bin/sh

DISTRIBFILES = link.sh Makefile clx-preload.lisp clx.lisp clx.fas image.lisp image.fas clx.o
distribdir =

### Custom defs.
CCMP2C = ../../ccmp2c
RM = rm -f
WANTS = @WANTS@
X_CFLAGS = @X_CFLAGS@

all : clx.fas image.fas clx.o

clx.fas clx.lib: clx.lisp clx-preload.lisp
	$(CLISP) -i clx-preload.lisp -c clx.lisp

image.fas: image.lisp clx.lib
	$(CLISP) -i clx-preload.lisp -c image.lisp

clx.e: clx.f
	$(CCMP2C) clx.f > genclx.c
	$(CC) $(CFLAGS) $(WANTS) genclx.c -o genclx
	./genclx > clx.e
	$(RM) genclx.c
	$(RM) genclx

clx.c: clx.e $(MODPREP)
	$(RM) clx.d
	echo "#line 1 \"clx.f\"" > clx.d
	cat clx.e >> clx.d
	$(CLISP) $(MODPREP) clx.d clx.c

clx.o: clx.c
	$(CC) $(CFLAGS) $(X_CFLAGS) -I$(INCLUDES) -c clx.c

# Make a module
clisp-module : clx.fas image.fas clx.o

# Make a module distribution into $(distribdir)
clisp-module-distrib : clisp-module force
	$(LN) $(DISTRIBFILES) $(distribdir)


clean : force
	$(RM) genclx.c genclx clx.temp *.lib *.fas clx.e clx.d clx.c clx.o

force:

