diff options
Diffstat (limited to 'debian/rules')
-rwxr-xr-x | debian/rules | 197 |
1 files changed, 197 insertions, 0 deletions
diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..ce30869 --- /dev/null +++ b/debian/rules @@ -0,0 +1,197 @@ +#!/usr/bin/make -f +include debian/make.mk + +export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +$(call lazy,DEB_BUILD_ARCH,$$(shell dpkg-architecture -qDEB_BUILD_ARCH)) +$(call lazy,DEB_BUILD_GNU_TYPE,$$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)) +$(call lazy,DEB_HOST_ARCH,$$(shell dpkg-architecture -qDEB_HOST_ARCH)) +$(call lazy,DEB_HOST_ARCH_OS,$$(shell dpkg-architecture -qDEB_HOST_ARCH_OS)) +$(call lazy,DEB_HOST_GNU_TYPE,$$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)) +$(call lazy,DEB_HOST_GNU_CPU,$$(shell dpkg-architecture -qDEB_HOST_GNU_CPU)) +$(call lazy,DEB_HOST_MULTIARCH,$$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)) +$(call lazy,CFLAGS,$$(shell dpkg-buildflags --get CFLAGS)) +$(call lazy,CPPFLAGS,$$(shell dpkg-buildflags --get CPPFLAGS)) +$(call lazy,LDFLAGS,$$(shell dpkg-buildflags --get LDFLAGS)) + +PREPROCESS_FILES := $(wildcard debian/*.in) nss/pkg/pkg-config/nss-config.in +PREPROCESSED_FILES := $(addprefix debian/,$(notdir $(PREPROCESS_FILES:.in=))) + +$(filter debian/%,$(PREPROCESS_FILES:.in=)): %: %.in +debian/nss-config: nss/pkg/pkg-config/nss-config.in +$(PREPROCESSED_FILES): + sed 's,/@DEB_HOST_MULTIARCH@,$(DEB_HOST_MULTIARCH:%=/%),g;$(EXTRA_REPLACES)' $< > $@ + +UPSTREAM_VERSION := $(shell dpkg-parsechangelog | sed -n 's/^Version: *\([0-9]*:\)\?\([0-9.]*+really\)\?\([^~]*\)\(~.*\)\?-.*$$/\3/ p') +MOD_MAJOR_VERSION := $(word 1, $(subst ., ,$(UPSTREAM_VERSION))) +MOD_MINOR_VERSION := $(word 2, $(subst ., ,$(UPSTREAM_VERSION))) +MOD_PATCH_VERSION := $(or $(word 3, $(subst ., ,$(UPSTREAM_VERSION))),0) + +debian/nss.pc: EXTRA_REPLACES := s/@VERSION@/$(UPSTREAM_VERSION)/ +debian/nss-config: EXTRA_REPLACES := s/@MOD_MAJOR_VERSION@/$(MOD_MAJOR_VERSION)/;s/@MOD_MINOR_VERSION@/$(MOD_MINOR_VERSION)/;s/@MOD_PATCH_VERSION@/$(MOD_PATCH_VERSION)/;s/@prefix@/\/usr/ +debian/libnss3.lintian-overrides: EXTRA_REPLACES := s,/@DEB_HOST_MULTIARCH_WC@,$(DEB_HOST_MULTIARCH:%=/*),g + +TOOLCHAIN := + +ifneq ($(DEB_HOST_ARCH),$(DEB_BUILD_ARCH)) +ifeq ($(origin CC),default) +TOOLCHAIN += CC=$(DEB_HOST_GNU_TYPE)-gcc +endif +ifeq ($(origin CXX),default) +CXX := $(DEB_HOST_GNU_TYPE)-g++ +TOOLCHAIN += CXX=$(CXX) +endif +TOOLCHAIN += CCC=$(CXX) +ifeq ($(origin RANLIB),default) +TOOLCHAIN += RANLIB=$(DEB_HOST_GNU_TYPE)-ranlib +endif +TOOLCHAIN += OS_TEST=$(DEB_HOST_GNU_CPU) +TOOLCHAIN += KERNEL=$(DEB_HOST_ARCH_OS) +endif + +# $(foreach foo,$(list),$(call cmd,some command $(foo))) expands to +# some command first-elem +# some command second-elem +# etc. +# This avoid using a long one liner with semi colons. +define cmd +$(1) + +endef + +CFLAGS += -Wall -pipe + +DISTDIR := $(CURDIR)/dist + +COMMON_MAKE_FLAGS := \ + $(and $(filter terse,$(DEB_BUILD_OPTIONS)),-s) \ + SOURCE_PREFIX=$(DISTDIR) \ + SOURCE_MD_DIR=$(DISTDIR) \ + DIST=$(DISTDIR) \ + OBJDIR_NAME=OBJS \ + $(and $(filter 64,$(shell dpkg-architecture -qDEB_HOST_ARCH_BITS)),USE_64=1) \ + $(and $(filter x32,$(shell dpkg-architecture -qDEB_HOST_ARCH)),USE_X32=1) \ + $(NULL) + +# Disable -Werror on less mainline architectures. +ifneq (,$(filter-out i386 x86_64 aarch64,$(DEB_HOST_GNU_CPU))) +COMMON_MAKE_FLAGS += NSS_ENABLE_WERROR=0 +endif + +NSS_TOOLS := \ + certutil \ + chktest \ + cmsutil \ + crlutil \ + derdump \ + httpserv \ + modutil \ + ocspclnt \ + p7content \ + p7env \ + p7sign \ + p7verify \ + pk12util \ + pk1sign \ + pwdecrypt \ + rsaperf \ + selfserv \ + shlibsign \ + signtool \ + signver \ + ssltap \ + strsclnt \ + symkeyutil \ + tstclnt \ + vfychain \ + vfyserv \ + $(NULL) + +override_dh_auto_build: + $(MAKE) -C nss/coreconf/nsinstall \ + $(COMMON_MAKE_FLAGS) \ + CC=$(DEB_BUILD_GNU_TYPE)-gcc \ + ARCHFLAG= + + $(MAKE) -C nss \ + all \ + $(COMMON_MAKE_FLAGS) \ + MOZILLA_CLIENT=1 \ + NSPR_INCLUDE_DIR=/usr/include/nspr \ + NSPR_LIB_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) \ + BUILD_OPT=1 \ + NS_USE_GCC=1 \ + OPTIMIZER="$(CFLAGS) $(CPPFLAGS)" \ + LDFLAGS='$(LDFLAGS) $$(ARCHFLAG) $$(ZDEFS_FLAG)' \ + DSO_LDOPTS='-shared $$(LDFLAGS)' \ + NSS_USE_SYSTEM_SQLITE=1 \ + NSS_ENABLE_ECC=1 \ + CHECKLOC= \ + $(TOOLCHAIN) + +override_dh_auto_clean: + -$(MAKE) -C nss \ + clobber \ + $(COMMON_MAKE_FLAGS) \ + BUILD_OPT=1 + + rm -rf $(DISTDIR) $(PREPROCESSED_FILES) + +manpage = $(addsuffix .1,$(addprefix nss/doc/nroff/,$(1))) + +override_dh_auto_install: $(PREPROCESSED_FILES) + install -m 755 -d debian/libnss3/usr/lib/$(DEB_HOST_MULTIARCH) debian/libnss3-dev/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig + install -m 644 -t debian/libnss3/usr/lib/$(DEB_HOST_MULTIARCH) \ + $(DISTDIR)/lib/libnss3.so \ + $(DISTDIR)/lib/libnssutil3.so \ + $(DISTDIR)/lib/libsmime3.so \ + $(DISTDIR)/lib/libssl3.so \ + $(DISTDIR)/lib/libfreebl3.so \ + $(DISTDIR)/lib/libfreeblpriv3.so \ + $(DISTDIR)/lib/libsoftokn3.so \ + $(DISTDIR)/lib/libnssdbm3.so \ + $(DISTDIR)/lib/libnssckbi.so + + install -m 644 -t debian/libnss3-dev/usr/include/nss \ + $(DISTDIR)/public/nss/* + install -m 644 -t debian/libnss3-dev/usr/lib/$(DEB_HOST_MULTIARCH) \ + $(DISTDIR)/lib/libcrmf.a + install -m 644 -t debian/libnss3-dev/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig debian/nss.pc + install -m 755 -t debian/libnss3-dev/usr/bin debian/nss-config + + install -m 755 -t debian/libnss3-tools/usr/bin $(addprefix $(DISTDIR)/bin/,$(NSS_TOOLS)) + install -m 755 -d $(DISTDIR)/man + install -m 644 -t $(DISTDIR)/man $(wildcard $(call manpage,$(NSS_TOOLS))) + + # these utilities are too generically-named, so we prefix them with nss- (see http://bugs.debian.org/701141) + $(foreach bin, \ + addbuiltin \ + dbtest \ + pp \ + , \ + $(call cmd,install -m 755 -T $(DISTDIR)/bin/$(bin) debian/libnss3-tools/usr/bin/nss-$(bin)) \ + $(if $(wildcard $(call manpage,$(bin))),$(call cmd,install -m 644 -T $(call manpage,$(bin)) $(DISTDIR)/man/nss-$(bin).1))) + +ifeq ($(DEB_HOST_ARCH),$(DEB_BUILD_ARCH)) +SHLIBSIGN = LD_LIBRARY_PATH=debian/libnss3/usr/lib/$(DEB_HOST_MULTIARCH) debian/libnss3-tools/usr/bin/shlibsign +else +SHLIBSIGN = shlibsign +endif + +override_dh_strip: + dh_strip + $(foreach lib,libsoftokn3.so libfreebl3.so libfreeblpriv3.so libnssdbm3.so, \ + $(call cmd,umask 022; $(SHLIBSIGN) -v -i debian/libnss3/usr/lib/$(DEB_HOST_MULTIARCH)/$(lib))) + +ifeq ($(DEB_HOST_ARCH),$(DEB_BUILD_ARCH)) + # Check FIPS mode correctly works + mkdir debian/tmp + LD_LIBRARY_PATH=debian/libnss3/usr/lib/$(DEB_HOST_MULTIARCH) debian/libnss3-tools/usr/bin/modutil -create -dbdir debian/tmp < /dev/null + LD_LIBRARY_PATH=debian/libnss3/usr/lib/$(DEB_HOST_MULTIARCH) debian/libnss3-tools/usr/bin/modutil -fips true -dbdir debian/tmp < /dev/null +endif + +override_dh_makeshlibs: + dh_makeshlibs -a -- -c4 + +%: + dh $@ |