#!/usr/bin/make -f # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # for DEB_HOST_* include /usr/share/dpkg/architecture.mk # for DEB_VERSION_UPSTREAM include /usr/share/dpkg/pkg-info.mk export DEB_BUILD_MAINT_OPTIONS = hardening=+all # A Scheme heap block is 1024 words, so the microcode's default heap of 3072 # blocks is 12MB on a 32-bit host, and compiling imail-imap with all of Edwin # loaded does not fit. It cannot simply be made large: with # HEAP_IN_LOW_MEMORY the heap has to sit below 2^26 bytes in the address # space, so 16384 (64MB, the 64-bit default) will not even start. 10000 is # what src/configure.ac gives its own host compiler on svm1-32, for the same # reason, and only applies to invocations that do not pass --heap themselves. ifeq ($(DEB_HOST_ARCH_BITS),32) export MITSCHEME_HEAP_SIZE = 10000 endif %: dh $@ override_dh_autoreconf: dh_autoreconf sh -- -e -x -c \ 'for d in src doc; \ do (cd $$d && autoreconf -f -i) done' # Two flavours: native code, and upstream's SVM virtual machine. Upstream # names its back ends its own way and its configure only auto-detects x86, so # each name is kept here and drives --enable-native-code, the installed # interpreter name and the alternatives symlink. See debian/NOTES.md. # BIN_ARCH is upstream's --enable-native-code name. BIN_CODE_TYPE is what a # Scheme built for that back end reports as microcode-id/compiled-code-type # (cc_arch_name in src/microcode/utabmd.c), which is what the cross-compile # decision below compares against. They agree except for aarch64, whose # --enable-native-code name carries the byte order. ifeq ($(DEB_HOST_ARCH),amd64) BIN_ARCH := x86-64 BIN_CODE_TYPE := x86-64 else ifeq ($(DEB_HOST_ARCH),arm64) BIN_ARCH := aarch64le BIN_CODE_TYPE := aarch64 else ifeq ($(DEB_HOST_ARCH),i386) BIN_ARCH := i386 BIN_CODE_TYPE := i386 endif export BIN_ARCH # The SVM comes in four flavours, by word size and byte order. SVM_ARCH := svm1-$(DEB_HOST_ARCH_BITS)$(if $(filter little,$(DEB_HOST_ARCH_ENDIAN)),le,be) export SVM_ARCH # Its own auxiliary directory, or it would overwrite the native build's. SVM_AUXDIR_NAME := mit-scheme-svm SVM_BUILDDIR := build-svm # Ask dh_listpackages rather than working it out again: it already accounts # for the Architecture fields and the build profiles, so debian/control stays # the single source of truth. DH_PACKAGES := $(shell dh_listpackages) BUILD_NATIVE := $(if $(filter mit-scheme,$(DH_PACKAGES)),yes,no) BUILD_SVM := $(if $(filter mit-scheme-svm,$(DH_PACKAGES)),yes,no) # debian/control asking for a native build we have no back-end name for. ifeq ($(BUILD_NATIVE),yes) ifeq ($(BIN_ARCH),) $(error debian/control builds mit-scheme on $(DEB_HOST_ARCH), but there is no \ native back end mapped for it above) endif endif CONF_FLAGS += --docdir=/usr/share/doc/mit-scheme-doc CONF_FLAGS += --enable-html=/usr/share/doc/mit-scheme-doc/html CONF_FLAGS += --enable-pdf=/usr/share/doc/mit-scheme-doc/pdf CONF_FLAGS += --enable-ps=no CONF_FLAGS += --enable-blowfish=yes CONF_FLAGS += --enable-gdbm=yes CONF_FLAGS += --enable-pgsql=yes # Cross-compile whenever the Scheme we build with disagrees with the target # about compiled-code format, or the build dies with fasl-file-bad-data when # saving lib/runtime.com. That is the normal case for the SVM flavour. HOST_CODE_TYPE := $(shell mit-scheme --batch-mode --no-init-file \ --eval '(begin (display microcode-id/compiled-code-type) (%exit 0))' \ < /dev/null 2>/dev/null) # Nothing to build with? Bootstrap from a prebuilt SVM library, if the # debian-bootstrap branch supplied one. Compiler only; everything shipped is # still built from source. See debian/NOTES.md. BOOTSTRAP_BUILDDIR := build-bootstrap ifeq ($(HOST_CODE_TYPE),) ifneq (,$(wildcard debian/prebuilt/$(SVM_ARCH))) BOOTSTRAP := yes HOST_CODE_TYPE := svm1 MIT_SCHEME_EXE := $(CURDIR)/$(BOOTSTRAP_BUILDDIR)/run-build export MIT_SCHEME_EXE else BOOTSTRAP := no endif else BOOTSTRAP := no endif # Empty when no Scheme is installed; leave the native flags alone then. NATIVE_CONF_FLAGS := ifneq ($(HOST_CODE_TYPE),) ifneq ($(HOST_CODE_TYPE),$(BIN_CODE_TYPE)) NATIVE_CONF_FLAGS += --enable-cross-compiling endif endif # compiled-code-type says "svm1", without the size/endianness suffix. SVM_CONF_FLAGS := ifneq ($(HOST_CODE_TYPE),svm1) SVM_CONF_FLAGS += --enable-cross-compiling endif override_dh_auto_configure-arch: @test "$(BUILD_NATIVE)$(BUILD_SVM)" != nono || \ { echo "both flavours disabled: nothing to build" >&2; exit 1; } ifeq ($(BOOTSTRAP),yes) @echo "no MIT/GNU Scheme to build with; bootstrapping one from debian/prebuilt" debian/bootstrap-scheme.sh $(SVM_ARCH) $(BOOTSTRAP_BUILDDIR) endif # -arch ifeq ($(BUILD_NATIVE),yes) dh_auto_configure --sourcedirectory=src -- \ $(CONF_FLAGS) $(NATIVE_CONF_FLAGS) --enable-native-code=$(BIN_ARCH) endif ifeq ($(BUILD_SVM),yes) @echo "second source tree for the SVM flavour" rm -rf $(SVM_BUILDDIR) cp -a src $(SVM_BUILDDIR) AUXDIR_NAME=$(SVM_AUXDIR_NAME) \ dh_auto_configure --sourcedirectory=$(SVM_BUILDDIR) -- \ $(CONF_FLAGS) $(SVM_CONF_FLAGS) --enable-native-code=$(SVM_ARCH) endif override_dh_auto_configure-indep: dh_auto_configure --sourcedirectory=doc -- $(CONF_FLAGS) # May wish to pass parameter in dh_auto_build # SCHEME_COMPILER=mit-scheme override_dh_auto_build-arch: # -arch ifeq ($(BUILD_NATIVE),yes) dh_auto_build --max-parallel=1 --sourcedirectory=src endif ifeq ($(BUILD_SVM),yes) dh_auto_build --max-parallel=1 --sourcedirectory=$(SVM_BUILDDIR) endif override_dh_auto_build-indep: dh_auto_build --sourcedirectory=doc override_dh_auto_install-arch: # -arch ifeq ($(BUILD_NATIVE),yes) dh_auto_install --max-parallel=1 --sourcedirectory=src --destdir=debian/tmp endif ifeq ($(BUILD_SVM),yes) dh_auto_install --max-parallel=1 --sourcedirectory=$(SVM_BUILDDIR) --destdir=debian/tmp-svm endif override_dh_auto_install-indep: dh_auto_install --sourcedirectory=doc -- install-html install-pdf STAGED := $(if $(filter yes,$(BUILD_NATIVE)),debian/tmp) \ $(if $(filter yes,$(BUILD_SVM)),debian/tmp-svm) execute_after_dh_auto_install-arch: @echo "remove symbolic link executables" for d in $(STAGED); do \ (cd $$d/usr/bin && \ for f in scheme bchscheme mit-scheme mit-scheme-native; do \ if [ -L $$f ]; then \ rm --verbose -f $$f; \ else \ echo skipping $$f; \ fi; \ done); \ done @echo "remove .la library support files as these are not actually used by the dynamic linker" find $(STAGED) -name '*.la' -ls -delete execute_after_dh_auto_install-indep: @echo "allow dh scripts to compress info files themselves" find debian/tmp \( -name '*.info.gz' -o -name '*.info-*.gz' \) -ls -exec gunzip '{}' ';' override_dh_install: ifeq ($(BUILD_SVM),yes) dh_install -pmit-scheme-svm --sourcedir=debian/tmp-svm endif dh_install --remaining-packages execute_after_dh_install-arch: ifeq ($(BUILD_NATIVE),yes) @echo "All .bci files belong in -dbg, move them manually for robustness" mkdir -p debian/mit-scheme-dbg tar -C debian/mit-scheme --create --file=- --files-from=/dev/null $$(cd debian/mit-scheme && find -name '*.bci') \ | tar -C debian/mit-scheme-dbg -xvf - find debian/mit-scheme -name '*.bci' -delete @echo "remove empty directory" -rmdir debian/mit-scheme/usr/lib/$(DEB_HOST_MULTIARCH)/mit-scheme/lib endif ifeq ($(BUILD_SVM),yes) @echo "the SVM flavour has no -dbg package; drop its .bci files" find debian/mit-scheme-svm -name '*.bci' -delete -rmdir debian/mit-scheme-svm/usr/lib/$(DEB_HOST_MULTIARCH)/$(SVM_AUXDIR_NAME)/lib endif # Installed under the back-end-qualified name the real binary has; plain # mit-scheme.1 comes from the alternatives as a slave link. define install_manpage cd debian/$(1)/usr/share/man && \ mv man1/mit-scheme.1 man1/mit-scheme-$(2).1 && \ ln -s mit-scheme-$(2).1 man1/mit-scheme-$(2)-$(DEB_VERSION_UPSTREAM).1 endef execute_after_dh_installman-arch: ifeq ($(BUILD_NATIVE),yes) $(call install_manpage,mit-scheme,$(BIN_ARCH)) endif ifeq ($(BUILD_SVM),yes) $(call install_manpage,mit-scheme-svm,$(SVM_ARCH)) endif # Upstream changelog is over 5MB, leave a copy in the doc package but # remove it from the binary package to reduce bloat. # See http://dedup.debian.net/. override_dh_installchangelogs-arch: dh_installchangelogs -rm --verbose \ debian/mit-scheme/usr/share/doc/mit-scheme/changelog \ debian/mit-scheme-dbg/usr/share/doc/mit-scheme-dbg/changelog override_dh_auto_clean: -dh_auto_clean rm -rf $(SVM_BUILDDIR) debian/tmp-svm $(BOOTSTRAP_BUILDDIR)