File: rules

package info (click to toggle)
nsis 2.51-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,368 kB
  • ctags: 9,644
  • sloc: cpp: 32,346; ansic: 29,335; python: 1,148; asm: 532; xml: 487; pascal: 179; makefile: 178
file content (233 lines) | stat: -rwxr-xr-x 8,690 bytes parent folder | download
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
#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# Exclude .svn directories from packages
export DH_ALWAYS_EXCLUDE=.svn

VERSION=$(shell dpkg-parsechangelog | sed -n 's/^Version: *//p')
PREFIX=/usr
DATADIR=$(PREFIX)/share/nsis
DOCDIR=$(PREFIX)/share/doc/nsis
SYSCONF=/etc
BUILDDIR=build
BUILDTYPE=release
TESTDIR=$(CURDIR)/$(BUILDDIR)/test

# Variables for Win32 cross compiler
XGCC_W32 = i686-w64-mingw32-gcc
ifneq ($(strip $(XGCC_W32)),)
	XGCC_W32_PATH = $(abspath $(shell $(XGCC_W32) -print-file-name=libkernel32.a)/../..)
	XGCC_W32_PREFIX = $(subst -gcc,-,$(XGCC_W32))
endif

# Evaluate parallel build option
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	SCONSFLAGS = -j $(NUMJOBS)
endif

# Honor hardening flags
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk
SCONSHOSTFLAGS = APPEND_CCFLAGS="-fgnu89-inline $(CFLAGS) $(CPPFLAGS)" \
  APPEND_LINKFLAGS="$(LDFLAGS)"

SCONSOPTS = $(SCONSFLAGS) VERSION=$(VERSION) \
  PREFIX=$(PREFIX) PREFIX_CONF=$(SYSCONF) CHMDOCS=0 \
  STRIP_CP=no \
  $(if $(findstring nostripfull,$(DEB_BUILD_OPTIONS)),STRIP_W32=no,)

ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
BUILDTYPE=debug
SCONSOPTS += DEBUG=yes
endif

ifdef XGCC_W32_PATH
SCONSOPTS += PREFIX_PLUGINAPI_INC=$(XGCC_W32_PATH)/include/ \
  PREFIX_PLUGINAPI_LIB=$(XGCC_W32_PATH)/lib/ \
  XGCC_W32_PREFIX=$(XGCC_W32_PREFIX)
endif

COMMA := ,

UTILS_ALL = 'Library/LibraryLocal,Library/RegTool,MakeLangId,Makensisw,NSIS Menu,UIs,SubStart,VPatch/Source/GenPat,zip2exe'

IGNORE_UTILS_NSIS   := $(subst Library/LibraryLocal$(COMMA),,$(UTILS_ALL))
IGNORE_UTILS_NSIS   := $(subst $(COMMA)VPatch/Source/GenPat,,$(IGNORE_UTILS_NSIS))
IGNORE_UTILS_COMMON := $(subst $(COMMA)Library/RegTool$,,$(UTILS_ALL))
IGNORE_UTILS_COMMON := $(subst $(COMMA)UIs,,$(IGNORE_UTILS_COMMON))

IGNORE_UTILS_CLEAN  := $(IGNORE_UTILS_COMMON)
IGNORE_UTILS_CLEAN  := $(subst Library/LibraryLocal$(COMMA),,$(UTILS_ALL))
IGNORE_UTILS_CLEAN  := $(subst $(COMMA)SubStart,,$(IGNORE_UTILS_CLEAN))
IGNORE_UTILS_CLEAN  := $(subst $(COMMA)VPatch/Source/GenPat,,$(IGNORE_UTILS_CLEAN))

SCONSOPTS_HOST   := $(SCONSHOSTFLAGS) $(SCONSOPTS) \
  SKIPUTILS=$(IGNORE_UTILS_NSIS) SKIPDOC=COPYING
SCONSOPTS_COMMON := $(SCONSOPTS) SKIPUTILS=$(IGNORE_UTILS_COMMON) \
  SKIPDOC=COPYING
SCONSOPTS_CLEAN  := $(SCONSOPTS) SKIPUTILS=$(IGNORE_UTILS_CLEAN)

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_FLAGS_nsis-doc = $(SCONSOPTS_HOST)

# Exclude test scripts which are not appropriate for POSIX platforms.
IGNORE_TESTS = makensis.nsi|gfx.nsi

# Path to .nsi scripts
SCRIPTS_PATH = $(DOCDIR)/Examples

define DO_SCONS_INSTALL
	scons $(INSTALL_FLAGS_$(1)) PREFIX_DEST="$(CURDIR)/debian/$(1)" $(INSTALL_$(1)) || exit 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:
	scons -c $(SCONSOPTS_CLEAN) 2>&1
	-rm -rf .sconf_temp .sconsign.dblite SCons/Tools/crossmingw.pyc build config.log .test $(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)/LibraryLocal.1 $(BUILDDIR)/makensis.1
	scons $(SCONSOPTS_HOST) utils makensis

override_dh_auto_build-indep: $(BUILDDIR)/NEWS
ifdef XGCC_W32_PATH
	scons $(SCONSOPTS_HOST) makensis
	scons $(SCONSOPTS_COMMON) stubs plugins utils
	html2text -style pretty -nobs -o "$(BUILDDIR)/README.Modern UI" "Contrib/Modern UI/Readme.html"
	html2text -style pretty -nobs -o "$(BUILDDIR)/README.Modern UI 2" "Contrib/Modern UI 2/Readme.html"
	html2text -style pretty -nobs -o $(BUILDDIR)/README.VPatch Contrib/VPatch/Readme.html
	html2text -style pretty -nobs -o $(BUILDDIR)/README.InstallOptions Contrib/InstallOptions/Readme.html
	html2text -style pretty -nobs -o $(BUILDDIR)/README.MultiUser Contrib/MultiUser/Readme.html
	html2text -style pretty -nobs -o $(BUILDDIR)/README.nsDialogs Contrib/nsDialogs/Readme.html
endif

override_dh_auto_test-arch:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	scons $(SCONSOPTS_HOST) test-code
endif

override_dh_auto_test-indep:
ifdef XGCC_W32_PATH
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	test -x "$(BUILDDIR)/$(BUILDTYPE)/makensis/makensis" && \
	scons $(SCONSOPTS_HOST) PREFIX_DEST="$(TESTDIR)"\
		$(INSTALL_nsis) $(INSTALL_nsis-doc) && \
	scons $(SCONSOPTS_COMMON) 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
endif

override_dh_auto_install-arch:
	$(foreach p,$(shell dh_listpackages -a),$(call DO_SCONS_INSTALL,$(p)))

override_dh_fixperms-arch:
	dh_fixperms
	find "$(CURDIR)/debian/nsis/$(SYSCONF)" \
		-type f -perm /111 -exec chmod a-x {} \;

override_dh_auto_install-indep:
ifdef XGCC_W32_PATH
	$(foreach p,$(shell dh_listpackages -i),$(call DO_SCONS_INSTALL,$(p)))
	# Exclude any architecture dependent binaries from nsis-common
	rm -rf "$(CURDIR)/debian/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,$(CURDIR)/debian/nsis-doc$(DOCDIR)/Examples/Modern UI)
	# Replace duplicate image files with symbolic links
	$(call SYMLINK_DUPLICATES,$(CURDIR)/debian/nsis-doc$(DOCDIR)/Docs/Modern UI/images,$(CURDIR)/debian/nsis-doc$(DOCDIR)/Docs/Modern UI 2/images,../../Modern UI/images)

endif

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 "$(CURDIR)/debian/nsis-common$(DATADIR)" \
		-type f -perm /111 -exec chmod a-x {} \;
	# Fix permissions for plugin API header and library files
ifdef XGCC_W32_PATH
	find "$(CURDIR)/debian/nsis-pluginapi$(XGCC_W32_PATH)" \
		-type f -perm /111 -exec chmod a-x {} \;
endif