File: rules

package info (click to toggle)
fp-units-win 3.2.2%2Bdfsg-46
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 528 kB
  • sloc: makefile: 224; sh: 172; perl: 8
file content (332 lines) | stat: -rwxr-xr-x 8,876 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
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
#!/usr/bin/make -f
# debian/rules for Free Pascal

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

# Documentation type to use pdf/html
ifeq (${DEBDOCTYPE},)
DOCTYPE=html
# HTML Converter l2h/4ht/hevea or html for (default)
CONVERTER=hevea
else
DOCTYPE=${DEBDOCTYPE}
CONVERTER=${DOCTYPE}
endif
# Include standard dpkg-buildpackage variables
include /usr/share/dpkg/architecture.mk
include /usr/share/dpkg/pkg-info.mk
# Undefine FPC if it was set
unexport FPC
# Build new compiler name
CPU_SOURCE=${DEB_BUILD_ARCH_CPU}
CPU_TARGET=${DEB_HOST_ARCH_CPU}
# Take care that Debian uses amd64 while FPC perfers x86_64 instead
CPU_SOURCE := $(subst amd64,x86_64,${CPU_SOURCE})
CPU_TARGET := $(subst amd64,x86_64,${CPU_TARGET})
# Take care that Debian uses arm64 while FPC perfers aarch64 instead
CPU_SOURCE := $(subst arm64,aarch64,${CPU_SOURCE})
CPU_TARGET := $(subst arm64,aarch64,${CPU_TARGET})
# Take care that debian uses ppc64/-el while FPC prefers powerpc64 instead
ifeq ($(DEB_HOST_ARCH_CPU),ppc64el)
CPU_SOURCE := $(subst ppc64el,powerpc64,${CPU_SOURCE})
CPU_TARGET := $(subst ppc64el,powerpc64,${CPU_TARGET})
else
CPU_SOURCE := $(subst ppc64,powerpc64,${CPU_SOURCE})
CPU_TARGET := $(subst ppc64,powerpc64,${CPU_TARGET})
endif
# Shuld get rid of this one day, as it is done automatically  by FPC make files
ifeq ($(CPU_TARGET),m68k)
PPSUF=68k
endif
ifeq ($(CPU_TARGET),i386)
PPSUF=386
OS_TARGET=win32
endif
ifeq ($(CPU_TARGET),x86_64)
PPSUF=x64
OS_TARGET=win64
endif
ifeq ($(CPU_TARGET),powerpc)
PPSUF=ppc
endif
ifeq ($(CPU_TARGET),powerpc64)
PPSUF=ppc64
endif
ifeq ($(CPU_TARGET),alpha)
PPSUF=axp
endif
ifeq ($(CPU_TARGET),arm)
PPSUF=arm
endif
ifeq ($(CPU_TARGET),aarch64)
PPSUF=a64
endif
ifeq ($(CPU_TARGET),sparc)
PPSUF=sparc
endif
ifeq ($(CPU_TARGET),sparc64)
PPSUF=sparc64
endif
ifeq ($(CPU_TARGET),mips)
PPSUF=mips
endif
ifeq ($(CPU_TARGET),mipsel)
PPSUF=mipsel
endif

ifneq ($(CPU_SOURCE),$(CPU_TARGET))
PPPRE=ppcross
else
PPPRE=ppc
endif

PPNEW=$(PPPRE)$(PPSUF)
# Take care that Debian uses kfreebsd while FPC prefers freebsd
OS_SOURCE=${DEB_BUILD_ARCH_OS}
# FPC uses FPCTARGET to identify the target for which the binaries are
# produced. This is generally a couple of target CPU and target OS names
# separated by a dash.
FPCTARGET=$(CPU_TARGET)-$(OS_TARGET)
# Get version information from changelog file
DEB_DATE:=$(shell date --utc --date="@${SOURCE_DATE_EPOCH}" +%Y/%m/%d)
export DEB_UPSTREAM_MAIN_VERSION:=$(shell echo ${DEB_VERSION_UPSTREAM} | sed -e 's/^\([0-9\.]*\).*/\1/')
DEB_BUILD=$(lastword $(subst -, ,${DEB_VERSION}))
ifndef PACKAGESUFFIX
export PACKAGESUFFIX=-${DEB_UPSTREAM_MAIN_VERSION}
endif
# Get directories
INSTALL_DIR=${CURDIR}/debian/tmp
BIN_DIR=${INSTALL_DIR}/usr/bin
# Debian policy is to install libraries that are multi-arch coinstallable in
# /usr/lib/${DEB_HOST_MULTIARCH}
LIB_DIR=/usr/lib/${DEB_HOST_MULTIARCH}/${DEB_PACKAGE_NAME}/${DEB_UPSTREAM_MAIN_VERSION}
DOC_DIR=${INSTALL_DIR}/usr/share/doc
SRC_DIR=/usr/share/fpcsrc/${DEB_UPSTREAM_MAIN_VERSION}
EXAMPLE_TEMP=${INSTALL_DIR}/usr/share/doc/fpc-${DEB_UPSTREAM_MAIN_VERSION}
STY_DIR=${INSTALL_DIR}/usr/share/texmf/tex/latex/fpc-${DEB_UPSTREAM_MAIN_VERSION}
# Override standard GNUE make variables
ifndef MKDIR
MKDIR=mkdir -p
endif
ifndef CP
CP=cp -Rfpl
endif
ifndef MV
MV=mv
endif
RM:=rm -rf
# Undefine FPCDIR if it was set
unexport FPCDIR
NEWPP=$(CURDIR)/fpcsrc/compiler/$(PPNEW)
NEWFPDOC=$(CURDIR)/fpcsrc/utils/fpdoc/fpdoc
# Set default compilation options
BUILDOPTS=OPT='@hardening'
ifdef CROSSOPT
BUILDOPTS+= CROSSOPT=${CROSSOPT}
endif
INSTALLOPTS=INSTALL_PREFIX=$(INSTALL_DIR)/usr PP=$(NEWPP)

export GDBLIBDIR=/usr/lib

BUILDOPTS+=OS_TARGET=${OS_TARGET}
INSTALLOPTS+=OS_TARGET=${OS_TARGET}

#export DH_VERBOSE=1

%:
	dh ${@}

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

clean:
	dh_clean
	${RM} fpcsrc
	${RM} debian/*.old
	find debian -name *.install.in -execdir sh -c '${RM} $$(basename {} .in)' ';'

FPCMAKEFILES=
makefiles: makefiles-stamp
makefiles-stamp:
	# Regenerate make files using fpcmake.
	for ff in fpcsrc/*/Makefile.fpc ; do fpcmake -r -Tall -q $${ff} ; done
	# Make files are now generated.
	touch $@

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

debian-files: debian-files-stamp
	@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_PPCBIN=${PPNEW} \
	DEB_SUBST_TARGET=${FPCTARGET} \
	DEB_SUBST_DEB_HOST_MULTIARCH=${DEB_HOST_MULTIARCH} \
	$< --gen-control debian/*.in
	# Because we use dh-exec to track units that don't need to install
	# everywhere, we need the <package>.install files to be executable
	chmod a+x debian/*.install
	# Ensure we fail build if contol file changed so that we update it in VCS
	diff -u debian/control.old debian/control
	touch debian-files-stamp


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

prepare-source: prepare-source-stamp
prepare-source-stamp:
	dh_testdir
	dh_prep
	# Crete sources directory
	${MKDIR} fpcsrc
	# Copy sources into it
	cp -at fpcsrc/ ${SRC_DIR}/*
	cp -at fpcsrc/compiler/ ${LIB_DIR}/msg
	tar -vaxf missing-sources.tar.xz

	# Checksum in fastcgi/fpunits.cfg & fcl-web/fpunits.cfg
	# Note: revert in clean target
	sed --in-place "s/Now/EncodeDate($(shell date --utc --date=${DEB_DATE} +'%Y, %m, %d'))/" fpcsrc/packages/fpmkunit/src/fpmkunit.pp
	touch prepare-source-stamp


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

build-arch: debian-files prepare-source makefiles build-arch-stamp
build-arch-stamp:
	@echo "--- Building"
	dh_testdir
	# First make a new Compiler using a make cycle
	$(MAKE) -C fpcsrc/compiler $(CYCLEOPTS)
	# Then build RTL using new compiler
	$(MAKE) -C fpcsrc/rtl clean all $(BUILDOPTS)
	# Finally build packages and tools using new compiler and new RTL
	$(MAKE) -C fpcsrc/packages all ${BUILDOPTS}
	# *.fpm files contain the build directory, which results in unreproducible
	# builds. As this is useless anyways, let's canonize the text.
	find . -name "*.fpm" -exec sed --in-place "s#${CURDIR}/##" {} \;
	touch build-arch-stamp

install-arch: build-arch install-arch-stamp
install-arch-stamp:
	@echo "--- Installing"
	dh_testdir
	dh_testroot
	dh_installdirs
	# create all necessary directories
	${MKDIR} ${BIN_DIR}
	${MKDIR} ${STY_DIR}
	# Specify the compiler to use so installing will use the correct versioned dir
	#$(MAKE) -C fpcsrc compiler_distinstall $(INSTALLOPTS)
	$(MAKE) -C fpcsrc/rtl distinstall $(INSTALLOPTS)
	$(MAKE) -C fpcsrc/packages distinstall $(INSTALLOPTS)
	${CP} -t  ${BIN_DIR} debian/fpc-depends
	${RM} ${EXAMPLE_TEMP}/ide
	# Copy examples to the correct doc dir
	/bin/bash debian/moveexamples ${EXAMPLE_TEMP} ${DOC_DIR} ${DEB_UPSTREAM_MAIN_VERSION}
	touch install-arch-stamp

arrange-arch: install-arch arrange-arch-stamp
arrange-arch-stamp:
	dh_testdir
	dh_testroot
	# Expected here:
	# usr/lib/fpc/lexyacc/yyparse.cod
	# usr/lib/fpc/lexyacc/yylex.cod
	# usr/bin/unihelper-<version>
	# usr/bin/ptop.rsj-<version>
	# usr/bin/mkx86ins-<version>
	# usr/bin/mkinsad-<version>
	# usr/bin/mkarmins-<version>
	# usr/bin/mka64ins-<version>
	# usr/bin/makeskel.rsj-<version>
	# usr/bin/cldrparser-<version>
	dh_install -a --list-missing
	touch arrange-arch-stamp

# This is a policy required target
build-indep: debian-files

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

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


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

binary-indep: install-indep
	@echo "--- Building: arch-indep packages"
	dh_testdir
	dh_testroot
	dh_installdocs -i -X.in
	dh_installchangelogs -i
	dh_install -i --list-missing
	dh_lintian -i
	dh_compress -i -X.pdf
	dh_fixperms
	dh_installdebconf -i
	dh_installdeb -i
	dh_gencontrol -i
	dh_md5sums -i
	dh_builddeb -i $(DEB_DH_BUILDDEB_ARGS)

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

.PHONY: arrange-arch binary binary-arch build build-arch \
	build-indep check-makefiles clean \
	debian-files install install-arch \
	makefiles prepare-source gen-control run-tests \

# Generate debian.control file
gen-control: debian/control

# Run upstream test suite
run-tests:
	dpkg-source --before-build ${CURDIR}
	debian/tests/run-upstream-testsuite

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

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