#!/usr/bin/make -f # -*- makefile -*- # Uncomment this to turn on verbose mode. # export DH_VERBOSE=1 include /usr/share/dpkg/architecture.mk include /usr/share/dpkg/pkg-info.mk TARGET := arm-none-eabi TOP_DIR := $(shell pwd) BUILD_DIR := $(TOP_DIR)/build/ BUILD_NANO_DIR := $(TOP_DIR)/build_nano/ TMP_DIR := debian/tmp TMP_NANO_DIR := debian/tmp_nano CFLAGS := CFLAGS="-g -O2 -ffunction-sections -fdata-sections" CFLAGS_NANO := CFLAGS="-g -Os -ffunction-sections -fdata-sections -fshort-wchar" TARGET_TOOLS = \ CC_FOR_TARGET=$(TARGET)-gcc \ GCC_FOR_TARGET=$(TARGET)-gcc \ AR_FOR_TARGET=$(TARGET)-ar \ AS_FOR_TARGET=$(TARGET)-as \ LD_FOR_TARGET=$(TARGET)-ld \ NM_FOR_TARGET=$(TARGET)-nm \ OBJDUMP_FOR_TARGET=$(TARGET)-objdump \ RANLIB_FOR_TARGET=$(TARGET)-ranlib \ READELF_FOR_TARGET=$(TARGET)-readelf \ STRIP_FOR_TARGET=$(TARGET)-strip CONFIGURE_COMMON_FLAGS = \ --host=$(DEB_HOST_MULTIARCH) \ --target=$(TARGET) \ --prefix=/usr/lib \ --libdir=/usr/lib \ --infodir=/usr/share/doc/$(DEB_SOURCE)/info \ --mandir=/usr/share/man \ --htmldir=/usr/share/doc/$(DEB_SOURCE)/html \ --pdfdir=/usr/share/doc/$(DEB_SOURCE)/pdf \ --with-pkgversion=$(DEB_VERSION) \ --disable-newlib-supplied-syscalls \ --disable-nls \ $(TARGET_TOOLS) CONFIGURE_FLAGS = \ --enable-newlib-io-long-long \ --enable-newlib-register-fini \ $(CFLAGS) \ $(CONFIGURE_COMMON_FLAGS) CONFIGURE_FLAGS_NANO = \ --enable-newlib-reent-small \ --disable-newlib-fvwrite-in-streamio \ --disable-newlib-fseek-optimization \ --disable-newlib-wide-orient \ --enable-newlib-nano-malloc \ --disable-newlib-unbuf-stream-opt \ --enable-lite-exit \ --enable-newlib-global-atexit \ --enable-newlib-nano-formatted-io \ $(CFLAGS_NANO) \ $(CONFIGURE_COMMON_FLAGS) %: dh $@ -B$(BUILD_DIR) --with autotools-dev --parallel override_dh_clean: dh_clean rm -rf $(BUILD_DIR) $(BUILD_NANO_DIR) $(TMP_NANO_DIR) override_dh_auto_configure: dh_auto_configure -B$(BUILD_DIR) -- $(CONFIGURE_FLAGS) dh_auto_configure -B$(BUILD_NANO_DIR) -- $(CONFIGURE_FLAGS_NANO) override_dh_auto_test: dh_auto_test -B$(BUILD_DIR) dh_auto_test -B$(BUILD_NANO_DIR) override_dh_auto_build: dh_auto_build -B$(BUILD_DIR) dh_auto_build -B$(BUILD_NANO_DIR) override_dh_auto_install: dh_auto_install -B$(BUILD_DIR) --max-parallel=1 dh_auto_install -B$(BUILD_NANO_DIR) --destdir debian/tmp_nano --max-parallel=1 # # Rename nano lib* files to lib*_nano find $(TMP_NANO_DIR) -regex ".*/lib\(c\|g\|rdimon\)\.a" \ -exec rename 's@$(TMP_NANO_DIR)/(.*).a@$(TMP_DIR)/$$1_nano.a@' \{\} \+ # # Move nano's version of newlib.h to nano/newlib.h mkdir -p $(TMP_DIR)/usr/lib/$(TARGET)/include/nano mv $(TMP_NANO_DIR)/usr/lib/$(TARGET)/include/newlib.h \ $(TMP_DIR)/usr/lib/$(TARGET)/include/nano/newlib.h override_dh_installchangelogs: dh_installchangelogs ChangeLog override_dh_installdocs: set -ex; \ cd $(BUILD_DIR)/$(TARGET)/newlib; \ make html-recursive; \ cd -; dh_installdocs