# $Id: makefile,v 1.3 2003/11/11 05:32:00 layer Exp $
#
# On Windows, this makefile requires the use of GNU make from Redhat
# (http://sources.redhat.com/cygwin/).

# t for a debugging executable, nil for a production executable:
DEBUG = nil

# Change the following to `t' if you want a console app on windows, 
# one that behaves like a UNIX app and uses `stdout'.  Be aware, however,
# there multiprocessing issues with this method of running an application.
# If your application uses ACL multiprocessing, this is STRONGLY discouraged.
WINDOWS_CONSOLE_APP = nil

on_windows = $(shell if test -d "c:/"; then echo yes; else echo no; fi)

use_dcl = $(shell if test -f ../dcl.dxl; then echo yes; else echo no; fi)

ifeq ($(use_dcl),yes)
mlisp = ../lisp -I dcl
endif

ifndef mlisp
ifeq ($(on_windows),yes)
acldir = /cygdrive/c/Program Files/acl70
mlisp = "$(acldir)/mlisp.exe" +B +cn
else
acldir = /usr/local/acl70
mlisp = $(acldir)/mlisp
endif
endif

all:	clean build

build:	FORCE
	rm -fr dist build.tmp
	echo '(setq *debug-testapp* $(DEBUG))' >> build.tmp
	echo '(setq *console-app* $(WINDOWS_CONSOLE_APP))' >> build.tmp
	cat deliver.cl >> build.tmp
# -batch must come before -L, since arguments are evaluated from left to right
	$(mlisp) -batch -L build.tmp -kill

install: FORCE
ifeq ($(DEBUG),t)
	@echo 'Do not install a debug version!'
	exit 1
else
ifeq ($(on_windows),yes)
	cp -p dist/*.* c:/bin
else
	rm -fr /usr/local/testapp
	mkdir /usr/local/testapp
	cp -p dist/* /usr/local/testapp
	rm -f /usr/local/bin/testapp
	ln -s /usr/local/testapp/testapp /usr/local/bin/testapp
endif
endif

echo_dist_files: FORCE
	@echo deliver.cl makefile readme.txt test.cl

clean: FORCE
	rm -fr *.fasl *.tmp *.out *.in dist

FORCE:
