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 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
|
#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk
include /usr/share/dpkg/buildtools.mk
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# Exclude .svn directories from packages
export DH_ALWAYS_EXCLUDE=.svn
# Enable hardening
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
VERSION=$(DEB_VERSION)
PREFIX=/usr
DATADIR=$(PREFIX)/share/nsis
DOCDIR=$(PREFIX)/share/doc/nsis
SYSCONF=/etc
BUILDDIR=build
UNICODE=yes
INSTDIR=$(CURDIR)/debian
TESTDIR=$(CURDIR)/$(BUILDDIR)/test
# Decomposition of version string
define SPLIT
$(if $(2),$(call SPLIT,$(subst $(firstword $(2)), ,$(1)),$(filter-out $(firstword $(2)), $(2))), $(1))
endef
VERSION_DECOMPOSED=$(call SPLIT,$(VERSION),. - + ~)
VER_MAJOR=$(firstword $(VERSION_DECOMPOSED))
VER_MINOR=$(word 2,$(VERSION_DECOMPOSED))
VER_REVISION=$(shell echo $(firstword $(subst +, ,$(word 3,$(VERSION_DECOMPOSED)))) | sed 's/[^0-9]//g')
# Variables for Win32/Win64 cross compiler
XGCC_W32_X86 = i686-w64-mingw32-gcc
XGCC_W32_X86_PATH = $(abspath $(shell $(XGCC_W32_X86) -print-file-name=libkernel32.a)/../..)
XGCC_W32_X86_PREFIX = $(subst -gcc,-,$(XGCC_W32_X86))
XGCC_W32_AMD64 = x86_64-w64-mingw32-gcc
XGCC_W32_AMD64_PATH = $(abspath $(shell $(XGCC_W32_AMD64) -print-file-name=libkernel32.a)/../..)
XGCC_W32_AMD64_PREFIX = $(subst -gcc,-,$(XGCC_W32_AMD64))
# Evaluate parallel build option
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
ifeq (,$(shell dh_listpackages -i))
NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
SCONSFLAGS = -j $(NUMJOBS)
endif
endif
# Honor hardening flags
SCONSHOSTFLAGS = APPEND_CCFLAGS="$(shell dpkg-buildflags --get CPPFLAGS) \
$(shell dpkg-buildflags --get CFLAGS)" \
APPEND_LINKFLAGS="$(shell dpkg-buildflags --get LDFLAGS)"
# Propagate CCACHE_DIR environment variable
ifneq (,$(CCACHE_DIR))
SCONSHOSTFLAGS += CC="CCACHE_DIR=\"$(CCACHE_DIR)\" $(CC)" CXX="CCACHE_DIR=\"$(CCACHE_DIR)\" $(CXX)"
endif
SCONSOPTS = $(SCONSFLAGS) VERSION=$(VERSION) VER_MAJOR=$(VER_MAJOR) \
VER_MINOR=$(VER_MINOR) VER_REVISION=$(VER_REVISION) \
PREFIX=$(PREFIX) PREFIX_CONF=$(SYSCONF) CHMDOCS=0 \
STRIP_CP=no \
$(if $(findstring nostripfull,$(DEB_BUILD_OPTIONS)),STRIP_W32=no,)
ifneq (,$(UNICODE),yes)
SCONSOPTS += UNICODE=yes
BUILDTYPE := u
endif
ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
SCONSOPTS += DEBUG=yes
BUILDTYPE := $(BUILDTYPE)debug
else
BUILDTYPE := $(BUILDTYPE)release
endif
ifdef XGCC_W32_X86_PATH
SCONSOPTS_X86 = PREFIX_PLUGINAPI_INC=$(XGCC_W32_X86_PATH)/include/ \
PREFIX_PLUGINAPI_LIB=$(XGCC_W32_X86_PATH)/lib/ \
XGCC_W32_PREFIX=$(XGCC_W32_X86_PREFIX) \
TARGET_ARCH=x86
endif
ifdef XGCC_W32_AMD64_PATH
SCONSOPTS_AMD64 = PREFIX_PLUGINAPI_INC=$(XGCC_W32_AMD64_PATH)/include/ \
PREFIX_PLUGINAPI_LIB=$(XGCC_W32_AMD64_PATH)/lib/ \
XGCC_W32_PREFIX=$(XGCC_W32_AMD64_PREFIX) \
TARGET_ARCH=amd64
endif
COMMA := ,
UTILS_ALL = 'Library/RegTool,MakeLangId,Makensisw,NSIS Menu,UIs,SubStart,VPatch/Source/GenPat,zip2exe'
# Only build GenPat for the host system
IGNORE_UTILS_NSIS := $(subst $(COMMA)VPatch/Source/GenPat,,$(UTILS_ALL))
# Build the win32 user interfaces (UIs) and RegTool
IGNORE_UTILS_COMMON := $(subst Library/RegTool$(COMMA),,$(UTILS_ALL))
IGNORE_UTILS_COMMON := $(subst $(COMMA)UIs,,$(IGNORE_UTILS_COMMON))
SCONSOPTS_HOST := $(SCONSHOSTFLAGS) $(SCONSOPTS) \
SKIPPLUGINS=all SKIPSTUBS=all \
SKIPUTILS=$(IGNORE_UTILS_NSIS) SKIPDOC=COPYING
SCONSOPTS_COMMON := $(SCONSOPTS) SKIPUTILS=$(IGNORE_UTILS_COMMON) \
SKIPDOC=COPYING
INSTALL_nsis = install-utils install-compiler install-conf
INSTALL_FLAGS_nsis = $(SCONSOPTS_HOST)
INSTALL_nsis-common = install-stubs install-plugins install-data install-utils
INSTALL_FLAGS_nsis-common = $(SCONSOPTS_COMMON)
INSTALL_nsis-pluginapi = install-pluginapi
INSTALL_FLAGS_nsis-pluginapi = $(SCONSOPTS_COMMON)
INSTALL_nsis-doc = install-examples install-doc install-docs
INSTALL_FLAGS_nsis-doc = $(SCONSOPTS_COMMON) \
SKIPPLUGINS=ExDLL SKIPSTUBS=all SKIPUTILS=$(IGNORE_UTILS_COMMON) \
SKIPDOC=COPYING
# Exclude test scripts which are not appropriate for POSIX platforms.
IGNORE_TESTS = gfx.nsi|install-per-user.nsi|install-shared.nsi|makensis.nsi
# Path to .nsi scripts
SCRIPTS_PATH = $(DOCDIR)/Examples
# Add contents to the given Debian package by taking
# INSTALL_FLAGS_<package> and INSTALL_<package> variables into account.
# $(1) package name, for example nsis-common
# $(2) additional flags for scons
define DO_SCONS_INSTALL
scons $(INSTALL_FLAGS_$(1)) $(2) PREFIX_DEST="$(INSTDIR)/$(1)" $(INSTALL_$(1)) || exit 1;
endef
# Add contents to the given Debian package via the path specfic target
# $(1) package name, for example nsis-common
# $(2) path specfic scons target
define DO_SCONS_INSTALL_EXTRA
scons $(INSTALL_FLAGS_$(1)) PREFIX_DEST="$(INSTDIR)/$(1)" "$(INSTDIR)/$(1)$(2)" || exit 1;
endef
# Select pretty style option depending on major version of html2text
HTML2TEXT_PRETTY_OPTION = $(shell test $$(expr \
$$(dpkg-query --show --showformat '$${Version}' html2text) \
: '\([^.]*\)') -gt 1 \
&& echo -rcfile /usr/share/doc/html2text/examples/pretty.style \
|| echo -style pretty)
# Convert html to text using the pretty.style configuration
# $(1) html formatted input file
# $(2) If omitted then the resulting text is written to standard output
# otherwise to the provided output file
define HTML2TEXT_PRETTY
html2text -nobs \
$(HTML2TEXT_PRETTY_OPTION) $(if $(2),-o $(2) ,)$(1)
endef
# Substitute reference to License text file in Modern UI examples
# with source file to enable their compilation with makensis
define SANITIZE_MODERN_UI
for f in $$(find "$(1)" -type f -name '*.nsi' -print0 | xargs -0 -n 1 basename); \
do \
sed -i \
-e "s&\$${NSISDIR}\\\\Docs\\\\Modern UI\\\\License.txt&$${f}&g" \
"$(1)/$${f}"; \
done
endef
# Replace duplicate files with symbolic link
define SYMLINK_DUPLICATES
for f in $$(ls -1 "$(1)"); \
do \
cmp -s "$(1)/$${f}" "$(2)/$${f}"; \
if [ $$? -eq 0 ]; \
then \
ln -sf "$(3)/$${f}" "$(2)/$${f}"; \
echo $${f}; \
fi; \
done
endef
%:
dh "$@"
override_dh_auto_clean:
# Remove build directory instead of removing target files
# via Scons due to pull in of dependencies.
-rm -rf .sconf_temp .sconsign.dblite SCons/Tools/__pycache__ SCons/Tools/crossmingw.pyc build config.log .test $(BUILDDIR) $(TESTDIR)
-rm -f Source/exehead/sconf.h Source/version.h Source/defines.h config.log
$(BUILDDIR)/NEWS:
scons $(SCONSOPTS_HOST) Docs/src; \
html2text -nobs "$(BUILDDIR)/$(BUILDTYPE)/Docs/html/AppendixF.html" | \
sed -e '0,/^\*\*\*\*\*/c\NSIS Release Notes (automatically converted from AppendixF.html)' -e 's/F\.[.0-9]* //g' -e 's/^\*\*\*\** *\([^*]*\) *\**\*\*\*/\n\1\n/g' -e '/Changelog/d' -e '/^NSIS_1.x_version_history/,/^=/c\ http://nsis.sourceforge.net/download/nsis1/' -e 's/^\(Released.*\)/ \1\n/g' | cat -s > "$@"
# Convert DocBook to man page
$(BUILDDIR)/%.1: debian/%.xml
xsltproc --nonet --output $@ $<
override_dh_auto_build-arch: $(BUILDDIR)/NEWS $(BUILDDIR)/GenPat.1 $(BUILDDIR)/makensis.1
scons $(SCONSOPTS_HOST) utils makensis
override_dh_auto_build-indep: $(BUILDDIR)/NEWS
scons $(SCONSOPTS_HOST) makensis
ifdef XGCC_W32_X86_PATH
scons $(SCONSOPTS_COMMON) $(SCONSOPTS_X86) stubs plugins utils
endif
ifdef XGCC_W32_AMD64_PATH
scons $(SCONSOPTS_COMMON) $(SCONSOPTS_AMD64) stubs plugins utils
endif
$(call HTML2TEXT_PRETTY,"Contrib/Modern UI/Readme.html","$(BUILDDIR)/README.Modern UI")
$(call HTML2TEXT_PRETTY,"Contrib/Modern UI 2/Readme.html","$(BUILDDIR)/README.Modern UI 2")
$(call HTML2TEXT_PRETTY,Contrib/VPatch/Readme.html,$(BUILDDIR)/README.VPatch)
$(call HTML2TEXT_PRETTY,Contrib/InstallOptions/Readme.html,$(BUILDDIR)/README.InstallOptions)
$(call HTML2TEXT_PRETTY,Contrib/MultiUser/Readme.html,$(BUILDDIR)/README.MultiUser)
$(call HTML2TEXT_PRETTY,Contrib/nsDialogs/Readme.html,$(BUILDDIR)/README.nsDialogs)
override_dh_auto_test-arch:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
scons $(SCONSOPTS_HOST) test-code
endif
override_dh_auto_test-indep:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
test -x "$(BUILDDIR)/$(BUILDTYPE)/makensis/makensis" && \
scons $(INSTALL_FLAGS_nsis) PREFIX_DEST="$(TESTDIR)"\
install-compiler install-conf && \
scons $(INSTALL_FLAGS_nsis-doc) PREFIX_DEST="$(TESTDIR)"\
install-examples && \
scons $(INSTALL_FLAGS_nsis-common) $(SCONSOPTS_X86) PREFIX_DEST="$(TESTDIR)" \
$(INSTALL_nsis-common) && \
scons $(INSTALL_FLAGS_nsis-common) $(SCONSOPTS_AMD64) PREFIX_DEST="$(TESTDIR)" \
$(INSTALL_nsis-common) && \
$(call SANITIZE_MODERN_UI,$(TESTDIR)$(DOCDIR)/Examples/Modern UI) && \
for script_path in $(TESTDIR)$(SCRIPTS_PATH)/*.nsi \
$(TESTDIR)$(SCRIPTS_PATH)/*/*.nsi; do \
script=$${script_path#$(TESTDIR)$(SCRIPTS_PATH)/}; \
if [ "$${script%/*}" != "$${script}" ]; then \
mkdir -p "$(TESTDIR)/$${script%/*}"; \
fi; \
case $${script} in \
$(IGNORE_TESTS)) ;; \
*) \
if [ -f "$${script_path}" ]; then \
PATH=$(TESTDIR)$(PREFIX)/bin:$(PATH) \
NSISDIR=$(TESTDIR)$(DATADIR) \
NSISCONFDIR=$(TESTDIR)$(SYSCONF) \
"$(TESTDIR)$(PREFIX)/bin/makensis" \
"$${script_path}" \
-X"OutFile \"$(TESTDIR)/$${script%.nsi}.exe\"" \
|| exit 1; \
fi;; \
esac; \
done;
# Fail the build if libwinpthread is needed at runtime (see #722898)
test `find $(TESTDIR)$(DATADIR)/Plugins -iname "*.dll" -exec objdump -p {} \; | grep -E "file format|DLL Name" | grep -cim1 libwinpthread` -eq 0
endif
override_dh_auto_install-arch:
$(foreach p,$(shell dh_listpackages -a),$(call DO_SCONS_INSTALL,$(p)))
override_dh_fixperms-arch:
dh_fixperms
find "$(INSTDIR)/nsis/$(SYSCONF)" \
-type f -perm /111 -exec chmod a-x {} \;
override_dh_auto_install-indep:
$(foreach p,$(shell dh_listpackages -i),$(call DO_SCONS_INSTALL,$(p),$(SCONSOPTS_X86)))
$(foreach p,$(shell dh_listpackages -i),$(call DO_SCONS_INSTALL,$(p),$(SCONSOPTS_AMD64)))
# Add plugin example to nsis-pluginapi package
$(call DO_SCONS_INSTALL_EXTRA,nsis-pluginapi,$(DOCDIR)/Examples/Plugin)
# Exclude any architecture dependent binaries from nsis-common
rm -rf "$(INSTDIR)/nsis-common$(PREFIX)/bin"
# Clean up examples and documentation
# The docs file can't seem to have spaces within the file name(s)
dh_installdocs -pnsis-doc "$(BUILDDIR)/README.Modern UI" \
"$(BUILDDIR)/README.Modern UI 2"
rm "debian/nsis-doc$(DOCDIR)/Docs/Modern UI/License.txt"
rm "debian/nsis-doc$(DOCDIR)/Docs/Modern UI 2/License.txt"
rm "debian/nsis-doc$(DOCDIR)/Docs/NSISdl/License.txt"
$(call SANITIZE_MODERN_UI,$(INSTDIR)/nsis-doc$(DOCDIR)/Examples/Modern UI)
# Replace duplicate image files with symbolic links
$(call SYMLINK_DUPLICATES,$(INSTDIR)/nsis-doc$(DOCDIR)/Docs/Modern UI/images,$(INSTDIR)/nsis-doc$(DOCDIR)/Docs/Modern UI 2/images,../../Modern UI/images)
override_dh_compress-indep:
dh_compress -X.nlf -X.nsh -X.nsi -X.dll
# Adapt links to documents with those of their compressed version
if [ -d debian/nsis-doc$(DOCDIR) ]; then \
cd debian/nsis-doc$(DOCDIR) ; \
find -mindepth 2 -name \*.gz | \
sed -e 's,^\.\(.\+\)\.gz$$,\1,g' -e 's, ,%20,g' | \
xargs -i88 sh -c 'fgrep -rl "88\"" . | \
xargs -i{} sed -i -e "s|88\"|88.gz\"|g" "{}"'; \
fi
override_dh_fixperms-indep:
dh_fixperms
# Remove executable flag from data files
find "$(INSTDIR)/nsis-common$(DATADIR)" \
-type f -perm /111 -exec chmod a-x {} \;
# Fix permissions for plugin API header and library files
ifdef XGCC_W32_X86_PATH
find "$(INSTDIR)/nsis-pluginapi$(XGCC_W32_X86_PATH)" \
-type f -perm /111 -exec chmod a-x {} \;
endif
ifdef XGCC_W32_AMD64_PATH
find "$(INSTDIR)/nsis-pluginapi$(XGCC_W32_AMD64_PATH)" \
-type f -perm /111 -exec chmod a-x {} \;
endif
|