#!/usr/bin/make -f # -*- makefile -*- #export DH_VERBOSE=1 include /usr/share/dpkg/architecture.mk CFLAGS += $(CPPFLAGS) CXXFLAGS += $(CPPFLAGS) # FIXME: Needs to downgrade debug information to DWARF 4 format # ... otherwise DWZ will explode (see https://sourceware.org/bugzilla/show_bug.cgi?id=24756) LDC_COMPILER_FLAGS = -gdwarf=4 LDC_BUILD_FLAGS = -DINCLUDE_INSTALL_DIR='/usr/lib/ldc/${DEB_HOST_MULTIARCH}/include/d' \ -DLDC_DYNAMIC_COMPILE=OFF -DPHOBOS_SYSTEM_ZLIB=ON BOOTSTRAP_DC := $(shell which ldmd2 2>/dev/null || which gdmd 2>/dev/null) BOOTSTRAP_LDC_FLAGS = -DD_COMPILER=$(BOOTSTRAP_DC) -DBUILD_SHARED_LIBS=ON -DPHOBOS_SYSTEM_ZLIB=ON ifeq ($(DEB_HOST_ARCH),armhf) LDC_COMPILER_FLAGS += -mattr=-neon endif ifeq ($(DEB_HOST_ARCH),mips64el) LDC_COMPILER_FLAGS += -mabi=n64 -mcpu=mips64r2 -mattr=+xgot endif ifneq (,$(filter $(DEB_HOST_ARCH), armhf)) export DEB_BUILD_MAINT_OPTIONS += abi=+time64,+lfs endif LDC_BUILD_FLAGS += -DD_COMPILER_FLAGS='$(LDC_COMPILER_FLAGS)' BOOTSTRAP_S1_BUILD_DIR := $(CURDIR)/bootstrap-stage1 STAGE1_LDMD = $(BOOTSTRAP_S1_BUILD_DIR)/bin/ldmd2 BOOTSTRAP_S2_BUILD_DIR := $(CURDIR)/bootstrap-stage2 STAGE2_LDMD = $(BOOTSTRAP_S2_BUILD_DIR)/bin/ldmd2 # Clear DFLAGS: dpkg sets "-frelease", which is automatically read by ldmd2 # and will lead to failures as ldmd2 doesn't understand GDC flags. # Setting this to emptystring however will mess up gdmd, so since none of the # compiler wrappers seems to parse this properly at all, we must unset it. export DEB_DFLAGS_MAINT_STRIP = -frelease %: dh $@ override_dh_auto_configure: ifeq ($(BOOTSTRAP_DC),) $(error Neither GDMD nor LDMD2 found) endif # Bootstrap LDC using the GNU D Compiler dh_auto_configure -B$(BOOTSTRAP_S1_BUILD_DIR) -- $(BOOTSTRAP_LDC_FLAGS) dh_auto_build -B$(BOOTSTRAP_S1_BUILD_DIR) # Build LDC again using the previously bootstrapped copy dh_auto_configure -B$(BOOTSTRAP_S2_BUILD_DIR) -- \ -DD_COMPILER=$(STAGE1_LDMD) \ -DBUILD_SHARED_LIBS=OFF $(LDC_BUILD_FLAGS) dh_auto_build -B$(BOOTSTRAP_S2_BUILD_DIR) # Configure the to-be-released LDC versions, build them with S2 self-built LDC dh_auto_configure -- \ -DD_COMPILER=$(STAGE2_LDMD) \ -DBUILD_SHARED_LIBS=BOTH $(LDC_BUILD_FLAGS) override_dh_auto_install: dh_auto_install rm -rf $(CURDIR)/debian/tmp/usr/lib/ldc/*/include/d/etc/c/zlib/ override_dh_installman: dh_installman debian/ldc2.1 debian/ldmd2.1 override_dh_clean: rm -f configure-stamp build-stamp rm -rf $(BOOTSTRAP_S1_BUILD_DIR) $(BOOTSTRAP_S2_BUILD_DIR) dh_clean override_dh_makeshlibs: dh_makeshlibs -V override_dh_auto_test: # Tests, std.zip, std.zip-debug, std.zip-shared, std.zip-debug-shared, dmd-testsuite-debug. dmd-testsuite fail at the moment, so # we only run unit tests temporarily ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) ctest -V -R "ldc2-unittest" --test-dir $(BOOTSTRAP_S2_BUILD_DIR) endif