### -*-makefile-*-
###
-### Building the distribution
+### Build script for `runlisp'
###
-### (c) 1997 Mark Wooding
+### (c) 2020 Mark Wooding
###
###----- Licensing notice ---------------------------------------------------
###
-### This file is part of the Common Files Distribution (`common')
+### This file is part of Runlisp, a tool for invoking Common Lisp scripts.
###
-### `Common' is free software; you can redistribute it and/or modify
-### it under the terms of the GNU General Public License as published by
-### the Free Software Foundation; either version 2 of the License, or
-### (at your option) any later version.
+### Runlisp is free software: you can redistribute it and/or modify it
+### under the terms of the GNU General Public License as published by the
+### Free Software Foundation; either version 3 of the License, or (at your
+### option) any later version.
###
-### `Common' is distributed in the hope that it will be useful,
-### but WITHOUT ANY WARRANTY; without even the implied warranty of
-### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-### GNU General Public License for more details.
+### Runlisp is distributed in the hope that it will be useful, but WITHOUT
+### ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+### FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+### for more details.
###
### You should have received a copy of the GNU General Public License
-### along with `common'; if not, write to the Free Software Foundation,
-### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+### along with Runlisp. If not, see <https://www.gnu.org/licenses/>.
-bin_SCRIPTS =
-pkgdata_SCRIPTS =
-dist_pkgdata_SCRIPTS =
-pkgdata_DATA =
-dist_pkgdata_DATA =
+include $(top_srcdir)/vars.am
-EXTRA_DIST =
-CLEANFILES =
+SUBDIRS =
-###--------------------------------------------------------------------------
-### Handy variables.
+image_DATA =
+image_SCRIPTS =
-confsubst = $(srcdir)/confsubst.in
-mkdir_p = $(srcdir)/config/install-sh -d
+SUBDIRS += .
-V_SUBST = $(V_SUBST_$(V))
-V_SUBST_ = $(V_SUBST_$(AM_DEFAULT_VERBOSITY))
-V_SUBST_0 = @echo " SUBST $@";
-SUBST = $(V_SUBST)$(confsubst)
+ACLOCAL_AMFLAGS = -Im4
###--------------------------------------------------------------------------
-### Main scripts.
-
-## mklinks
-bin_SCRIPTS += mklinks
-CLEANFILES += mklinks
-EXTRA_DIST += mklinks.in
-
-mklinks: mklinks.in Makefile
- $(SUBST) $(srcdir)/mklinks.in >$@.new \
- pkgdatadir=$(pkgdatadir) VERSION=$(VERSION)
- $(AM_V_at)chmod +x $@.new
- $(AM_V_at)mv $@.new $@
-
-## findlinks
-bin_SCRIPTS += findlinks
-CLEANFILES += findlinks
-EXTRA_DIST += findlinks.in
-
-findlinks: findlinks.in Makefile
- $(SUBST) $(srcdir)/findlinks.in >$@.new \
- pkgdatadir=$(pkgdatadir) VERSION=$(VERSION)
- $(AM_V_at)chmod +x $@.new
- $(AM_V_at)mv $@.new $@
-
-## mdw-setup
-bin_SCRIPTS += mdw-setup
-EXTRA_DIST += mdw-setup
+### A library of common code.
-###--------------------------------------------------------------------------
-### Files to install.
+noinst_LIBRARIES += librunlisp.a
+librunlisp_a_SOURCES =
-## Licences.
-dist_pkgdata_DATA += GPL-1 GPL-2 GPL-3
-dist_pkgdata_DATA += LGPL-2 LGPL-2.1 LGPL-3
-dist_pkgdata_DATA += AGPL-3
-dist_pkgdata_DATA += gpl.tex lgpl.tex gpl.texi lgpl.texi
+librunlisp_a_SOURCES += common.c common.h
+librunlisp_a_SOURCES += lib.c lib.h
+librunlisp_a_SOURCES += mdwopt.c mdwopt.h
+librunlisp_a_SOURCES += sha256.c sha256.h
-install-data-hook::
- cd $(DESTDIR)$(pkgdatadir) && $(LN_S) -f GPL-2 COPYING
- cd $(DESTDIR)$(pkgdatadir) && $(LN_S) -f LGPL-2 COPYING.LIB
-
-## Documentation.
-dist_pkgdata_DATA += INSTALL
-dist_pkgdata_DATA += texinice.tex
+###--------------------------------------------------------------------------
+### The main driver program.
-## Useful code.
-dist_pkgdata_DATA += mdwopt.c mdwopt.h
-dist_pkgdata_DATA += getdate.y getdate.h
+bin_PROGRAMS += runlisp
+runlisp_SOURCES = runlisp.c
+runlisp_LDADD = librunlisp.a
+man_MANS += runlisp.1
+doc_DATA += runlisp.pdf
+EXTRA_DIST += runlisp.1.in
-## Scripts.
-dist_pkgdata_SCRIPTS += install-ac
-dist_pkgdata_SCRIPTS += maninst
+###--------------------------------------------------------------------------
+### Additional machinery.
-## Python support stuff.
-dist_pkgdata_DATA += mdwsetup.py
-dist_pkgdata_DATA += pysetup.mk
+pkgdata_DATA += eval.lisp
+EXTRA_DIST += eval.lisp
-## confsubst
-pkgdata_SCRIPTS += confsubst
-CLEANFILES += confsubst
-EXTRA_DIST += confsubst.in
+pkgdata_SCRIPTS += dump-ecl
+EXTRA_DIST += dump-ecl
-confsubst: confsubst.in Makefile
- $(SUBST) $(srcdir)/confsubst.in >$@.new VERSION=$(VERSION)
- $(AM_V_at)chmod +x $@.new
- $(AM_V_at)mv $@.new $@
+bin_PROGRAMS += query-runlisp-config
+query_runlisp_config_SOURCES = query-runlisp-config.c
+query_runlisp_config_LDADD = librunlisp.a
+man_MANS += query-runlisp-config.1
+doc_DATA += query-runlisp-config.pdf
+EXTRA_DIST += query-runlisp-config.1.in
-## auto-version
-pkgdata_SCRIPTS += auto-version
-CLEANFILES += auto-version
-EXTRA_DIST += auto-version.in
+man_MANS += runlisp.conf.5
+doc_DATA += runlisp.conf.pdf
+EXTRA_DIST += runlisp.conf.5.in
-auto-version: auto-version.in Makefile
- $(SUBST) $(srcdir)/auto-version.in >$@.new VERSION=$(VERSION)
- $(AM_V_at)chmod +x $@.new
- $(AM_V_at)mv $@.new $@
+EXTRA_DIST += runlisp-base.conf
+install-data-hook::
+ $(MKDIR_P) $(DESTDIR)$(pkgconfdir)/runlisp.d
+ cp $(srcdir)/runlisp-base.conf \
+ $(DESTDIR)$(pkgconfdir)/runlisp.d/0base.conf
+uninstall-hook::
+ rm -f $(DESTDIR)$(pkgconfdir)/runlisp.d/0base.conf
-## Testsuites.
-dist_pkgdata_DATA += autotest.am
-dist_pkgdata_DATA += testsuite.at
+EXTRA_DIST += runlisp.conf
+install-data-hook::
+ $(MKDIR_P) $(DESTDIR)$(pkgconfdir)
+ if ! [ -f $(DESTDIR)$(pkgconfdir)/runlisp.conf ]; then \
+ cp $(srcdir)/runlisp.conf $(DESTDIR)$(pkgconfdir)/; \
+ fi
+uninstall-hook::
+ rm -f $(DESTDIR)$(pkgconfdir)/runlisp.conf
-## Autoconf snippets.
-EXTRA_DIST += aclocal.glob
+###--------------------------------------------------------------------------
+### Image dumping.
+
+bin_PROGRAMS += dump-runlisp-image
+dump_runlisp_image_SOURCES = dump-runlisp-image.c
+dump_runlisp_image_LDADD = librunlisp.a
+man_MANS += dump-runlisp-image.1
+doc_DATA += dump-runlisp-image.pdf
+EXTRA_DIST += dump-runlisp-image.1.in
+
+DUMP_RUNLISP_IMAGE = $(v_dump)\
+ ASDF_OUTPUT_TRANSLATIONS='( \
+ :output-translations \
+ :ignore-inherited-configuration \
+ (t ("$(abs_builddir)/" "fasl/" \
+ :implementation-type :**/ :*.*.*)))' \
+ ./dump-runlisp-image -f -O$@ \
+ -c$(srcdir)/runlisp-base.conf \
+ -odata-dir=$(srcdir)
+clean-local::; rm -fr fasl
+
+v_dump = $(v_dump_@AM_V@)
+v_dump_ = $(v_dump_@AM_DEFAULT_V@)
+v_dump_0 = @echo " DUMP $@";
+
+IMAGES =
+noinst_DATA += $(IMAGES)
+
+if DUMP_SBCL
+IMAGES += sbcl+asdf.core
+CLEANFILES += sbcl+asdf.core sbcl+asdf.core-*
+sbcl+asdf.core: dump-runlisp-image runlisp-base.conf
+ $(DUMP_RUNLISP_IMAGE) sbcl
+endif
+
+if DUMP_CCL
+IMAGES += ccl+asdf.image
+CLEANFILES += ccl+asdf.image ccl+asdf.image-*
+ccl+asdf.image: dump-runlisp-image runlisp-base.conf
+ $(DUMP_RUNLISP_IMAGE) ccl
+endif
+
+if DUMP_CLISP
+IMAGES += clisp+asdf.mem
+CLEANFILES += clisp+asdf.mem clisp+asdf.mem-*
+clisp+asdf.mem: dump-runlisp-image runlisp-base.conf
+ $(DUMP_RUNLISP_IMAGE) clisp
+endif
+
+if DUMP_ECL
+IMAGES += ecl+asdf
+CLEANFILES += ecl+asdf ecl+asdf-*
+ecl+asdf: dump-runlisp-image runlisp-base.conf dump-ecl
+ $(DUMP_RUNLISP_IMAGE) -odata-dir=$(srcdir) ecl
+endif
+
+if DUMP_CMUCL
+IMAGES += cmucl+asdf.core
+CLEANFILES += cmucl+asdf.core cmucl+asdf.core-*
+cmucl+asdf.core: dump-runlisp-image runlisp-base.conf
+ $(DUMP_RUNLISP_IMAGE) cmucl
+endif
install-data-hook::
- $(mkdir_p) $(DESTDIR)$(aclocaldir)
- $(srcdir)/install-ac install \
- $(srcdir)/aclocal.glob $(DESTDIR)$(aclocaldir)
+ mkdir -p $(DESTDIR)$(imagedir)
+ set -e; for i in $(IMAGES); do \
+ j=$$(readlink $$i); \
+ cp $$j $(DESTDIR)$(imagedir)/$$j.new && \
+ mv $(DESTDIR)$(imagedir)/$$j.new \
+ $(DESTDIR)$(imagedir)/$$j; \
+ ln -sf $$j $(DESTDIR)$(imagedir)/$$i; \
+ done
uninstall-hook::
- $(srcdir)/install-ac rm \
- $(srcdir)/aclocal.glob $(DESTDIR)$(aclocaldir)
+ set -e; for i in $(IMAGES); do \
+ if j=$$(readlink $(DESTDIR)$(imagedir)/$$i); then \
+ case $$j in \
+ $$i-*[!0-9a-f]) ;; \
+ $$i-*) rm -f $(DESTDIR)$(imagedir)/$$j ;; \
+ esac; \
+ fi; \
+ rm -f $(DESTDIR)$(imagedir)/$$i; \
+ done
###--------------------------------------------------------------------------
-### Documentation.
+### Other subdirectories.
-info_TEXINFOS = common.texi
+## Documentation.
+SUBDIRS += doc
+EXTRA_DIST += README.org
-###--------------------------------------------------------------------------
-### Other special tweaks.
+## Testing.
+SUBDIRS += t
-## Make `make distcheck' work.
-DISTCHECK_CONFIGURE_FLAGS = \
- --with-aclocaldir='$${prefix}/share/aclocal'
+## Benchmarking.
+if BENCHMARK
+SUBDIRS += bench
+endif
-## Distribute the release number.
+###--------------------------------------------------------------------------
+### Distribution.
+
+## Release number.
dist-hook::
echo $(VERSION) >$(distdir)/RELEASE
-## Ensure that the `COPYING' file is prominent.
-dist-hook::
- cd $(distdir) && $(LN_S) GPL-2 COPYING
+## Additional build tools.
+EXTRA_DIST += config/auto-version
+EXTRA_DIST += config/confsubst
-###--------------------------------------------------------------------------
-### Debian.
+## Debian.
+EXTRA_DIST += debian/changelog debian/copyright debian/compat
+EXTRA_DIST += debian/control debian/rules debian/source/format
-EXTRA_DIST += debian/compat
-EXTRA_DIST += debian/control
-EXTRA_DIST += debian/copyright
-EXTRA_DIST += debian/rules
-EXTRA_DIST += debian/changelog
+EXTRA_DIST += debian/runlisp.install debian/runlisp.dirs
+EXTRA_DIST += debian/runlisp.config debian/runlisp.templates
+EXTRA_DIST += debian/po/POTFILES.in debian/po/templates.pot
+EXTRA_DIST += debian/runlisp.postinst
+EXTRA_DIST += debian/runlisp.prerm debian/runlisp.postrm
+EXTRA_DIST += debian/runlisp.triggers
###----- That's all, folks --------------------------------------------------