Debian Codegraph @

debian/rules

raw symbols SCIP
1 #!/usr/bin/make -f
2 include /usr/share/dpkg/pkg-info.mk
3 include /usr/share/dpkg/buildtools.mk
4
5 # Uncomment this to turn on verbose mode.
6 #export DH_VERBOSE=1
7
8 # Exclude .svn directories from packages
9 export DH_ALWAYS_EXCLUDE=.svn
10
11 # Enable hardening
12 export DEB_BUILD_MAINT_OPTIONS=hardening=+all
13
14 VERSION=$(DEB_VERSION)
15 PREFIX=/usr
16 DATADIR=$(PREFIX)/share/nsis
17 DOCDIR=$(PREFIX)/share/doc/nsis
18 SYSCONF=/etc
19 BUILDDIR=build
20 UNICODE=yes
21 INSTDIR=$(CURDIR)/debian
22 TESTDIR=$(CURDIR)/$(BUILDDIR)/test
23
24 # Decomposition of version string
25 define SPLIT
26 $(if $(2),$(call SPLIT,$(subst $(firstword $(2)), ,$(1)),$(filter-out $(firstword $(2)), $(2))), $(1))
27 endef
28 VERSION_DECOMPOSED=$(call SPLIT,$(VERSION),. - + ~)
29 VER_MAJOR=$(firstword $(VERSION_DECOMPOSED))
30 VER_MINOR=$(word 2,$(VERSION_DECOMPOSED))
31 VER_REVISION=$(shell echo $(firstword $(subst +, ,$(word 3,$(VERSION_DECOMPOSED)))) | sed 's/[^0-9]//g')
32
33 # Variables for Win32/Win64 cross compiler
34 XGCC_W32_X86 = i686-w64-mingw32-gcc
35 XGCC_W32_X86_PATH = $(abspath $(shell $(XGCC_W32_X86) -print-file-name=libkernel32.a)/../..)
36 XGCC_W32_X86_PREFIX = $(subst -gcc,-,$(XGCC_W32_X86))
37 XGCC_W32_AMD64 = x86_64-w64-mingw32-gcc
38 XGCC_W32_AMD64_PATH = $(abspath $(shell $(XGCC_W32_AMD64) -print-file-name=libkernel32.a)/../..)
39 XGCC_W32_AMD64_PREFIX = $(subst -gcc,-,$(XGCC_W32_AMD64))
40
41
42 # Evaluate parallel build option
43 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
44 ifeq (,$(shell dh_listpackages -i))
45 NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
46 SCONSFLAGS = -j $(NUMJOBS)
47 endif
48 endif
49
50 # Honor hardening flags
51 SCONSHOSTFLAGS = APPEND_CCFLAGS="$(shell dpkg-buildflags --get CPPFLAGS) \
52 $(shell dpkg-buildflags --get CFLAGS)" \
53 APPEND_LINKFLAGS="$(shell dpkg-buildflags --get LDFLAGS)"
54
55 # Propagate CCACHE_DIR environment variable
56 ifneq (,$(CCACHE_DIR))
57 SCONSHOSTFLAGS += CC="CCACHE_DIR=\"$(CCACHE_DIR)\" $(CC)" CXX="CCACHE_DIR=\"$(CCACHE_DIR)\" $(CXX)"
58 endif
59
60 SCONSOPTS = $(SCONSFLAGS) VERSION=$(VERSION) VER_MAJOR=$(VER_MAJOR) \
61 VER_MINOR=$(VER_MINOR) VER_REVISION=$(VER_REVISION) \
62 PREFIX=$(PREFIX) PREFIX_CONF=$(SYSCONF) CHMDOCS=0 \
63 STRIP_CP=no \
64 $(if $(findstring nostripfull,$(DEB_BUILD_OPTIONS)),STRIP_W32=no,)
65
66 ifneq (,$(UNICODE),yes)
67 SCONSOPTS += UNICODE=yes
68 BUILDTYPE := u
69 endif
70
71 ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
72 SCONSOPTS += DEBUG=yes
73 BUILDTYPE := $(BUILDTYPE)debug
74 else
75 BUILDTYPE := $(BUILDTYPE)release
76 endif
77
78 ifdef XGCC_W32_X86_PATH
79 SCONSOPTS_X86 = PREFIX_PLUGINAPI_INC=$(XGCC_W32_X86_PATH)/include/ \
80 PREFIX_PLUGINAPI_LIB=$(XGCC_W32_X86_PATH)/lib/ \
81 XGCC_W32_PREFIX=$(XGCC_W32_X86_PREFIX) \
82 TARGET_ARCH=x86
83 endif
84
85 ifdef XGCC_W32_AMD64_PATH
86 SCONSOPTS_AMD64 = PREFIX_PLUGINAPI_INC=$(XGCC_W32_AMD64_PATH)/include/ \
87 PREFIX_PLUGINAPI_LIB=$(XGCC_W32_AMD64_PATH)/lib/ \
88 XGCC_W32_PREFIX=$(XGCC_W32_AMD64_PREFIX) \
89 TARGET_ARCH=amd64
90 endif
91
92 COMMA := ,
93
94 UTILS_ALL = 'Library/RegTool,MakeLangId,Makensisw,NSIS Menu,UIs,SubStart,VPatch/Source/GenPat,zip2exe'
95
96 # Only build GenPat for the host system
97 IGNORE_UTILS_NSIS := $(subst $(COMMA)VPatch/Source/GenPat,,$(UTILS_ALL))
98
99 # Build the win32 user interfaces (UIs) and RegTool
100 IGNORE_UTILS_COMMON := $(subst Library/RegTool$(COMMA),,$(UTILS_ALL))
101 IGNORE_UTILS_COMMON := $(subst $(COMMA)UIs,,$(IGNORE_UTILS_COMMON))
102
103 SCONSOPTS_HOST := $(SCONSHOSTFLAGS) $(SCONSOPTS) \
104 SKIPPLUGINS=all SKIPSTUBS=all \
105 SKIPUTILS=$(IGNORE_UTILS_NSIS) SKIPDOC=COPYING
106 SCONSOPTS_COMMON := $(SCONSOPTS) SKIPUTILS=$(IGNORE_UTILS_COMMON) \
107 SKIPDOC=COPYING
108
109 INSTALL_nsis = install-utils install-compiler install-conf
110 INSTALL_FLAGS_nsis = $(SCONSOPTS_HOST)
111 INSTALL_nsis-common = install-stubs install-plugins install-data install-utils
112 INSTALL_FLAGS_nsis-common = $(SCONSOPTS_COMMON)
113 INSTALL_nsis-pluginapi = install-pluginapi
114 INSTALL_FLAGS_nsis-pluginapi = $(SCONSOPTS_COMMON)
115 INSTALL_nsis-doc = install-examples install-doc install-docs
116 INSTALL_FLAGS_nsis-doc = $(SCONSOPTS_COMMON) \
117 SKIPPLUGINS=ExDLL SKIPSTUBS=all SKIPUTILS=$(IGNORE_UTILS_COMMON) \
118 SKIPDOC=COPYING
119
120 # Exclude test scripts which are not appropriate for POSIX platforms.
121 IGNORE_TESTS = gfx.nsi|install-per-user.nsi|install-shared.nsi|makensis.nsi
122
123 # Path to .nsi scripts
124 SCRIPTS_PATH = $(DOCDIR)/Examples
125
126 # Add contents to the given Debian package by taking
127 # INSTALL_FLAGS_<package> and INSTALL_<package> variables into account.
128 # $(1) package name, for example nsis-common
129 # $(2) additional flags for scons
130 define DO_SCONS_INSTALL
131 scons $(INSTALL_FLAGS_$(1)) $(2) PREFIX_DEST="$(INSTDIR)/$(1)" $(INSTALL_$(1)) || exit 1;
132 endef
133
134 # Add contents to the given Debian package via the path specfic target
135 # $(1) package name, for example nsis-common
136 # $(2) path specfic scons target
137 define DO_SCONS_INSTALL_EXTRA
138 scons $(INSTALL_FLAGS_$(1)) PREFIX_DEST="$(INSTDIR)/$(1)" "$(INSTDIR)/$(1)$(2)" || exit 1;
139 endef
140
141 # Select pretty style option depending on major version of html2text
142 HTML2TEXT_PRETTY_OPTION = $(shell test $$(expr \
143 $$(dpkg-query --show --showformat '$${Version}' html2text) \
144 : '\([^.]*\)') -gt 1 \
145 && echo -rcfile /usr/share/doc/html2text/examples/pretty.style \
146 || echo -style pretty)
147
148 # Convert html to text using the pretty.style configuration
149 # $(1) html formatted input file
150 # $(2) If omitted then the resulting text is written to standard output
151 # otherwise to the provided output file
152 define HTML2TEXT_PRETTY
153 html2text -nobs \
154 $(HTML2TEXT_PRETTY_OPTION) $(if $(2),-o $(2) ,)$(1)
155 endef
156
157 # Substitute reference to License text file in Modern UI examples
158 # with source file to enable their compilation with makensis
159 define SANITIZE_MODERN_UI
160 for f in $$(find "$(1)" -type f -name '*.nsi' -print0 | xargs -0 -n 1 basename); \
161 do \
162 sed -i \
163 -e "s&\$${NSISDIR}\\\\Docs\\\\Modern UI\\\\License.txt&$${f}&g" \
164 "$(1)/$${f}"; \
165 done
166 endef
167
168 # Replace duplicate files with symbolic link
169 define SYMLINK_DUPLICATES
170 for f in $$(ls -1 "$(1)"); \
171 do \
172 cmp -s "$(1)/$${f}" "$(2)/$${f}"; \
173 if [ $$? -eq 0 ]; \
174 then \
175 ln -sf "$(3)/$${f}" "$(2)/$${f}"; \
176 echo $${f}; \
177 fi; \
178 done
179 endef
180
181 %:
182 dh "$@"
183
184 override_dh_auto_clean:
185 # Remove build directory instead of removing target files
186 # via Scons due to pull in of dependencies.
187 -rm -rf .sconf_temp .sconsign.dblite SCons/Tools/__pycache__ SCons/Tools/crossmingw.pyc build config.log .test $(BUILDDIR) $(TESTDIR)
188 -rm -f Source/exehead/sconf.h Source/version.h Source/defines.h config.log
189
190 $(BUILDDIR)/NEWS:
191 scons $(SCONSOPTS_HOST) Docs/src; \
192 html2text -nobs "$(BUILDDIR)/$(BUILDTYPE)/Docs/html/AppendixF.html" | \
193 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 > "$@"
194
195 # Convert DocBook to man page
196 $(BUILDDIR)/%.1: debian/%.xml
197 xsltproc --nonet --output $@ $<
198
199 override_dh_auto_build-arch: $(BUILDDIR)/NEWS $(BUILDDIR)/GenPat.1 $(BUILDDIR)/makensis.1
200 scons $(SCONSOPTS_HOST) utils makensis
201
202 override_dh_auto_build-indep: $(BUILDDIR)/NEWS
203 scons $(SCONSOPTS_HOST) makensis
204 ifdef XGCC_W32_X86_PATH
205 scons $(SCONSOPTS_COMMON) $(SCONSOPTS_X86) stubs plugins utils
206 endif
207 ifdef XGCC_W32_AMD64_PATH
208 scons $(SCONSOPTS_COMMON) $(SCONSOPTS_AMD64) stubs plugins utils
209 endif
210 $(call HTML2TEXT_PRETTY,"Contrib/Modern UI/Readme.html","$(BUILDDIR)/README.Modern UI")
211 $(call HTML2TEXT_PRETTY,"Contrib/Modern UI 2/Readme.html","$(BUILDDIR)/README.Modern UI 2")
212 $(call HTML2TEXT_PRETTY,Contrib/VPatch/Readme.html,$(BUILDDIR)/README.VPatch)
213 $(call HTML2TEXT_PRETTY,Contrib/InstallOptions/Readme.html,$(BUILDDIR)/README.InstallOptions)
214 $(call HTML2TEXT_PRETTY,Contrib/MultiUser/Readme.html,$(BUILDDIR)/README.MultiUser)
215 $(call HTML2TEXT_PRETTY,Contrib/nsDialogs/Readme.html,$(BUILDDIR)/README.nsDialogs)
216
217 override_dh_auto_test-arch:
218 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
219 scons $(SCONSOPTS_HOST) test-code
220 endif
221
222 override_dh_auto_test-indep:
223 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
224 test -x "$(BUILDDIR)/$(BUILDTYPE)/makensis/makensis" && \
225 scons $(INSTALL_FLAGS_nsis) PREFIX_DEST="$(TESTDIR)"\
226 install-compiler install-conf && \
227 scons $(INSTALL_FLAGS_nsis-doc) PREFIX_DEST="$(TESTDIR)"\
228 install-examples && \
229 scons $(INSTALL_FLAGS_nsis-common) $(SCONSOPTS_X86) PREFIX_DEST="$(TESTDIR)" \
230 $(INSTALL_nsis-common) && \
231 scons $(INSTALL_FLAGS_nsis-common) $(SCONSOPTS_AMD64) PREFIX_DEST="$(TESTDIR)" \
232 $(INSTALL_nsis-common) && \
233 $(call SANITIZE_MODERN_UI,$(TESTDIR)$(DOCDIR)/Examples/Modern UI) && \
234 for script_path in $(TESTDIR)$(SCRIPTS_PATH)/*.nsi \
235 $(TESTDIR)$(SCRIPTS_PATH)/*/*.nsi; do \
236 script=$${script_path#$(TESTDIR)$(SCRIPTS_PATH)/}; \
237 if [ "$${script%/*}" != "$${script}" ]; then \
238 mkdir -p "$(TESTDIR)/$${script%/*}"; \
239 fi; \
240 case $${script} in \
241 $(IGNORE_TESTS)) ;; \
242 *) \
243 if [ -f "$${script_path}" ]; then \
244 PATH=$(TESTDIR)$(PREFIX)/bin:$(PATH) \
245 NSISDIR=$(TESTDIR)$(DATADIR) \
246 NSISCONFDIR=$(TESTDIR)$(SYSCONF) \
247 "$(TESTDIR)$(PREFIX)/bin/makensis" \
248 "$${script_path}" \
249 -X"OutFile \"$(TESTDIR)/$${script%.nsi}.exe\"" \
250 || exit 1; \
251 fi;; \
252 esac; \
253 done;
254 # Fail the build if libwinpthread is needed at runtime (see #722898)
255 test `find $(TESTDIR)$(DATADIR)/Plugins -iname "*.dll" -exec objdump -p {} \; | grep -E "file format|DLL Name" | grep -cim1 libwinpthread` -eq 0
256 endif
257
258 override_dh_auto_install-arch:
259 $(foreach p,$(shell dh_listpackages -a),$(call DO_SCONS_INSTALL,$(p)))
260
261 override_dh_fixperms-arch:
262 dh_fixperms
263 find "$(INSTDIR)/nsis/$(SYSCONF)" \
264 -type f -perm /111 -exec chmod a-x {} \;
265
266 override_dh_auto_install-indep:
267 $(foreach p,$(shell dh_listpackages -i),$(call DO_SCONS_INSTALL,$(p),$(SCONSOPTS_X86)))
268 $(foreach p,$(shell dh_listpackages -i),$(call DO_SCONS_INSTALL,$(p),$(SCONSOPTS_AMD64)))
269 # Add plugin example to nsis-pluginapi package
270 $(call DO_SCONS_INSTALL_EXTRA,nsis-pluginapi,$(DOCDIR)/Examples/Plugin)
271 # Exclude any architecture dependent binaries from nsis-common
272 rm -rf "$(INSTDIR)/nsis-common$(PREFIX)/bin"
273 # Clean up examples and documentation
274 # The docs file can't seem to have spaces within the file name(s)
275 dh_installdocs -pnsis-doc "$(BUILDDIR)/README.Modern UI" \
276 "$(BUILDDIR)/README.Modern UI 2"
277 rm "debian/nsis-doc$(DOCDIR)/Docs/Modern UI/License.txt"
278 rm "debian/nsis-doc$(DOCDIR)/Docs/Modern UI 2/License.txt"
279 rm "debian/nsis-doc$(DOCDIR)/Docs/NSISdl/License.txt"
280 $(call SANITIZE_MODERN_UI,$(INSTDIR)/nsis-doc$(DOCDIR)/Examples/Modern UI)
281 # Replace duplicate image files with symbolic links
282 $(call SYMLINK_DUPLICATES,$(INSTDIR)/nsis-doc$(DOCDIR)/Docs/Modern UI/images,$(INSTDIR)/nsis-doc$(DOCDIR)/Docs/Modern UI 2/images,../../Modern UI/images)
283
284 override_dh_compress-indep:
285 dh_compress -X.nlf -X.nsh -X.nsi -X.dll
286 # Adapt links to documents with those of their compressed version
287 if [ -d debian/nsis-doc$(DOCDIR) ]; then \
288 cd debian/nsis-doc$(DOCDIR) ; \
289 find -mindepth 2 -name \*.gz | \
290 sed -e 's,^\.\(.\+\)\.gz$$,\1,g' -e 's, ,%20,g' | \
291 xargs -i88 sh -c 'fgrep -rl "88\"" . | \
292 xargs -i{} sed -i -e "s|88\"|88.gz\"|g" "{}"'; \
293 fi
294
295 override_dh_fixperms-indep:
296 dh_fixperms
297 # Remove executable flag from data files
298 find "$(INSTDIR)/nsis-common$(DATADIR)" \
299 -type f -perm /111 -exec chmod a-x {} \;
300 # Fix permissions for plugin API header and library files
301 ifdef XGCC_W32_X86_PATH
302 find "$(INSTDIR)/nsis-pluginapi$(XGCC_W32_X86_PATH)" \
303 -type f -perm /111 -exec chmod a-x {} \;
304 endif
305 ifdef XGCC_W32_AMD64_PATH
306 find "$(INSTDIR)/nsis-pluginapi$(XGCC_W32_AMD64_PATH)" \
307 -type f -perm /111 -exec chmod a-x {} \;
308 endif