File: rules

package info (click to toggle)
lazarus 4.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 275,760 kB
  • sloc: pascal: 2,341,904; xml: 509,420; makefile: 348,726; cpp: 93,608; sh: 3,387; java: 609; perl: 297; sql: 222; ansic: 137
file content (454 lines) | stat: -rwxr-xr-x 14,903 bytes parent folder | download | duplicates (2)
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
#!/usr/bin/make -f
# debian/rules for Lazarus

include /usr/share/dpkg/architecture.mk
include /usr/share/dpkg/pkg-info.mk

export DEB_BUILD_MAINT_OPTIONS := hardening=+bindnow
export DH_ALWAYS_EXCLUDE := COPYING:LICENSE
export LANG:=C

# for Salsa CI
undefine RELEASE

# Documentation type to use chm/html
ifeq (${DEBDOCTYPE},)
DOCTYPE=html
# HTML Converter chmdocs or htmldocs for documentation format (defaults to both)
CONVERTER=${DOCTYPE}docs chmdocs
else
DOCTYPE=${DEBDOCTYPE}
CONVERTER=${DOCTYPE}docs
endif
# Define FPC
ifndef FPC
FPC=/usr/bin/fpc
endif
# Set FPCVER
FPCVER=$(shell ${FPC} -iV)

OS_TARGET=$(subst kfreebsd,freebsd,${DEB_HOST_ARCH_OS})

FPCTARGET=$(CPU_TARGET)-$(OS_TARGET)
# Get version information from changelog file via pkg-info.mk
DEB_UPSTREAM_MAIN_VERSION:=$(shell echo ${DEB_VERSION_UPSTREAM} | sed -e 's/^\([0-9\.]*\).*/\1/')
DEB_UPSTREAM_NODOT_VERSION:=$(shell echo ${DEB_UPSTREAM_MAIN_VERSION} | sed -e 's/\.//g')
DEB_BUILD=$(lastword $(subst -, ,${DEB_VERSION}))
ifndef PACKAGESUFFIX
export PACKAGESUFFIX=-$(shell echo ${DEB_UPSTREAM_MAIN_VERSION} | sed -e 's/^\([0-9]*\.[0-9]*\).*/\1/')
endif
# Get directories
INSTALL_DIR_ARCH=${CURDIR}/debian/tmp
INSTALL_DIR_INDEP=${CURDIR}/debian/tmp2
BIN_DIR=${INSTALL_DIR_ARCH}/usr/bin
LIB_DIR=${INSTALL_DIR_ARCH}/usr/lib/${DEB_SOURCE}/${DEB_UPSTREAM_MAIN_VERSION}
DOC_DIR=${INSTALL_DIR_INDEP}/usr/share/doc/${DEB_SOURCE}/${DEB_UPSTREAM_MAIN_VERSION}
DOC_DIR_ARCH=${INSTALL_DIR_ARCH}/usr/share/doc/${DEB_SOURCE}/${DEB_UPSTREAM_MAIN_VERSION}
SRC_DIR=${INSTALL_DIR_INDEP}/usr/lib/${DEB_SOURCE}/${DEB_UPSTREAM_MAIN_VERSION}
# Get utils
ifndef MKDIR
MKDIR=mkdir -p
endif
ifndef CP
CP=cp -Rfpl
endif
ifndef MV
MV=mv
endif
RM:=rm -rf
# Get fpcmake from path if none is specified.
ifndef FPCMAKE
FPCMAKE=fpcmake
endif
# Set default compilation options
BUILDOPTS=USESVN2REVISIONINC=0 OPT='@hardening'
INSTALLOPTS=PREFIX=$(INSTALL_DIR_ARCH)/usr
ifndef LAZBUILD
export LAZBUILD=${CURDIR}/lazbuild --lazarusdir=../..
endif

#export DH_VERBOSE=1

%:
	dh ${@}

###################
# Clean
#

clean: clean-patched clean-make-files
	$(RM) debian/tmp2
	dh_clean
	# Make sure the debconf translations are always up-to-date
	debconf-updatepo
	# Make sure the list with timestamps is up-to-date
	# if the check fails, update with "fp-fix-timestamps update" and commit
	[ ! $$(which fp-fix-timestamps) ] || fp-fix-timestamps check

clean-patched: make-files
	@echo "--- Cleaning"
	dh_testdir
	[ ! -f Makefile ] || $(MAKE) distclean ${BUILDOPTS} LCL_PLATFORM=qt5
	[ ! -f Makefile ] || $(MAKE) distclean ${BUILDOPTS} LCL_PLATFORM=gtk2
	$(MAKE) -C docs/html clean
	find -regex '.*\.\(a\|or?\|so\.*\|ppu\|rsj\)' -delete

###################
# Debian files
#

debian-files:debian-files-stamp update-divertions-list
	@echo "--- Creating/fixing *.install files done!"

debian-files-stamp:debian/fixdeb $(wildcard debian/*.in)
	mv debian/control debian/control.old
	@echo "--- Creating/fixing *.install files"
	DEB_SUBST_PACKAGESUFFIX=${PACKAGESUFFIX} \
	DEB_SUBST_TARGET=${FPCTARGET} \
	DEB_SUBST_DEB_HOST_MULTIARCH=${DEB_HOST_MULTIARCH} \
	$< --gen-control debian/*.in
	# Ensure we fail build if contol file changed so that we update it in VCS
	diff -u debian/control.old debian/control
	${RM} debian/control.old
	touch debian-files-stamp

make-files: make-files-stamp
	@echo "--- Regenerate make files using fpcmake done!"

make-files-stamp:
	@echo "--- Regenerate make files using fpcmake"
	find * -name Makefile.fpc -exec ${FPCMAKE} -Tall '{}' +
	touch $@

clean-make-files:
	# Remove auto-generated make files.
	find * -name Makefile.fpc -execdir sh -c '${RM} $$(basename {} .fpc)' ';'
	${RM} make-files-stamp

###################
# Arch packages
#

configure: debian-files clean-make-files make-files configure-stamp
	@echo "--- Generating configuration done!"

configure-stamp:
	@echo "--- Generating configuration"
	dh_testdir
	dh_prep
	# Add version.inc, but ignore binary NMUs.
	echo \'$(DEB_VERSION)\' | sed -e 's/+b[0-9]*$$//' > ide/version.inc

	# The next line adds the revision.inc file which is missing in upstream sources
	# Normally this is a number that can be taken from inspecting the tags directory here:
	# http://svn.freepascal.org/cgi-bin/viewvc.cgi/tags/?root=lazarus
	# But let's put something there describes better what the status is.
	echo const RevisionStr = \'Debian package $(DEB_VERSION)\'\; > ide/revision.inc

	# For reproducible builds, we need the above two files to have a fixed timestamp
	# Not added to debian/source/timestamps to keep that auto-updateable for now.
	touch --no-dereference --date="@$${SOURCE_DATE_EPOCH}" ide/version.inc
	touch --no-dereference --date="@$${SOURCE_DATE_EPOCH}" ide/revision.inc

	# Now that we are done with all changes to files in the packaging, let's
	# make sure that all the timestamps are reproducible.
	fp-fix-timestamps touch

	touch configure-stamp

build-arch: debian-files configure build-arch-stamp
	@echo "--- Building arch done!"

build-arch-stamp:
	@echo "--- Building arch"
	dh_testdir
	# QT5
	${MAKE} bigide ${BUILDOPTS} LCL_PLATFORM=qt5
	${MV} $(CURDIR)/lazarus $(CURDIR)/lazarus-qt5
	# GTK2
	${MAKE} bigide ${BUILDOPTS} LCL_PLATFORM=gtk2
	${MV} $(CURDIR)/lazarus $(CURDIR)/lazarus-gtk2
	touch build-arch-stamp

install-arch: build-arch install-arch-stamp
	# Hack until we figure out why this is not called by dh sequencer
	debian/rules override_dh_installman-arch
	@echo "--- Installing arch done!"

install-arch-stamp:
	@echo "--- Installing arch"
	dh_testdir
	dh_testroot
	dh_installdirs
	# create all necessary directories
	${MKDIR} ${BIN_DIR}
	${MKDIR} ${LIB_DIR}/tools
	${MKDIR} ${LIB_DIR}/components/chmhelp/lhelp
	# Install the IDE & its accessories
	${CP} -t ${LIB_DIR} \
		$(CURDIR)/lazarus-gtk2 \
		$(CURDIR)/lazarus-qt5 \
		$(CURDIR)/lazbuild \
		$(CURDIR)/startlazarus \
		$(CURDIR)/languages
	${CP} -t ${LIB_DIR}/tools \
		$(CURDIR)/tools/lazres \
		$(CURDIR)/tools/lrstolfm \
		$(CURDIR)/tools/svn2revisioninc \
		$(CURDIR)/tools/updatepofiles
	${CP} -t ${LIB_DIR}/components/chmhelp/lhelp \
		$(CURDIR)/components/chmhelp/lhelp/lhelp
	# Install the library files. Filter out debian and .pc sub folders.
	find -name debian -prune \
	  -o -name .pc -prune \
	  -o -name lib -print \
	  -o -name units -print \
	  | xargs ${CP} --parents -t ${LIB_DIR}
	# Remove READM.txt files from output directories
	find ${LIB_DIR} '(' -name '*.or' -or -wholename '*/lib/README.txt' ')' -delete
	# Mark package as manually compilable and install them
	for package in `find -name '*.lpk' | grep -v ^./debian` ; \
	do \
		${MKDIR} `dirname "${LIB_DIR}/$${package}"` ; \
		sed -e 's@\(\W*\)<CompilerOptions>.*@\1<AutoUpdate Value="Manually"/>\n&@' "$${package}" > "${LIB_DIR}/$${package}" ; \
	done
	${CP} -t ${LIB_DIR}/components/codetools \
		$(CURDIR)/components/codetools/fpc.errore.msg
	# Install packages global links
	${CP} -t ${LIB_DIR}/packager $(CURDIR)/packager/globallinks
	# copy icons and menu entry for the XDG menu
	${MKDIR} $(INSTALL_DIR_ARCH)/usr/share/applications
	${MKDIR} $(INSTALL_DIR_ARCH)/usr/share/icons/hicolor/scalable/apps
	# Install icon and desktop files
	${CP} $(CURDIR)/images/icons/lazarus.svg $(INSTALL_DIR_ARCH)/usr/share/icons/hicolor/scalable/apps/lazarus-${DEB_UPSTREAM_NODOT_VERSION}.svg
	for sz in 16x16 32x32 48x48 64x64 128x128 256x256 ; do \
		${MKDIR} $(INSTALL_DIR_ARCH)/usr/share/icons/hicolor/$${sz}/apps ; \
		${CP} $(CURDIR)/images/icons/lazarus$${sz}.png $(INSTALL_DIR_ARCH)/usr/share/icons/hicolor/$${sz}/apps/lazarus-${DEB_UPSTREAM_NODOT_VERSION}.png ; \
	done
	sed \
		-e 's/Lazarus.*/& (${DEB_UPSTREAM_MAIN_VERSION})/' \
		-e 's/Exec=startlazarus/&-${DEB_UPSTREAM_MAIN_VERSION}/' \
		-e 's/Icon=lazarus/&-${DEB_UPSTREAM_NODOT_VERSION}/' \
		$(CURDIR)/install/lazarus.desktop > $(INSTALL_DIR_ARCH)/usr/share/applications/lazarus-${DEB_UPSTREAM_MAIN_VERSION}.desktop
	# Install configuration files
	${MKDIR} $(INSTALL_DIR_ARCH)/etc/lazarus${PACKAGESUFFIX}
	sed -e "s#__LAZARUSDIR__#/usr/lib/lazarus/${DEB_UPSTREAM_MAIN_VERSION}/#" -e 's#__FPCSRCDIR__#/usr/share/fpcsrc/$$(FPCVER)/#' ${CURDIR}/tools/install/linux/environmentoptions.xml > $(INSTALL_DIR_ARCH)/etc/lazarus${PACKAGESUFFIX}/environmentoptions.xml
	fpcsubst -d LazarusVersion=${DEB_UPSTREAM_MAIN_VERSION} -i ${CURDIR}/tools/install/linux/helpoptions.xml -o $(INSTALL_DIR_ARCH)/etc/lazarus${PACKAGESUFFIX}/helpoptions.xml
	# Install contributer list
	${MKDIR} ${DOC_DIR_ARCH}/docs
	${CP} -t ${DOC_DIR_ARCH}/docs \
		$(CURDIR)/docs/lazdoc.css \
		$(CURDIR)/docs/Contributors.txt \
		$(CURDIR)/docs/acknowledgements.txt
	find ${INSTALL_DIR_ARCH} -empty -delete

	# The following lines are taken from https://wiki.debian.org/dedup.debian.net
	# Replace duplicate files in lcl-* with symlinks
	# directories are listed to make sure the "originals" end up in nogui which the
	# gtk2 package depend on
	rdfind -outputname /dev/null -makesymlinks true \
		${LIB_DIR}/units/*/nogui \
		${LIB_DIR}/units/*/gtk2 \
		${LIB_DIR}/units/*/qt5 \
		${LIB_DIR}/components/*/*/*/nogui \
		${LIB_DIR}/components/*/*/*/gtk2 \
		${LIB_DIR}/components/*/*/*/qt5 \
		${LIB_DIR}/components/*/*/*/*/nogui \
		${LIB_DIR}/components/*/*/*/*/gtk2 \
		${LIB_DIR}/components/*/*/*/*/qt5 \
		${LIB_DIR}/components/*/*/*/*/*/nogui \
		${LIB_DIR}/components/*/*/*/*/*/gtk2 \
		${LIB_DIR}/components/*/*/*/*/*/qt5

	# Fix those symlinks to make them relative
	symlinks -r -s -c ${LIB_DIR}

	touch install-arch-stamp

override_dh_installman-arch:
	# Install man pages
	$(MAKE) -C install/man install $(INSTALLOPTS)
	for s in ${INSTALL_DIR_ARCH}/usr/share/man/man[1-9] ; do cd $${s} && for f in *.[1-9].gz ; do ${MV} $${f} $${f%%.*}-${DEB_UPSTREAM_MAIN_VERSION}."$${f#*.}" ; done ; done || true
	dh_installman -a

###################
# Documentation
#

build-doc: build-doc-stamp
	@echo "--- Building Documentation done!"

build-doc-stamp:
	@echo "--- Building Documentation"
	dh_testdir
	# Until the whole locale is properly set to include at least UTF-8 in some
	# more generic way than on a per d/rules file basis, we need to set the
	# locale here to get reproducible builds (because of sorting in index
	# pages) and to fix some characters in some documentation files that are
	# non-ascii.
	LC_ALL=C.UTF-8 $(MAKE) -C docs/html ${CONVERTER}
	touch build-doc-stamp

install-doc: build-doc install-doc-stamp
	@echo "--- Installing Documentation done!"

install-doc-stamp:
	@echo "--- Installing Documentation"
	dh_testdir
	dh_testroot
	${MAKE} -C docs/html ${DOCTYPE}install INSTALL_PREFIX=${INSTALL_DIR_INDEP}/usr INSTALL_DOCDIR=${DOC_DIR}
	cd docs ; ${CP} --parents -t ${DOC_DIR} \
	  index.html \
	  images/laztitle.svg
	find ${DOC_DIR} -empty -delete

	# The following lines are taken from https://wiki.debian.org/dedup.debian.net
	# Replace duplicate files with symlinks
	rdfind -outputname /dev/null -makesymlinks true ${DOC_DIR}
	# Fix those symlinks to make them relative
	symlinks -r -s -c ${DOC_DIR}

	touch install-doc-stamp

###################
# Source
#

install-source: clean-patched install-source-stamp
	@echo "--- Cleaning the tree and copying the source code done!"

install-source-stamp:
	@echo "--- Cleaning the tree and copying the source code"
	dh_testdir
	dh_testroot
	${MKDIR} ${SRC_DIR}
	${CP} -t ${SRC_DIR} \
		$(CURDIR)/Makefile* \
		$(CURDIR)/components \
		$(CURDIR)/converter \
		$(CURDIR)/debugger \
		$(CURDIR)/designer \
		$(CURDIR)/doceditor \
		$(CURDIR)/examples \
		$(CURDIR)/ide \
		$(CURDIR)/images \
		$(CURDIR)/lcl \
		$(CURDIR)/packager \
		$(CURDIR)/test \
		$(CURDIR)/tools

	# Remove unneeded font files
	rm ${SRC_DIR}/components/aggpas/examples/Free*.ttf
	rm ${SRC_DIR}/components/aggpas/lazarus/example/AggPas_LCLDemo?_example/Free*.ttf

	# Remove lpk file copied with previous command as hard links
	find debian -name *.lpk -delete
	# Mark packages as compilable as needed and install them
	for package in `find -name '*.lpk'` ; \
	do \
		${MKDIR} `dirname "${SRC_DIR}/$${package}"` ; \
		sed -e 's@\(\W*\)<CompilerOptions>.*@\1<AutoUpdate Value="AsNeeded"/>\n&@' "$${package}" > "${SRC_DIR}/$${package}" ; \
	done
	${RM} ${SRC_DIR}/packager/globallinks
	find ${SRC_DIR} -regex '.*\.\(bmp\|jpg\|png\|xpm\)' -delete
	$(RM) ${SRC_DIR}/components/lazreport/license*.txt
	$(RM) ${SRC_DIR}/components/codetools/fpc.errore.msg
	find ${SRC_DIR} -empty -delete

	# Fix some permissions
	find ${SRC_DIR}/components ${SRC_DIR}/ide -type f -perm /u+x,g+x,o+x \
		! \( -name "*.sh" -o -name "*.pl" \) -exec chmod a-x {} \;

	find ${SRC_DIR}/components ${SRC_DIR}/ide -type f -perm /u-x,g-x,o-x \
		\( -name "*.sh" \) -exec chmod a+x {} \;

	# Not set above, as no .sh extension
	-chmod a+x components/aggpas/examples/build_find_compile/build-*

	# .sh extension, but is not a script
	-chmod a-x components/sqldb/design/registersqldb.sh

	touch install-source-stamp

###################
# Generic
#

build: build-arch build-indep
install: install-arch install-indep
binary: binary-arch binary-indep


###################
# Deb building
#

configure-indep: configure
	@echo "--- Configure indep done!"

binary-indep: configure-indep install-doc install-source
	@echo "--- Building: arch-indep packages"
	dh_testdir
	dh_testroot
	dh_installdocs -i -X.in
	dh_installchangelogs -i
	dh_install -i --sourcedir=debian/tmp2 -Xgpl-2.0.txt -Xgpl-3.0.txt
	dh_missing --fail-missing
	dh_lintian -i
	dh_compress -i -X.pdf -X.chm -X.xct
	dh_fixperms
	dh_installdebconf -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i $(DEB_DH_BUILDDEB_ARGS)

binary-arch: install-arch
	@echo "--- Building: arch packages"
	dh_testdir
	dh_testroot
	dh_link
	dh_install -a
	dh_installdocs -a -X.in
	dh_installchangelogs -a
	dh_installexamples -a
	fpc-depends
	dh_missing --fail-missing
	dh_strip -a
	dh_compress -a
	dh_fixperms
	dh_lintian -a
	dh_installdebconf -a
	dh_installdeb -a
	dh_shlibdeps -a
	dh_gencontrol -a
	dh_md5sums -a
	dh_builddeb -a $(DEB_DH_BUILDDEB_ARGS)

.PHONY: build clean binary binary-arch \
	binary-indep debian-files build-arch \
	install install-indep install-arch \
	configure configure-indep make-files clean-make-files \
	build-doc

# Generate debian.control file
gen-control: debian/control
	@echo "Generation of $< done!"

debian/%:debian/fixdeb debian/changelog debian/%.in
	DEB_SUBST_PACKAGESUFFIX=${PACKAGESUFFIX} \
	DEB_SUBST_TARGET=${FPCTARGET} \
	DEB_SUBST_DEB_HOST_MULTIARCH=${DEB_HOST_MULTIARCH} \
	$< --gen-control $@.in

update-divertions-list:debian/lazarus-src${PACKAGESUFFIX}.preinst debian/changelog
	for package in `find -name '*.lpk' | grep -v ^./debian` ; \
	do \
		pkgName=/usr/lib/${DEB_SOURCE}/${DEB_UPSTREAM_MAIN_VERSION}/$${package#./} ; \
		echo "  dpkg-divert --package $(<F:.preinst=) --add --rename --divert $${pkgName}.orig $${pkgName}" ; \
	done >> $<.tmp
	sed -e "/#DPKG_DIVERT_FILES#/r $<.tmp" -e '/#DPKG_DIVERT_FILES#/d' -i $<
	${RM} $<.tmp

lintian:
	lintian -I -i ../${DEB_SOURCE}_${DEB_VERSION}.dsc