Skip to content
Makefile.in 20.5 KiB
Newer Older
#
#  Makefile for MKCL
#
#  Copyright (c) 2010-2014, Jean-Claude Beaudoin.
#  Copyright by a number of previous anonymous authors
#            presumed to be the same as for the rest of MKCL.
#
#  MKCL is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public
#  License as published by the Free Software Foundation; either
#  version 3 of the License, or (at your option) any later version.
#
#  See file '../Copyright' for full details.
#
#
top_srcdir= @top_srcdir@
srcdir	= @srcdir@

# Programs used by "make":
#

@SET_MAKE@
CC	= @MKCL_CC@
LIBS	= @TCP_LIBS@ @LIBS@
LDFLAGS	= @LDFLAGS@
RM	= @RM@
LN_S	= @LN_S@
EXE	= @EXEEXT@

# ==================== Where To Install Things ====================

# The default location for installation.  Everything is placed in
# subdirectories of this directory.  The default values for many of
# the variables below are expressed in terms of this one, so you may
# not need to change them.  This defaults to /usr/local.
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@/
libdir=@libdir@/
includedir=@includedir@/
mkcldir=@mkcldir@/
localmkcldir=./lib/@PACKAGE_NAME@-@PACKAGE_VERSION@/

# Programs used by "make install":
#
SHELL = @SHELL@
INSTALL	= @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_LIBRARY = $(INSTALL_SCRIPT)
INSTALL_DATA = @INSTALL_DATA@
mkinstalldirs = $(SHELL) ./gc/mkinstalldirs

# Files

SUBDIRS = @SUBDIRS@
LIBRARIES = @LIBRARIES@
LSP_LIBRARIES = @LSP_LIBRARIES@
TARGETS = @TARGETS@

MKCL_HFILES = mkcl/config.h \
              mkcl/list.h \
              mkcl/external.h \
              mkcl/internal.h \
              mkcl/mkcl-fenv.h \
              mkcl/mkcl-gc.h \
              mkcl/mkcl-inl.h \
              mkcl/mkcl-math.h \
              mkcl/number.h \
              mkcl/object.h \
              mkcl/stacks.h

ASDF2_FASLS = asdf2.fasb ../contrib/asdf2-bundle/asdf2-bundle.fas
ASDF_FASLS = asdf.fasb

CONTRIB_FASLS = \
                bytecmp.fasb \
                defsystem.fasb \
                profile.fasb \
                rt.fasb \
                serve-event.fasb \
                sockets.fasb \
                walker.fasb \
                trivial-features.fasb \
                trivial-garbage.fasb \
                alexandria.fasb \
                babel.fasb \
                cffi.fasb \
                fiveam.fasb \
                bordeaux-threads.fasb \
		uiop.fasb
CONTRIB_STATIC_LIBS = asdf.a asdf2.a $(CONTRIB_FASLS:%.fasb=%.a)

BUILTINS = asdf profile rt serve-event sockets

MKCL_STATIC_PARTS = mkcltop.@LIBEXT@ lsp.a mkclmin.@LIBEXT@
all: bin/mkcl-config $(TARGETS) $(ASDF_FASLS) $(ASDF2_FASLS) $(CONTRIB_FASLS) help.doc
.PHONY:	all

Makefile: Makefile.in config.status
	./config.status

mkcl/config.h: mkcl/config.h.in config.status
	./config.status
	touch mkcl/config.h


bin/mkcl-small$(EXE) lsp.a $(LSP_LIBRARIES) encodings: compile.lsp lsp/config.lsp cmp/cmpdefs.lsp lsp/*.lsp clos/*.lsp cmp/*.lsp mkcl/mkcl-cmp.h mkcl/config.h BUILD-STAMP mkcl_min$(EXE) mkcltop.@LIBEXT@
	for i in $(LSP_LIBRARIES) ; do \
	  if test -s $$i ; then \
	    case $$i in \
	      *.dll) $(INSTALL_LIBRARY) $$i ./bin/ ;; \
	      *) ;; \
	    esac \
	  fi \
	done


ext-dir-exists:
	mkdir ./ext
	touch ext-dir-exists

asdf-stage-dir-exists:
	mkdir ./asdf-stage
	touch asdf-stage-dir-exists

asdf2.fasb asdf2.a: bin/mkcl-small$(EXE) ext-dir-exists build-asdf2.lsp cmp.fasb compile-utils.lsp ../contrib/asdf2/*.lisp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf2.lsp

asdf.fasb asdf.a: bin/mkcl-small$(EXE) ext-dir-exists build-asdf.lsp cmp.fasb compile-utils.lsp ../contrib/asdf/*.lisp
	(cd ../contrib/asdf/; $(MAKE) build/asdf.lisp)
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf.lsp
uiop.fasb uiop.a: bin/mkcl-small$(EXE) asdf-stage-dir-exists build-uiop.lsp cmp.fasb compile-utils.lsp asdf.fasb ../contrib/asdf/uiop/*.lisp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-uiop.lsp
	cp ./asdf-stage/asdf/uiop/uiop.fasb .
	cp ./asdf-stage/asdf/uiop/uiop.a .
	cp ./asdf-stage/asdf/uiop/uiop.asd .

bytecmp.fasb bytecmp.a: bin/mkcl-small$(EXE) ext-dir-exists build-bytecmp.lsp cmp.fasb compile-utils.lsp ../contrib/bytecmp/bytecmp.lsp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-bytecmp.lsp
defsystem.fasb defsystem.a: bin/mkcl-small$(EXE) ext-dir-exists build-defsystem.lsp cmp.fasb compile-utils.lsp ../contrib/defsystem/defsystem.lisp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-defsystem.lsp
profile.fasb profile.a: bin/mkcl-small$(EXE) ext-dir-exists build-profile.lsp cmp.fasb compile-utils.lsp ../contrib/profile/profile.lisp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-profile.lsp

../contrib/sockets/package.lisp: ../contrib/sockets/sockets.lisp
	touch ../contrib/sockets/package.lisp

sockets.fasb sockets.a: bin/mkcl-small$(EXE) ext-dir-exists build-sockets.lsp cmp.fasb compile-utils.lsp ../contrib/sockets/*.lisp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-sockets.lsp
serve-event.fasb serve-event.a: bin/mkcl-small$(EXE) ext-dir-exists build-serve-event.lsp cmp.fasb compile-utils.lsp ../contrib/serve-event/serve-event.lisp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-serve-event.lsp
walker.fasb walker.a: bin/mkcl-small$(EXE) ext-dir-exists build-walker.lsp cmp.fasb compile-utils.lsp ../contrib/walker/walk.lsp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-walker.lsp
../contrib/asdf2-bundle/asdf2-bundle.fas: bin/mkcl-small$(EXE) build-asdf2-bundle.lsp cmp.fasb compile-utils.lsp asdf2.fasb ../contrib/asdf2-bundle/*.lisp
	if [ "$${LOCALAPPDATA}" ]; then (cd "$${LOCALAPPDATA}"; rm -rf ./common-lisp/cache/mkcl-*); elif [ "$${APPDATA}" ]; then (cd "$${APPDATA}"; rm -rf ./common-lisp/cache/mkcl-*); else rm -rf $$HOME/.cache/common-lisp/mkcl-*/$$(cd ..;pwd -P)/contrib/asdf2-bundle; fi
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf2-bundle.lsp
trivial-features.fasb trivial-features.a: bin/mkcl-small$(EXE) asdf-stage-dir-exists build-asdf-contrib*.lsp $(ASDF_FASLS) $(ASDF2_FASLS) ../contrib/trivial-features*/src/*.lisp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf-contrib.lsp -- trivial-features ../contrib/trivial-features*/
	cp ./asdf-stage/trivial-features*/trivial-features.fasb .
	cp ./asdf-stage/trivial-features*/trivial-features.a .
	cp ./asdf-stage/trivial-features*/trivial-features.asd .
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf-contrib-as2.lsp -- trivial-features ../contrib/trivial-features*/
trivial-garbage.fasb trivial-garbage.a: bin/mkcl-small$(EXE) asdf-stage-dir-exists build-asdf-contrib*.lsp $(ASDF_FASLS) $(ASDF2_FASLS) ../contrib/trivial-garbage*/*.lisp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf-contrib.lsp -- trivial-garbage ../contrib/trivial-garbage*/
	cp ./asdf-stage/trivial-garbage*/trivial-garbage.fasb .
	cp ./asdf-stage/trivial-garbage*/trivial-garbage.a .
	cp ./asdf-stage/trivial-garbage*/trivial-garbage.asd .
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf-contrib-as2.lsp -- trivial-garbage ../contrib/trivial-garbage*/
alexandria.fasb alexandria.a: bin/mkcl-small$(EXE) asdf-stage-dir-exists build-asdf-contrib*.lsp $(ASDF_FASLS) $(ASDF2_FASLS) ../contrib/alexandria*/*.lisp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf-contrib.lsp -- alexandria ../contrib/alexandria*/
	cp ./asdf-stage/alexandria*/alexandria.fasb .
	cp ./asdf-stage/alexandria*/alexandria.a .
	cp ./asdf-stage/alexandria*/alexandria.asd .
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf-contrib-as2.lsp -- alexandria ../contrib/alexandria*/

babel.fasb babel.a: bin/mkcl-small$(EXE) asdf-stage-dir-exists build-asdf-contrib*.lsp $(ASDF_FASLS) $(ASDF2_FASLS) trivial-features.fasb alexandria.fasb ../contrib/babel*/src/*.lisp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf-contrib.lsp -- babel ../contrib/babel*/
	cp ./asdf-stage/babel*/babel.fasb .
	cp ./asdf-stage/babel*/babel.a .
	cp ./asdf-stage/babel*/babel.asd .
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf-contrib-as2.lsp -- babel ../contrib/babel*/
cffi.fasb cffi.a: bin/mkcl-small$(EXE) asdf-stage-dir-exists build-asdf-contrib*.lsp $(ASDF_FASLS) $(ASDF2_FASLS) babel.fasb ../contrib/cffi*/src/*.lisp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf-contrib.lsp -- cffi ../contrib/cffi*/
	cp ./asdf-stage/cffi*/cffi.fasb .
	cp ./asdf-stage/cffi*/cffi.a .
	cp ./asdf-stage/cffi*/cffi.asd .
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf-contrib-as2.lsp -- cffi ../contrib/cffi*/

bordeaux-threads.fasb bordeaux-threads.a: bin/mkcl-small$(EXE) asdf-stage-dir-exists build-asdf-contrib*.lsp $(ASDF_FASLS) $(ASDF2_FASLS) alexandria.fasb ../contrib/bordeaux-threads-*/src/*.lisp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf-contrib.lsp -- bordeaux-threads ../contrib/bordeaux-threads-*/
	cp ./asdf-stage/bordeaux-threads*/bordeaux-threads.fasb .
	cp ./asdf-stage/bordeaux-threads*/bordeaux-threads.a .
	cp ./asdf-stage/bordeaux-threads*/bordeaux-threads.asd .
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf-contrib-as2.lsp -- bordeaux-threads ../contrib/bordeaux-threads-*/
fiveam.fasb fiveam.a: bin/mkcl-small$(EXE) asdf-stage-dir-exists build-asdf-contrib*.lsp $(ASDF_FASLS) $(ASDF2_FASLS) alexandria.fasb ../contrib/fiveam-*/src/*.lisp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf-contrib.lsp -- fiveam ../contrib/fiveam-*/
	cp ./asdf-stage/fiveam*/src/fiveam.fasb .
	cp ./asdf-stage/fiveam*/src/fiveam.a .
	cp ./asdf-stage/fiveam*/src/fiveam.asd .
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf-contrib-as2.lsp -- fiveam ../contrib/fiveam-*/

rt.fasb rt.a: bin/mkcl-small$(EXE) asdf-stage-dir-exists build-asdf-contrib*.lsp $(ASDF_FASLS) $(ASDF2_FASLS) babel.fasb ../contrib/rt*/*.lisp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf-contrib.lsp -- rt ../contrib/rt*/
	cp ./asdf-stage/rt*/rt.fasb .
	cp ./asdf-stage/rt*/rt.a .
	cp ./asdf-stage/rt*/rt.asd .
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-asdf-contrib-as2.lsp -- rt ../contrib/rt*/

cmp.fasb cmp.a: bin/mkcl-small$(EXE) cmp/*.lsp build-cmp.lsp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-cmp.lsp

bin/mkcl-dyn: bin/mkcl-small$(EXE) cmp.fasb build-dynamic-mkcl.lsp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-dynamic-mkcl.lsp

bin/mkcl$(EXE): bin/mkcl-small$(EXE) cmp.fasb build-mkcl.lsp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-mkcl.lsp

ifeq (@thehost@,mingw32)
bin/mkcl-full$(EXE): bin/mkcl-small$(EXE) build-full-mkcl.lsp $(BUILTINS:%=%.a)
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-full-mkcl.lsp -- $(BUILTINS:%=%.a)
else
bin/mkcl-full$(EXE): bin/mkcl-small$(EXE) build-full-mkcl.lsp $(BUILTINS)
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load build-full-mkcl.lsp -- $(BUILTINS)
help.doc: dump-doc.lsp bin/mkcl-small$(EXE) doc/help.lsp
	bin/mkcl-small$(EXE) -norc -q --external-format "(:ascii :lf)" -load dump-doc.lsp
mkcl_min$(EXE): $(LIBRARIES) mkclmin.@LIBEXT@ c/cinit.o c/all_symbols.o .gdbinit
	$(CC) $(LDFLAGS) -o $@ c/cinit.o c/all_symbols.o mkclmin.@LIBEXT@ $(LIBRARIES) $(LIBS)


.gdbinit: util/gdbinit
	cp util/gdbinit $@

c/all_symbols.o: depend
	cd c; $(MAKE) all_symbols.o

lsp/config.lsp: lsp/config.pre
	sed -e 's,@mkcldir\\@,$(mkcldir),g' < lsp/config.pre > lsp/config.lsp

lsp/config.pre: lsp/config.lsp.in config.status
	./config.status

cmp/cmpdefs.lsp: cmp/cmpdefs.pre
	sed -e 's,@mkcldir\\@,"$(mkcldir)",g' \
	    -e 's,@libdir\\@,"$(libdir)",g' \
	    -e 's,@includedir\\@,"$(includedir)",g' < cmp/cmpdefs.pre > $@

cmp/cmpdefs.pre: cmp/cmpdefs.lsp.in config.status
	./config.status

compile.lsp: compile.pre bare.lsp lsp/load.lsp clos/load.lsp cmp/load.lsp
	sed -e 's,@mkcldir\\@,$(mkcldir),g' \
	    -e 's,@libdir\\@,$(libdir),g' < compile.pre > compile.lsp

compile.pre: compile.lsp.in config.status
bare.lsp: bare.lsp.in config.status
lsp/load.lsp: lsp/load.lsp.in config.status
clos/load.lsp: clos/load.lsp.in config.status
cmp/load.lsp: cmp/load.lsp.in config.status
	./config.status

bin/mkcl-config: bin/mkcl-config.pre
	sed -e 's,@libdir\\@,$(libdir),' \
	    -e 's,@includedir\\@,$(includedir),' bin/mkcl-config.pre > bin/mkcl-config

bin/mkcl-config.pre: util/mkcl-config config.status
mkclmin.@LIBEXT@: depend c/*.d mkcl/*.h c/arch/*.d
	cd c; $(MAKE) ../mkclmin.@LIBEXT@
mkcltop.@LIBEXT@: depend c/main.d c/all_symbols.d c/symbols_list.h
	cd c; $(MAKE) ../mkcltop.@LIBEXT@

gc/.libs/@LIBPREFIX@gc.@LIBEXT@:
	cd gc; $(MAKE)

mkclgc.@LIBEXT@: gc/.libs/@LIBPREFIX@gc.@LIBEXT@
	cp -p gc/.libs/@LIBPREFIX@gc.@LIBEXT@ ./mkclgc.@LIBEXT@
	mkdir -p mkcl/gc
	cp -p gc/include/*.h mkcl/gc


mkcl/mkcl-cmp.h: mkcl/mkcl.h c/symbols_list.h
	touch $@

mkcl/mkcl.h: $(MKCL_HFILES)
	touch $@

mkcl/config-install.h: mkcl/config.h
	sed '/-CUT-/,$$d' ./mkcl/config.h > ./mkcl/config-install.h


BUILD-STAMP: config.status
	echo "#" `uname -a` > $@
	head -8 config.log | tail -6 >> $@

install: install-base install-contribs
#	cd doc; $(MAKE) prefix=$(prefix) install

install-base: all mkcl/config-install.h
	$(mkinstalldirs) $(bindir) $(libdir) \
	  $(mkcldir) $(includedir) $(includedir)/mkcl
	$(INSTALL_DATA) ../Copyright ../LGPL $(mkcldir)
	$(INSTALL_DATA) ../Copyright ../LGPL $(includedir)/mkcl
	for i in $(TARGETS); do \
	  $(INSTALL_PROGRAM) $$i $(bindir); \
	done
	if [ -d encodings ]; then \
	  $(mkinstalldirs) $(mkcldir)/encodings; \
	  for i in ./encodings/*; do \
	    $(INSTALL_DATA) $$i $(mkcldir)/encodings; \
	  done \
	fi
	$(INSTALL_DATA) ./mkcl/*.h $(includedir)/mkcl
	if (echo $(SUBDIRS) | grep gc); then \
	  $(mkinstalldirs) $(includedir)/mkcl/gc; \
	  $(INSTALL_DATA) ./mkcl/gc/*.h $(includedir)/mkcl/gc; \
	fi
	rm $(includedir)/mkcl/config.h
	mv $(includedir)/mkcl/config-install.h $(includedir)/mkcl/config.h
	$(INSTALL_SCRIPT) bin/mkcl-config $(bindir)
	for i in BUILD-STAMP help.doc ; do \
	  $(INSTALL_DATA) $$i $(mkcldir); \
	done
	for i in $(LSP_LIBRARIES); do \
	  if test -s $$i ; then \
	    case $$i in \
	      *.dll) $(INSTALL_LIBRARY) $$i $(libdir); \
		     $(INSTALL_LIBRARY) $$i $(bindir);; \
	      *) $(INSTALL_LIBRARY) $$i $(libdir);; \
	    esac \
	  fi \
	done
	if [ "x@SONAME@" != "x" -a -f "@SONAME@" ]; then \
	  ( cd $(libdir) && rm -f @SONAME3@ @SONAME2@ @SONAME1@ && \
	    mv @SONAME@ @SONAME3@ && \
	    $(LN_S) @SONAME3@ @SONAME2@ && \
	    $(LN_S) @SONAME3@ @SONAME1@ && \
	    $(LN_S) @SONAME3@ @SONAME@ ) \
	fi
	for i in $(MKCL_STATIC_PARTS) $(LIBRARIES); do \
	  if test -s $$i ; then \
	    $(INSTALL_LIBRARY) $$i $(mkcldir); \
	  fi \
	done
	$(INSTALL_DATA) c/dpp$(EXE) $(mkcldir)
	$(INSTALL_DATA) mkcl_min$(EXE) $(mkcldir)
	$(INSTALL_DATA) cmp.asd $(mkcldir)
	if [ -f cmp.a ] ; then $(INSTALL_DATA) cmp.a $(mkcldir); fi
	$(INSTALL_PROGRAM) cmp.fasb $(mkcldir)

install-contribs: $(ASDF_FASLS) $(ASDF2_FASLS) $(CONTRIB_FASLS)
	$(mkinstalldirs) $(mkcldir)/contrib/
	for i in *.as2 *.asd; do $(INSTALL_DATA) $${i} $(mkcldir)/contrib/; done
	for i in asdf.fasb asdf2.fasb $(CONTRIB_FASLS) $(CONTRIB_STATIC_LIBS); do \
	  if test -s $$i; then \
	    case $$i in \
	      *.fasb) $(INSTALL_PROGRAM) $$i $(mkcldir)/contrib/;; \
	      *) $(INSTALL_DATA) $$i $(mkcldir)/contrib/;; \
	    esac; \
	  fi \
	done
	if [ -d ../contrib/asdf2-bundle ]; then \
	  (cd ../contrib/; tar cf - asdf2-bundle) | (cd $(mkcldir)/contrib/; tar xof -); \
	fi
	if [ -d ../contrib/slime ]; then \
	  (cd ../contrib/; tar cf - slime) | (cd $(mkcldir)/contrib/; tar xof -); \
	fi

install-local: install-base-local install-contribs-local

install-base-local: all mkcl/config-install.h
	$(mkinstalldirs) ./lib/ \
	  $(localmkcldir) ./include/ ./include//mkcl
	$(INSTALL_DATA) ../Copyright ../LGPL $(localmkcldir)
	$(INSTALL_DATA) ../Copyright ../LGPL ./include/mkcl
	if [ -d encodings ]; then \
	  $(mkinstalldirs) $(localmkcldir)/encodings; \
	  for i in ./encodings/*; do \
	    $(INSTALL_DATA) $$i $(localmkcldir)/encodings; \
	  done \
	fi
	$(INSTALL_DATA) ./mkcl/*.h ./include//mkcl
	if (echo $(SUBDIRS) | grep gc); then \
	  $(mkinstalldirs) ./include//mkcl/gc; \
	  $(INSTALL_DATA) ./mkcl/gc/*.h ./include//mkcl/gc; \
	fi
	rm ./include//mkcl/config.h
	mv ./include//mkcl/config-install.h ./include//mkcl/config.h
	for i in BUILD-STAMP help.doc ; do \
	  $(INSTALL_DATA) $$i $(localmkcldir); \
	done
	for i in $(LSP_LIBRARIES); do \
	  if test -s $$i ; then \
	    case $$i in \
	      *.dll) $(INSTALL_LIBRARY) $$i ./lib/; \
		     $(INSTALL_LIBRARY) $$i ./bin/;; \
	      *) $(INSTALL_LIBRARY) $$i ./lib/;; \
	    esac \
	  fi \
	done
	if [ "x@SONAME@" != "x" -a -f "@SONAME@" ]; then \
	  ( cd ./lib/ && rm -f @SONAME3@ @SONAME2@ @SONAME1@ && \
	    mv @SONAME@ @SONAME3@ && \
	    $(LN_S) @SONAME3@ @SONAME2@ && \
	    $(LN_S) @SONAME3@ @SONAME1@ && \
	    $(LN_S) @SONAME3@ @SONAME@ ) \
	fi
	for i in $(MKCL_STATIC_PARTS) $(LIBRARIES); do \
	  if test -s $$i ; then \
	    $(INSTALL_LIBRARY) $$i $(localmkcldir); \
	  fi \
	done
	$(INSTALL_DATA) c/dpp$(EXE) $(localmkcldir)
	$(INSTALL_DATA) mkcl_min$(EXE) $(localmkcldir)
	$(INSTALL_DATA) cmp.asd $(localmkcldir)
	if [ -f cmp.a ] ; then $(INSTALL_DATA) cmp.a $(localmkcldir); fi
	$(INSTALL_PROGRAM) cmp.fasb $(localmkcldir)

install-contribs-local: $(ASDF_FASLS) $(ASDF2_FASLS) $(CONTRIB_FASLS)
	$(mkinstalldirs) $(localmkcldir)/contrib/
	for i in *.as2 *.asd; do $(INSTALL_DATA) $${i} $(localmkcldir)/contrib/; done
	for i in asdf.fasb asdf2.fasb $(CONTRIB_FASLS) $(CONTRIB_STATIC_LIBS); do \
	  if test -s $$i; then \
	    case $$i in \
	      *.fasb) $(INSTALL_PROGRAM) $$i $(localmkcldir)/contrib/;; \
	      *) $(INSTALL_DATA) $$i $(localmkcldir)/contrib/;; \
	    esac; \
	  fi \
	done
	cp -pR ../contrib/asdf2-bundle $(localmkcldir)/contrib/


uninstall:
	for i in $(TARGETS) mkcl-config; do $(RM) $(bindir)/$$i; done
	$(RM) -r $(includedir)/mkcl $(mkcldir)
	for i in $(LSP_LIBRARIES); do \
	  case $$i in \
	    *.dll) $(RM) $(libdir)/$$i || : ; $(RM) $(bindir)/$$i || : ;;
	    *) $(RM) $(libdir)/$$i || : ;; \
	  esac \
	done
#	cd doc; $(MAKE) uninstall

doc: $(TARGETS)
	cd doc; $(MAKE)

clean: clean_lisp clean_contribs
	cd c; $(MAKE) clean
	$(RM) compile.lsp bin/mkcl-config BUILD-STAMP mkcl/config-install.h
	$(RM) mkcl_min$(EXE) bin/mkcl$(EXE) bin/mkcl-dyn bin/mkcl-small$(EXE) bin/mkcl-full$(EXE)
	$(RM) MKCLINIT* bin/MKCLINIT*
	$(RM) MKC*.c MKC*.tmp bin/MKC*.c bin/MKC*.tmp
	$(RM) mkcl/gc/*.h ./mkclgc.@LIBEXT@
	$(RM) *.dll bin/*.dll
	$(RM) *.o *.a *.la *.so *.data *.fasb *.fas core core.* a.out
	cd bin; $(RM) *.o *.a *.la *.so *.data *.fasb *.fas core core.* a.out
	$(RM) -r lib include

clean_contribs:
	$(RM) -r ext ext-dir-exists asdf-stage asdf-stage-dir-exists
	cd ../contrib; sh ./clean_up.sh
	$(RM) asdf.fasb asdf2.fasb $(CONTRIB_FASLS) $(CONTRIB_FASLS:%.fasb=%.asd) $(CONTRIB_FASLS:%.fasb=%.as2)

clean_lisp:
	for i in lsp cmp clos; \
	do $(RM) $$i.{a,fasb,asd,as2} $$i/?*.{o,data,c,sdat,h,fasb,fas}; done
	$(RM) lsp/config.lsp cmp/cmpdefs.lsp

distclean: clean
	cd c; $(MAKE) distclean
	$(RM) bin/mkcl-config.pre
	$(RM) Makefile bare.lsp compile.pre
	$(RM) doc/Makefile doc/mkcl.man doc/mkcl-config.man
	$(RM) mkcl/config.h mkcl/configpre.h
	$(RM) lsp/config.pre lsp/load.lsp clos/load.lsp
	$(RM) cmp/cmpdefs.pre cmp/load.lsp
	(cd gc; $(MAKE) distclean)
	$(RM) config.status config.version config.log config.cache

realclean: distclean
	cd c; $(MAKE) realclean
	$(RM) *~

TAGS: lsp/*.lsp lsp/config.pre clos/*.lsp cmp/*.lsp cmp/cmpdefs.pre c/*.d c/*.h c/arch/*.d mkcl/*.h
	if type etags >/dev/null 2>&1; then  \
	  if etags --help | grep -q -e "--language-force"; then \
	    etags -R lsp/*.lsp lsp/config.pre clos/*.lsp cmp/*.lsp cmp/cmpdefs.pre --language-force=c c/*.d c/*.h c/arch/*.d mkcl/*.h; \
	  else \
	    etags -R lsp/*.lsp lsp/config.pre clos/*.lsp cmp/*.lsp cmp/cmpdefs.pre --language=c c/*.d c/*.h c/arch/*.d mkcl/*.h; \
	  fi \
	else touch TAGS; fi