| 1 |
#!/usr/bin/make -f |
| 2 |
|
| 3 |
include debian/make.mk |
| 4 |
|
| 5 |
export DEB_BUILD_MAINT_OPTIONS = hardening=+all |
| 6 |
|
| 7 |
# Use dpkg-buildflags to get hardening flags, and exclude non-hardening flags |
| 8 |
dpkg_buildflags = $(and $(1),$(shell DEB_CFLAGS_MAINT_STRIP="$(shell DEB_BUILD_MAINT_OPTIONS=hardening=-all dpkg-buildflags --get $(1))" dpkg-buildflags --get $(1))) |
| 9 |
$(call lazy,CFLAGS,$$(call dpkg_buildflags,CFLAGS)) |
| 10 |
$(call lazy,CPPFLAGS,$$(call dpkg_buildflags,CPPFLAGS)) |
| 11 |
$(call lazy,LDFLAGS,$$(call dpkg_buildflags,LDFLAGS)) |
| 12 |
|
| 13 |
CFLAGS += -Wall -pipe |
| 14 |
LDFLAGS += -Wl,--as-needed |
| 15 |
|
| 16 |
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) |
| 17 |
CONFIGURE_FLAGS := --disable-optimize |
| 18 |
else |
| 19 |
CONFIGURE_FLAGS := --enable-optimize |
| 20 |
endif |
| 21 |
|
| 22 |
ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) |
| 23 |
CONFIGURE_FLAGS += --enable-debug |
| 24 |
else |
| 25 |
CONFIGURE_FLAGS += --disable-debug --enable-debug-symbols |
| 26 |
endif |
| 27 |
|
| 28 |
ifeq (64,$(shell dpkg-architecture -qDEB_HOST_ARCH_BITS)) |
| 29 |
CONFIGURE_FLAGS += --enable-64bit |
| 30 |
endif |
| 31 |
ifeq (x32,$(shell dpkg-architecture -qDEB_HOST_ARCH)) |
| 32 |
CONFIGURE_FLAGS += --enable-x32 |
| 33 |
endif |
| 34 |
|
| 35 |
$(call lazy,DEB_HOST_MULTIARCH,$$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)) |
| 36 |
$(call lazy,BUILD_DATE,$$(shell dpkg-parsechangelog -S Date)) |
| 37 |
|
| 38 |
PREPROCESS_FILES := $(wildcard debian/*.in) |
| 39 |
|
| 40 |
$(PREPROCESS_FILES:.in=): %: %.in |
| 41 |
sed 's,@DEB_HOST_MULTIARCH@/,$(DEB_HOST_MULTIARCH:=/),g;s,@MULTIARCH_WILDCARD@/,$(if $(DEB_HOST_MULTIARCH),*/),g' $< > $@ |
| 42 |
|
| 43 |
%: |
| 44 |
dh $@ --sourcedirectory=nspr |
| 45 |
|
| 46 |
override_dh_auto_configure: $(PREPROCESS_FILES:.in=) |
| 47 |
for file in config.guess config.sub; do \ |
| 48 |
sed -i '2!b;/^#/ i\exec "/usr/share/misc/'$$file'" "$$@"' nspr/build/autoconf/$$file; \ |
| 49 |
done |
| 50 |
|
| 51 |
cd nspr && \ |
| 52 |
CFLAGS="$(CFLAGS)" \ |
| 53 |
CPPFLAGS="$(CPPFLAGS)" \ |
| 54 |
LDFLAGS="$(LDFLAGS)" \ |
| 55 |
./configure --target=$(DEB_HOST_GNU_TYPE) --host=$(DEB_BUILD_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \ |
| 56 |
$(CONFIGURE_FLAGS) \ |
| 57 |
--prefix=/usr \ |
| 58 |
--libdir=/usr/lib/$(DEB_HOST_MULTIARCH) |
| 59 |
|
| 60 |
override_dh_auto_build: |
| 61 |
$(MAKE) -C nspr $(and $(filter terse,$(DEB_BUILD_OPTIONS)),-s) \ |
| 62 |
SH_NOW="$(shell TZ=UTC date -d "$(BUILD_DATE)" +%s)000000" \ |
| 63 |
SH_DATE="$(shell TZ=UTC date -d "$(BUILD_DATE)" "+%Y-%m-%d %T")" |
| 64 |
|
| 65 |
override_dh_auto_clean: |
| 66 |
[ ! -f nspr/pr/tests/Makefile ] || $(MAKE) -C nspr/pr/tests clean |
| 67 |
[ ! -f nspr/lib/tests/Makefile ] || $(MAKE) -C nspr/lib/tests clean |
| 68 |
dh_auto_clean |
| 69 |
|
| 70 |
rm -f $(PREPROCESS_FILES:.in=) |
| 71 |
for file in config.guess config.sub; do \ |
| 72 |
sed -i '2!b;/^exec "/ d' nspr/build/autoconf/$$file; \ |
| 73 |
done |
| 74 |
|
| 75 |
override_dh_makeshlibs: |
| 76 |
dh_makeshlibs -a -- -c4 |
| 77 |
|
| 78 |
override_dh_auto_test: |
| 79 |
ifeq ($(filter nocheck,$(DEB_BUILD_OPTIONS)),) |
| 80 |
$(MAKE) -C nspr/pr/tests |
| 81 |
$(MAKE) -C nspr/lib/tests |
| 82 |
# Skip gethost because it needs DNS, and thus networking. |
| 83 |
# Skip fdcach, peek and vercheck because they fail. |
| 84 |
# Skip socket because it freezes. |
| 85 |
# Skip getproto because it fails on some buildds. |
| 86 |
# Skip nblayer because it freezes on armel. |
| 87 |
cd nspr/pr/tests && grep -v '^\(fdcach\|gethost\|getproto\|nblayer\|peek\|socket\|vercheck\)$$' ./runtests.sh | sh - $(CURDIR)/nspr/dist |
| 88 |
cd nspr/lib/tests && LD_LIBRARY_PATH=$(CURDIR)/nspr/dist/bin$(addprefix :,$(LD_LIBRARY_PATH)) ./base64t |
| 89 |
cd nspr/lib/tests && LD_LIBRARY_PATH=$(CURDIR)/nspr/dist/bin$(addprefix :,$(LD_LIBRARY_PATH)) ./string |
| 90 |
endif |