### 
### This is an automagically generated sample makefile for building lisp as a
### shared library examples using Allegro CL version 9.0.final.7 on a
### linux86-64 host with *features* :use-thread-libs, :linux86-64, :loadacl,
### :linux86-64, :smp-macros, :smp, :dynload-acl-library, :ssl-support,
### :dlfcn, :os-threads.
### 

CC = cc
AS = as -64
LD = $(CC)

LNKACL_NAME = liblnkacl.so

CFLAGS = -DACL_MAJ_VER=9 -DACL_MIN_VER=0 -D_GNU_SOURCE -DACLSMP -DACLSMPBASE -DOS_THREADS -DPOSIX_THREADS -DAcl64Bit -m64 -fPIC

env = LD_LIBRARY_PATH=.; export LD_LIBRARY_PATH;

LDFLAGS = $(CFLAGS) -Wl,-E

LIBRARIES = -lpthread -lrt -lm -ldl -lc

RUNLISP := $(shell if test -d ../c; then echo ../lispi -I dcli.dxl; else echo ../../mlisp; fi)

SHLIBS_H_ARG := -I$(shell if test -d ../c; then echo ../c; else echo ../../misc; fi)

all: clean fact/ftest test

all2: clean fact/ftest test2

fact/ftest: ftest fact.dxl

ftest: ftest.c
	$(env) $(LD) -o ftest $(SHLIBS_H_ARG) $(LDFLAGS) ftest.c -L. -llnkacl $(LDFLAGS) $(LIBRARIES)

FACT_CMD = '(generate-application "fact" "fact/" \
		(list "lnkacl.fasl" "fact.fasl") \
		:application-type :exe \
		:application-files (list "ftest" "$(LNKACL_NAME)") \
		:read-init-files nil \
		:restart-init-function nil \
		:restart-app-function  nil \
		:include-compiler nil)'

fact.dxl: fact.cl
	rm -f build.tmp
	rm -fr fact
	echo '(compile-file "fact")' >> build.tmp
	echo $(FACT_CMD) >> build.tmp
	echo '(exit 0)' >> build.tmp
	$(env) $(RUNLISP) -L build.tmp
	rm -f build.tmp

test: fact/ftest FORCE
	$(env) if test "`(cd fact; ./ftest 5)`" -eq 120; then \
		echo Test for lnkacl-unix completed successfully.; \
	else \
		echo "lnkacl test failed."; \
		exit 1; \
	fi

test2: fact/ftest FORCE
	$(env) cd fact; ./ftest 5

clean:	FORCE
	rm -f fact.fasl *.o *.out *.tmp
	rm -f ftest so_locations
	rm -fr fact

FORCE:
