1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
#!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie
include /usr/share/cdbs/1/rules/utils.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
# recent OpenSSL needed because https://github.com/nodejs/node/issues/589
ssl-minver = 1.0.2
# source equivalent of nodejs -e 'console.log(process.versions.modules)'
abi := $(shell awk '/^\#define NODE_MODULE_VERSION/ {print $$3}' src/node_version.h)
abi-deps = nodejs-dev (>= $(DEB_VERSION)~), nodejs-abi-$(abi)
# Build-depend unversioned on debhelper
# TODO: Drop when adopted in cdbs
CDBS_BUILD_DEPENDS_rules_debhelper_v9 = debhelper (>=9.20141010)
# Needed by upstream build
# * recent gyp needed to build using flock
bdeps = binutils, openssl (>= $(ssl-minver)), pkg-config
bdeps +=, bash-completion, curl, procps, zlib1g-dev, libicu-dev
bdeps +=, libkvm-dev [kfreebsd-any], gyp (>= 0.1~svn1773)
# Needed for tests
bdeps +=, ca-certificates
# needed by doctool-yaml.patch
bdeps +=, node-yamlish <!stage1>
# needed by doc builder
bdeps +=, node-marked <!stage1>
# Needed by upstream build and binary development package
# * recent libv8 because... FIXME (git commit eb490ef)
deps = python, libssl1.0-dev (>= $(ssl-minver))
deps +=, libuv1-dev
CDBS_BUILD_DEPENDS +=, $(bdeps), $(deps)
CDBS_DEPENDS_nodejs-dev = $(deps)
CDBS_RECOMMENDS_nodejs = ca-certificates
CDBS_PROVIDES_nodejs = nodejs-abi-$(abi)
# suppress checking binary files, to not upset dpkg-source
DEB_COPYRIGHT_CHECK_IGNORE_REGEX = ^(deps/v8/benchmarks/v8-logo\.png|test/fixtures/person\.jpg.*|src/res/node\.ico|debian/(changelog|copyright(|_hints|_newhints)))$
DEB_CONFIGURE_NORMAL_ARGS =
DEB_CONFIGURE_EXTRA_FLAGS = --without-npm --shared-openssl --shared-zlib --shared-libuv --with-intl=system-icu --prefix=/usr
# map HOST ARCH AND OS, and if unknown let upstream guess
# ia32 x64 x32 arm arm64 mips mipsel mips64el x87 ppc ppc64
destCpu =
destCpu := $(or $(destCpu),$(if $(filter i386,$(DEB_HOST_ARCH)),x87))
destCpu := $(or $(destCpu),$(if $(filter x32,$(DEB_HOST_ARCH)),x32))
destCpu := $(or $(destCpu),$(if $(filter kfreebsd-i386,$(DEB_HOST_ARCH)),x87))
destCpu := $(or $(destCpu),$(if $(filter hurd-i386,$(DEB_HOST_ARCH)),x87))
destCpu := $(or $(destCpu),$(if $(filter amd64,$(DEB_HOST_ARCH)),x64))
destCpu := $(or $(destCpu),$(if $(filter kfreebsd-amd64,$(DEB_HOST_ARCH)),x64))
destCpu := $(or $(destCpu),$(if $(filter armel,$(DEB_HOST_ARCH)),unsupported))
destCpu := $(or $(destCpu),$(if $(filter armhf,$(DEB_HOST_ARCH)),arm))
destCpu := $(or $(destCpu),$(if $(filter aarch64,$(DEB_HOST_ARCH)),arm64))
destCpu := $(or $(destCpu),$(if $(filter mipsel,$(DEB_HOST_ARCH)),mipsel))
destCpu := $(or $(destCpu),$(if $(filter mips64el,$(DEB_HOST_ARCH)),mips64el))
destCpu := $(or $(destCpu),$(if $(filter mips,$(DEB_HOST_ARCH)),mips))
destCpu := $(or $(destCpu),$(if $(filter powerpc,$(DEB_HOST_ARCH)),unsupported))
destCpu := $(or $(destCpu),$(if $(filter ppc64,$(DEB_HOST_ARCH)),ppc64))
destCpu := $(or $(destCpu),$(if $(filter s390x,$(DEB_HOST_ARCH)),s390x))
# solaris freebsd openbsd linux
destOs =
destOs := $(or $(destOs),$(if $(filter linux,$(DEB_HOST_ARCH_OS)),linux))
destOs := $(or $(destOs),$(if $(filter kfreebsd,$(DEB_HOST_ARCH_OS)),freebsd))
ifneq (, $(destOs))
DEB_CONFIGURE_EXTRA_FLAGS += --dest-os=$(destOs)
endif
ifeq (unsupported, $(destCpu))
$(error "nodejs cannot run on $(DEB_HOST_ARCH), please consult maintainers")
endif
ifneq (, $(destCpu))
DEB_CONFIGURE_EXTRA_FLAGS += --dest-cpu=$(destCpu)
endif
ifeq (freebsd, $(destOs))
LDFLAGS += -lbsd
endif
# mips and fpu, see https://github.com/paul99/v8m-rb/issues/192
# and https://bugs.debian.org/800410
# https://lists.debian.org/debian-mips/2016/07/msg00005.html
ifeq (mipsel, $(DEB_HOST_ARCH))
DEB_CONFIGURE_EXTRA_FLAGS += --with-mips-arch-variant=r2
endif
ifeq (mips, $(DEB_HOST_ARCH))
DEB_CONFIGURE_EXTRA_FLAGS += --with-mips-arch-variant=r2
endif
# mips32r1 or greater, detected at runtime
ifeq (mips64el, $(DEB_HOST_ARCH))
DEB_CONFIGURE_EXTRA_FLAGS += --with-mips-arch-variant=rx --with-mips-fpu-mode=fp64
endif
ifeq (armel, $(DEB_HOST_ARCH))
DEB_CONFIGURE_EXTRA_FLAGS += --with-arm-float-abi=softfp
ifeq ($(shell dpkg-vendor --is ubuntu && echo true),true)
# Ubuntu targets armv7+ with VFP and thumb2 support by default for armel
DEB_CONFIGURE_EXTRA_FLAGS += --with-arm-fpu=vfpv3
else
# debian defaults
# v8 does not support < armv5
CXXFLAGS += -march=armv5t
DEB_CONFIGURE_EXTRA_FLAGS += --with-arm-fpu=vfp
endif
endif
ifeq (armhf, $(DEB_HOST_ARCH))
DEB_CONFIGURE_EXTRA_FLAGS += --with-arm-float-abi=hard
ifeq ($(shell dpkg-vendor --derives-from raspbian && echo true),true)
# enable vfp, disable armv7
DEB_CONFIGURE_EXTRA_FLAGS += --with-arm-fpu=vfp
else
# enable armv7 vfpv3
DEB_CONFIGURE_EXTRA_FLAGS += --with-arm-fpu=vfpv3
endif
endif
DEB_DESTDIR = $(CURDIR)/debian/tmp
DEB_MAKE_CLEAN_TARGET = clean
# relax regression tests when targeted experimental suite
export HOME = $(CURDIR)/test/tmp
export FLAKY_TESTS = dontcare
export TEST_CI_ARGS = --arch=$(destCpu) --timeout=3000
export CI_JS_SUITES = message parallel sequential
# keep in mind ./debian/rules check is also invoked by adt-run, see debian/tests/
exp-relax-check := $(if $(shell dpkg-parsechangelog | grep -x 'Distribution: \(experimental\|UNRELEASED\)'),-i)
DEB_MAKE_CHECK_TARGET = $(exp-relax-check) test-ci-js
# hardening gyp
CXXFLAGS+=$(CPPFLAGS)
export CXXFLAGS
export LDFLAGS
# disable DNS requests during tests
export RES_OPTIONS = attempts:0
# properly clean files from build, test, python
clean::
rm -f icu_config.gypi
rm -rf test/addons/doc-*
rm -f test/addons/.buildstamp
rm -f test/addons/.docbuildstamp
rm -rf test/addons/*/build
rm -f config.gypi
rm -f config.mk
rm -f test/fixtures/hello.txt
rm -rf test/tmp*
find . -name "*.pyc" -delete
rm -rf out
binary-post-install/nodejs::
mv debian/nodejs/usr/bin/node debian/nodejs/usr/bin/nodejs
mv debian/nodejs/usr/share/man/man1/node.1 debian/nodejs/usr/share/man/man1/nodejs.1
ifeq ($(filter stage1,$(DEB_BUILD_PROFILES)),)
# remove *.json files from documentation
binary-install/nodejs::
find debian/nodejs/usr/share/doc/nodejs -name *.json -delete
endif
pre-build::
mkdir -p $(HOME)
ifeq ($(filter stage1,$(DEB_BUILD_PROFILES)),)
build/nodejs::
make doc
else
# Stops the stage1 variant from breaking dh_installdocs
build/nodejs::
mkdir -p out/doc/api
endif
# Provide dependency hints for reverse dependencies to consume
CDBS_SUGGESTS_nodejs-dev = debhelper
install/nodejs-dev::
pod2man --release "" --center "" debian/dh_nodejs > $(cdbs_curdestdir)/usr/share/man/man1/dh_nodejs.1
install -D debian/dh_nodejs $(cdbs_curdestdir)/usr/bin/dh_nodejs
mkdir -p $(cdbs_curdestdir)/usr/share/nodejs
echo '$(abi-deps)' > $(cdbs_curdestdir)/usr/share/nodejs/pluginsdep
check:
-ln -s /usr/bin/nodejs node
mkdir -p $(HOME)
make $(DEB_MAKE_CHECK_TARGET)
rm -f node
rm -rf test/tmp*
|