# Makefile for installing CLISP

# -------------- Start of configurable section --------------------

# Linking sets to be installed:
linkingsets = base full

# Directories used by "make install":
# Common base directory for not architecture dependent files.
prefix = /usr/local
# Common base directory for architecture dependent files.
exec_prefix = $(prefix)
# Directory where executables are installed.
bindir = $(exec_prefix)/bin
# Directory where manual pages are installed.
mandir = $(exec_prefix)/man
# Directory where manual pages in HTML format are installed.
htmldir = $(exec_prefix)/share/html
# Directory where manual pages in DVI format are installed.
dvidir = $(exec_prefix)/share/dvi
# Directory where documentation is installed.
docdir = $(exec_prefix)/doc
lispdocdir = $(docdir)/clisp
libdir = $(exec_prefix)/lib
lisplibdir = $(libdir)/clisp
# If you have $(exec_prefix) different from $(prefix), and indend to use
# different versions of CLISP on different architectures, replace the
# following line with:  datadir = $(exec_prefix)/share
datadir = $(prefix)/share
localedir = $(datadir)/locale

# Programs used by "make":
CC = cc
CFLAGS = -O

# Programs used by "make install":
INSTALL = cp
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL)

# -------------- End of configurable section --------------------

SHELL = /bin/sh

all : base/lisp.run full/lisp.run

base/lisp.run :  base/modules.o base/lisp.a base/libavcall.a base/libcallback.a base/libnoreadline.a base/libreadline.a base/libintl.a base/libiconv.a base/libsigsegv.a
	$(CC) $(CFLAGS)  base/modules.o base/lisp.a base/libsigsegv.a base/libiconv.a base/libintl.a base/libreadline.a base/libavcall.a base/libcallback.a -ltermcap -ldl -o base/lisp.run

full/lisp.run :  full/modules.o full/lisp.a full/libavcall.a full/libcallback.a full/libnoreadline.a full/libreadline.a full/libintl.a full/libiconv.a full/libsigsegv.a full/wildcard.o full/fnmatch.o full/wildcard.dvi full/regexp.o full/regexi.o full/regex.o full/regexp.dvi full/clx.o full/clx-preload.lsp full/clx.lsp full/clx.fas full/image.lsp full/image.fas full/linux.o
	$(CC) $(CFLAGS)  full/modules.o full/linux.o -lm full/clx.o -L/usr/X11R6/lib -lXpm -lXext -lSM -lICE -lX11 full/regexp.o full/regexi.o full/regex.o full/wildcard.o full/fnmatch.o full/lisp.a full/libsigsegv.a full/libiconv.a full/libintl.a full/libreadline.a full/libavcall.a full/libcallback.a -ltermcap -ldl -o full/lisp.run

install : install-bin install-man install-doc

install-bin : all force
	if [ ! -d $(prefix) ] ; then mkdir $(prefix) ; fi
	if [ ! -d $(exec_prefix) ] ; then mkdir $(exec_prefix) ; fi
	if [ ! -d $(libdir) ] ; then mkdir $(libdir) ; fi
	if [ ! -d $(lisplibdir) ] ; then mkdir $(lisplibdir) ; fi
	tar cf - data | (cd $(lisplibdir) && tar xf -)
	(cd $(lisplibdir) && rm -rf $(linkingsets))
	tar cf - clisp-link linkkit | (cd $(lisplibdir) && tar xf -)
	tar cf - $(linkingsets) | (cd $(lisplibdir) && tar xf -)
	if [ ! -d $(datadir) ] ; then mkdir $(datadir) ; fi
	if [ ! -d $(localedir) ] ; then mkdir $(localedir) ; fi
	(cd locale && tar cf - .) | (cd $(localedir) && tar xf -)
	if [ ! -d $(bindir) ] ; then mkdir $(bindir) ; fi
	$(CC) $(CFLAGS) -DLISPLIBDIR='"$(lisplibdir)"' -DLOCALEDIR='"$(localedir)"' src/clisp.c -o $(bindir)/clisp

install-man : doc/clisp.1 doc/clisp.html doc/clreadline.3 doc/clreadline.html doc/clreadline.dvi force
	if [ ! -d $(prefix) ] ; then mkdir $(prefix) ; fi
	if [ ! -d $(exec_prefix) ] ; then mkdir $(exec_prefix) ; fi
	if [ ! -d $(mandir) ] ; then mkdir $(mandir) ; fi
	if [ ! -d $(mandir)/man1 ] ; then mkdir $(mandir)/man1 ; fi
	if [ ! -d $(exec_prefix)/share ] ; then mkdir $(exec_prefix)/share ; fi
	if [ ! -d $(htmldir) ] ; then mkdir $(htmldir) ; fi
	if [ ! -d $(dvidir) ] ; then mkdir $(dvidir) ; fi
	$(INSTALL_DATA) doc/clisp.1 $(mandir)/man1/clisp.1
	$(INSTALL_DATA) doc/clisp.html $(htmldir)/clisp.html
	test ! -f doc/clisp.dvi || $(INSTALL_DATA) doc/clisp.dvi $(dvidir)/clisp.dvi
	if [ ! -d $(mandir)/man3 ] ; then mkdir $(mandir)/man3 ; fi
	$(INSTALL_DATA) doc/clreadline.3 $(mandir)/man3/clreadline.3
	$(INSTALL_DATA) doc/clreadline.html $(htmldir)/clreadline.html
	$(INSTALL_DATA) doc/clreadline.dvi $(dvidir)/clreadline.dvi

install-doc : force
	if [ ! -d $(prefix) ] ; then mkdir $(prefix) ; fi
	if [ ! -d $(exec_prefix) ] ; then mkdir $(exec_prefix) ; fi
	if [ ! -d $(docdir) ] ; then mkdir $(docdir) ; fi
	if [ ! -d $(lispdocdir) ] ; then mkdir $(lispdocdir) ; fi
	tar cf - ANNOUNCE COPYRIGHT GNU-GPL SUMMARY NEWS README README.de README.es MAGIC.add doc | (cd $(lispdocdir) && tar xf -)

force:

