| 1 |
#!/usr/bin/make -f |
| 2 |
# debian/rules for Free Pascal |
| 3 |
|
| 4 |
DEB_PACKAGE_NAME = fpc |
| 5 |
export DEB_BUILD_MAINT_OPTIONS := hardening=+bindnow |
| 6 |
export DH_ALWAYS_EXCLUDE := COPYING:LICENSE |
| 7 |
export LANG:=C |
| 8 |
|
| 9 |
# Documentation type to use pdf/html |
| 10 |
ifeq (${DEBDOCTYPE},) |
| 11 |
DOCTYPE=html |
| 12 |
# HTML Converter l2h/4ht/hevea or html for (default) |
| 13 |
CONVERTER=hevea |
| 14 |
else |
| 15 |
DOCTYPE=${DEBDOCTYPE} |
| 16 |
CONVERTER=${DOCTYPE} |
| 17 |
endif |
| 18 |
# Include standard dpkg-buildpackage variables |
| 19 |
include /usr/share/dpkg/architecture.mk |
| 20 |
include /usr/share/dpkg/pkg-info.mk |
| 21 |
# Undefine FPC if it was set |
| 22 |
unexport FPC |
| 23 |
# Build new compiler name |
| 24 |
CPU_SOURCE=${DEB_BUILD_ARCH_CPU} |
| 25 |
CPU_TARGET=${DEB_HOST_ARCH_CPU} |
| 26 |
# Take care that Debian uses amd64 while FPC perfers x86_64 instead |
| 27 |
CPU_SOURCE := $(subst amd64,x86_64,${CPU_SOURCE}) |
| 28 |
CPU_TARGET := $(subst amd64,x86_64,${CPU_TARGET}) |
| 29 |
# Take care that Debian uses arm64 while FPC perfers aarch64 instead |
| 30 |
CPU_SOURCE := $(subst arm64,aarch64,${CPU_SOURCE}) |
| 31 |
CPU_TARGET := $(subst arm64,aarch64,${CPU_TARGET}) |
| 32 |
# Take care that debian uses ppc64/-el while FPC prefers powerpc64 instead |
| 33 |
ifeq ($(DEB_HOST_ARCH_CPU),ppc64el) |
| 34 |
CPU_SOURCE := $(subst ppc64el,powerpc64,${CPU_SOURCE}) |
| 35 |
CPU_TARGET := $(subst ppc64el,powerpc64,${CPU_TARGET}) |
| 36 |
else |
| 37 |
CPU_SOURCE := $(subst ppc64,powerpc64,${CPU_SOURCE}) |
| 38 |
CPU_TARGET := $(subst ppc64,powerpc64,${CPU_TARGET}) |
| 39 |
endif |
| 40 |
# Shuld get rid of this one day, as it is done automatically by FPC make files |
| 41 |
ifeq ($(CPU_TARGET),m68k) |
| 42 |
PPSUF=68k |
| 43 |
endif |
| 44 |
ifeq ($(CPU_TARGET),i386) |
| 45 |
PPSUF=386 |
| 46 |
OS_TARGET=win32 |
| 47 |
endif |
| 48 |
ifeq ($(CPU_TARGET),x86_64) |
| 49 |
PPSUF=x64 |
| 50 |
OS_TARGET=win64 |
| 51 |
endif |
| 52 |
ifeq ($(CPU_TARGET),powerpc) |
| 53 |
PPSUF=ppc |
| 54 |
endif |
| 55 |
ifeq ($(CPU_TARGET),powerpc64) |
| 56 |
PPSUF=ppc64 |
| 57 |
endif |
| 58 |
ifeq ($(CPU_TARGET),alpha) |
| 59 |
PPSUF=axp |
| 60 |
endif |
| 61 |
ifeq ($(CPU_TARGET),arm) |
| 62 |
PPSUF=arm |
| 63 |
endif |
| 64 |
ifeq ($(CPU_TARGET),aarch64) |
| 65 |
PPSUF=a64 |
| 66 |
endif |
| 67 |
ifeq ($(CPU_TARGET),sparc) |
| 68 |
PPSUF=sparc |
| 69 |
endif |
| 70 |
ifeq ($(CPU_TARGET),sparc64) |
| 71 |
PPSUF=sparc64 |
| 72 |
endif |
| 73 |
ifeq ($(CPU_TARGET),mips) |
| 74 |
PPSUF=mips |
| 75 |
endif |
| 76 |
ifeq ($(CPU_TARGET),mipsel) |
| 77 |
PPSUF=mipsel |
| 78 |
endif |
| 79 |
|
| 80 |
ifneq ($(CPU_SOURCE),$(CPU_TARGET)) |
| 81 |
PPPRE=ppcross |
| 82 |
else |
| 83 |
PPPRE=ppc |
| 84 |
endif |
| 85 |
|
| 86 |
PPNEW=$(PPPRE)$(PPSUF) |
| 87 |
# Take care that Debian uses kfreebsd while FPC prefers freebsd |
| 88 |
OS_SOURCE=${DEB_BUILD_ARCH_OS} |
| 89 |
# FPC uses FPCTARGET to identify the target for which the binaries are |
| 90 |
# produced. This is generally a couple of target CPU and target OS names |
| 91 |
# separated by a dash. |
| 92 |
FPCTARGET=$(CPU_TARGET)-$(OS_TARGET) |
| 93 |
# Get version information from changelog file |
| 94 |
DEB_DATE:=$(shell date --utc --date="@${SOURCE_DATE_EPOCH}" +%Y/%m/%d) |
| 95 |
export DEB_UPSTREAM_MAIN_VERSION:=$(shell echo ${DEB_VERSION_UPSTREAM} | sed -e 's/^\([0-9\.]*\).*/\1/') |
| 96 |
DEB_BUILD=$(lastword $(subst -, ,${DEB_VERSION})) |
| 97 |
ifndef PACKAGESUFFIX |
| 98 |
export PACKAGESUFFIX=-${DEB_UPSTREAM_MAIN_VERSION} |
| 99 |
endif |
| 100 |
# Get directories |
| 101 |
INSTALL_DIR=${CURDIR}/debian/tmp |
| 102 |
BIN_DIR=${INSTALL_DIR}/usr/bin |
| 103 |
# Debian policy is to install libraries that are multi-arch coinstallable in |
| 104 |
# /usr/lib/${DEB_HOST_MULTIARCH} |
| 105 |
LIB_DIR=/usr/lib/${DEB_HOST_MULTIARCH}/${DEB_PACKAGE_NAME}/${DEB_UPSTREAM_MAIN_VERSION} |
| 106 |
DOC_DIR=${INSTALL_DIR}/usr/share/doc |
| 107 |
SRC_DIR=/usr/share/fpcsrc/${DEB_UPSTREAM_MAIN_VERSION} |
| 108 |
EXAMPLE_TEMP=${INSTALL_DIR}/usr/share/doc/fpc-${DEB_UPSTREAM_MAIN_VERSION} |
| 109 |
STY_DIR=${INSTALL_DIR}/usr/share/texmf/tex/latex/fpc-${DEB_UPSTREAM_MAIN_VERSION} |
| 110 |
# Override standard GNUE make variables |
| 111 |
ifndef MKDIR |
| 112 |
MKDIR=mkdir -p |
| 113 |
endif |
| 114 |
ifndef CP |
| 115 |
CP=cp -Rfpl |
| 116 |
endif |
| 117 |
ifndef MV |
| 118 |
MV=mv |
| 119 |
endif |
| 120 |
RM:=rm -rf |
| 121 |
# Undefine FPCDIR if it was set |
| 122 |
unexport FPCDIR |
| 123 |
NEWPP=$(CURDIR)/fpcsrc/compiler/$(PPNEW) |
| 124 |
NEWFPDOC=$(CURDIR)/fpcsrc/utils/fpdoc/fpdoc |
| 125 |
# Set default compilation options |
| 126 |
BUILDOPTS=OPT='@hardening' |
| 127 |
ifdef CROSSOPT |
| 128 |
BUILDOPTS+= CROSSOPT=${CROSSOPT} |
| 129 |
endif |
| 130 |
INSTALLOPTS=INSTALL_PREFIX=$(INSTALL_DIR)/usr PP=$(NEWPP) |
| 131 |
|
| 132 |
export GDBLIBDIR=/usr/lib |
| 133 |
|
| 134 |
BUILDOPTS+=OS_TARGET=${OS_TARGET} |
| 135 |
INSTALLOPTS+=OS_TARGET=${OS_TARGET} |
| 136 |
|
| 137 |
#export DH_VERBOSE=1 |
| 138 |
|
| 139 |
%: |
| 140 |
dh ${@} |
| 141 |
|
| 142 |
################### |
| 143 |
# Clean |
| 144 |
# |
| 145 |
|
| 146 |
clean: |
| 147 |
dh_clean |
| 148 |
${RM} fpcsrc |
| 149 |
${RM} debian/*.old |
| 150 |
find debian -name *.install.in -execdir sh -c '${RM} $$(basename {} .in)' ';' |
| 151 |
|
| 152 |
FPCMAKEFILES= |
| 153 |
makefiles: makefiles-stamp |
| 154 |
makefiles-stamp: |
| 155 |
# Regenerate make files using fpcmake. |
| 156 |
for ff in fpcsrc/*/Makefile.fpc ; do fpcmake -r -Tall -q $${ff} ; done |
| 157 |
# Make files are now generated. |
| 158 |
touch $@ |
| 159 |
|
| 160 |
################### |
| 161 |
# Debian files |
| 162 |
# |
| 163 |
|
| 164 |
debian-files: debian-files-stamp |
| 165 |
@echo "--- Creating/fixing *.install files done!" |
| 166 |
|
| 167 |
debian-files-stamp:debian/fixdeb $(wildcard debian/*.in) |
| 168 |
mv debian/control debian/control.old |
| 169 |
@echo "--- Creating/fixing *.install files" |
| 170 |
DEB_SUBST_PACKAGESUFFIX=${PACKAGESUFFIX} \ |
| 171 |
DEB_SUBST_PPCBIN=${PPNEW} \ |
| 172 |
DEB_SUBST_TARGET=${FPCTARGET} \ |
| 173 |
DEB_SUBST_DEB_HOST_MULTIARCH=${DEB_HOST_MULTIARCH} \ |
| 174 |
$< --gen-control debian/*.in |
| 175 |
# Because we use dh-exec to track units that don't need to install |
| 176 |
# everywhere, we need the <package>.install files to be executable |
| 177 |
chmod a+x debian/*.install |
| 178 |
# Ensure we fail build if contol file changed so that we update it in VCS |
| 179 |
diff -u debian/control.old debian/control |
| 180 |
touch debian-files-stamp |
| 181 |
|
| 182 |
|
| 183 |
################### |
| 184 |
# Source |
| 185 |
# |
| 186 |
|
| 187 |
prepare-source: prepare-source-stamp |
| 188 |
prepare-source-stamp: |
| 189 |
dh_testdir |
| 190 |
dh_prep |
| 191 |
# Crete sources directory |
| 192 |
${MKDIR} fpcsrc |
| 193 |
# Copy sources into it |
| 194 |
cp -at fpcsrc/ ${SRC_DIR}/* |
| 195 |
cp -at fpcsrc/compiler/ ${LIB_DIR}/msg |
| 196 |
tar -vaxf missing-sources.tar.xz |
| 197 |
|
| 198 |
# Checksum in fastcgi/fpunits.cfg & fcl-web/fpunits.cfg |
| 199 |
# Note: revert in clean target |
| 200 |
sed --in-place "s/Now/EncodeDate($(shell date --utc --date=${DEB_DATE} +'%Y, %m, %d'))/" fpcsrc/packages/fpmkunit/src/fpmkunit.pp |
| 201 |
touch prepare-source-stamp |
| 202 |
|
| 203 |
|
| 204 |
################### |
| 205 |
# Arch packages |
| 206 |
# |
| 207 |
|
| 208 |
build-arch: debian-files prepare-source makefiles build-arch-stamp |
| 209 |
build-arch-stamp: |
| 210 |
@echo "--- Building" |
| 211 |
dh_testdir |
| 212 |
# First make a new Compiler using a make cycle |
| 213 |
$(MAKE) -C fpcsrc/compiler $(CYCLEOPTS) |
| 214 |
# Then build RTL using new compiler |
| 215 |
$(MAKE) -C fpcsrc/rtl clean all $(BUILDOPTS) |
| 216 |
# Finally build packages and tools using new compiler and new RTL |
| 217 |
$(MAKE) -C fpcsrc/packages all ${BUILDOPTS} |
| 218 |
# *.fpm files contain the build directory, which results in unreproducible |
| 219 |
# builds. As this is useless anyways, let's canonize the text. |
| 220 |
find . -name "*.fpm" -exec sed --in-place "s#${CURDIR}/##" {} \; |
| 221 |
touch build-arch-stamp |
| 222 |
|
| 223 |
install-arch: build-arch install-arch-stamp |
| 224 |
install-arch-stamp: |
| 225 |
@echo "--- Installing" |
| 226 |
dh_testdir |
| 227 |
dh_testroot |
| 228 |
dh_installdirs |
| 229 |
# create all necessary directories |
| 230 |
${MKDIR} ${BIN_DIR} |
| 231 |
${MKDIR} ${STY_DIR} |
| 232 |
# Specify the compiler to use so installing will use the correct versioned dir |
| 233 |
#$(MAKE) -C fpcsrc compiler_distinstall $(INSTALLOPTS) |
| 234 |
$(MAKE) -C fpcsrc/rtl distinstall $(INSTALLOPTS) |
| 235 |
$(MAKE) -C fpcsrc/packages distinstall $(INSTALLOPTS) |
| 236 |
${CP} -t ${BIN_DIR} debian/fpc-depends |
| 237 |
${RM} ${EXAMPLE_TEMP}/ide |
| 238 |
# Copy examples to the correct doc dir |
| 239 |
/bin/bash debian/moveexamples ${EXAMPLE_TEMP} ${DOC_DIR} ${DEB_UPSTREAM_MAIN_VERSION} |
| 240 |
touch install-arch-stamp |
| 241 |
|
| 242 |
arrange-arch: install-arch arrange-arch-stamp |
| 243 |
arrange-arch-stamp: |
| 244 |
dh_testdir |
| 245 |
dh_testroot |
| 246 |
# Expected here: |
| 247 |
# usr/lib/fpc/lexyacc/yyparse.cod |
| 248 |
# usr/lib/fpc/lexyacc/yylex.cod |
| 249 |
# usr/bin/unihelper-<version> |
| 250 |
# usr/bin/ptop.rsj-<version> |
| 251 |
# usr/bin/mkx86ins-<version> |
| 252 |
# usr/bin/mkinsad-<version> |
| 253 |
# usr/bin/mkarmins-<version> |
| 254 |
# usr/bin/mka64ins-<version> |
| 255 |
# usr/bin/makeskel.rsj-<version> |
| 256 |
# usr/bin/cldrparser-<version> |
| 257 |
dh_install -a --list-missing |
| 258 |
touch arrange-arch-stamp |
| 259 |
|
| 260 |
# This is a policy required target |
| 261 |
build-indep: debian-files |
| 262 |
|
| 263 |
################### |
| 264 |
# Generic |
| 265 |
# |
| 266 |
|
| 267 |
build: build-arch |
| 268 |
install: install-arch |
| 269 |
binary: binary-arch |
| 270 |
|
| 271 |
|
| 272 |
################### |
| 273 |
# Deb building |
| 274 |
# |
| 275 |
|
| 276 |
binary-indep: install-indep |
| 277 |
@echo "--- Building: arch-indep packages" |
| 278 |
dh_testdir |
| 279 |
dh_testroot |
| 280 |
dh_installdocs -i -X.in |
| 281 |
dh_installchangelogs -i |
| 282 |
dh_install -i --list-missing |
| 283 |
dh_lintian -i |
| 284 |
dh_compress -i -X.pdf |
| 285 |
dh_fixperms |
| 286 |
dh_installdebconf -i |
| 287 |
dh_installdeb -i |
| 288 |
dh_gencontrol -i |
| 289 |
dh_md5sums -i |
| 290 |
dh_builddeb -i $(DEB_DH_BUILDDEB_ARGS) |
| 291 |
|
| 292 |
binary-arch: arrange-arch |
| 293 |
@echo "--- Building: arch packages" |
| 294 |
dh_testdir |
| 295 |
dh_testroot |
| 296 |
dh_link |
| 297 |
dh_installdocs -a -X.in |
| 298 |
dh_installchangelogs -a |
| 299 |
dh_installexamples -a |
| 300 |
dh_strip -a |
| 301 |
dh_lintian -a |
| 302 |
dh_compress -a |
| 303 |
dh_fixperms |
| 304 |
dh_installdebconf -a |
| 305 |
dh_installdeb -a |
| 306 |
dh_shlibdeps -a |
| 307 |
dh_gencontrol -a |
| 308 |
dh_md5sums -a |
| 309 |
dh_builddeb -a $(DEB_DH_BUILDDEB_ARGS) |
| 310 |
|
| 311 |
.PHONY: arrange-arch binary binary-arch build build-arch \ |
| 312 |
build-indep check-makefiles clean \ |
| 313 |
debian-files install install-arch \ |
| 314 |
makefiles prepare-source gen-control run-tests \ |
| 315 |
|
| 316 |
# Generate debian.control file |
| 317 |
gen-control: debian/control |
| 318 |
|
| 319 |
# Run upstream test suite |
| 320 |
run-tests: |
| 321 |
dpkg-source --before-build ${CURDIR} |
| 322 |
debian/tests/run-upstream-testsuite |
| 323 |
|
| 324 |
debian/%:debian/fixdeb debian/changelog debian/%.in |
| 325 |
DEB_SUBST_PACKAGESUFFIX=${PACKAGESUFFIX} \ |
| 326 |
DEB_SUBST_PPCBIN=${PPNEW} \ |
| 327 |
DEB_SUBST_TARGET=${FPCTARGET} \ |
| 328 |
DEB_SUBST_DEB_HOST_MULTIARCH=${DEB_HOST_MULTIARCH} \ |
| 329 |
$< --gen-control [email protected] |
| 330 |
|
| 331 |
lintian: |
| 332 |
lintian -I -i ../${DEB_SOURCE}_${DEB_VERSION}_${DEB_HOST_ARCH}.changes |