Debian Codegraph @

debian/rules

raw symbols SCIP
1 #!/usr/bin/make -f
2 # debian/rules for Castle Game Engine
3
4 include /usr/share/dpkg/pkg-info.mk
5 export DH_ALWAYS_EXCLUDE := COPYING:LICENSE
6 export LANG:=C
7
8 # Documentation type to use chm/html
9 ifeq (${DEBDOCTYPE},)
10 DOCTYPE=html
11 # HTML Converter chmdocs or htmldocs for (default)
12 CONVERTER=${DOCTYPE}docs
13 else
14 DOCTYPE=${DEBDOCTYPE}
15 CONVERTER=${DOCTYPE}docs
16 endif
17 # Define FPC
18 ifndef FPC
19 FPC=/usr/bin/fpc
20 endif
21 # Set FPCVER
22 FPCVER=$(shell ${FPC} -iV)
23
24 CPU_TARGET?=$(shell ${FPC} -iTP)
25 OS_TARGET?=$(shell ${FPC} -iTO)
26 FPCTARGET=${CPU_TARGET}-${OS_TARGET}
27 export CGE_VERSION=$(shell echo ${DEB_VERSION_UPSTREAM} | sed -e 's/^\([0-9\.]*\).*/\1/')
28 DEB_BUILD=$(lastword $(subst -, ,${DEB_VERSION}))
29 # Get directories
30 INSTALL_DIR=$(CURDIR)/debian/tmp
31 CFG_DIR=${INSTALL_DIR}/etc/fpc-${FPCVER}.cfg.d
32 LIB_PREFIX=${INSTALL_DIR}/usr/lib
33 LIB_DIR=${LIB_PREFIX}/${DEB_SOURCE}
34 SRC_DIR=$(CURDIR)/debian/src/${DEB_SOURCE}-${CGE_VERSION}
35 TMP_DIR=${INSTALL_DIR}/tmp
36 # Define units installation default directory as recommended by Debian FPC Team
37 UNITS_DIR=${LIB_PREFIX}/${DEB_HOST_MULTIARCH}/${DEB_SOURCE}/fp-units/${FPCVER}
38
39 # Set default compilation options
40 BUILDOPTS=\
41 --compiler-option=@${CURDIR}/castle-fpc.cfg \
42
43 # Get utils
44 ifndef MKDIR
45 MKDIR=mkdir -p
46 endif
47 ifndef CP
48 CP=cp -Rfpl
49 endif
50 RM:=rm -rf
51
52 #export DH_VERBOSE=1
53
54 %:
55 dh ${@}
56
57 override_dh_auto_clean:
58 ${MAKE} clean
59 $(MAKE) strip-precompiled-libraries
60 dh_auto_clean
61 # Make sure the list with timestamps is up-to-date
62 # if the check fails, update with "fp-fix-timestamps update" and commit
63 [ ! $$(which fp-fix-timestamps) ] || fp-fix-timestamps check
64
65 prepare-source: prepare-source-stamp
66 prepare-source-stamp:
67 # Building Pascal style font file first while making sure that
68 # no unit or object files polute the source tree
69 ${MKDIR} ${TMP_DIR}
70 ${FPC} -FE${TMP_DIR} @castle-fpc.cfg \
71 -otexture-font-to-pascal \
72 tools/texture-font-to-pascal/texture_font_to_pascal.lpr
73 cd src/fonts ; PATH=${PATH}:${TMP_DIR} ./mk_fonts.sh /usr/share/fonts/truetype/dejavu
74
75 # cge embeds some images from xcf via png into Pascal source files
76 # First we need to create the pngs
77 for pngfile in $$(grep \\\.png\$$ debian/clean) ; do convert -layers flatten -background transparent $${pngfile%.png}.xcf $${pngfile} ; done
78 # Then we build the helper function
79 ${FPC} -FE${TMP_DIR} -dRELEASE @castle-fpc.cfg \
80 -oimage-to-pascal \
81 tools/image-to-pascal/image_to_pascal.lpr
82 # To finally convert png files to pas file
83 PATH=${TMP_DIR} ${MAKE} -C src/ui/gui-images all
84
85 # Upstream source contains auto-generated include files. Let's generate
86 # them again.
87 ${FPC} -FE${TMP_DIR} -dRELEASE @castle-fpc.cfg \
88 -Futools/internal/x3d-nodes-to-pascal/code \
89 -ox3d-nodes-to-pascal \
90 tools/internal/x3d-nodes-to-pascal/x3d_nodes_to_pascal.lpr
91 cd tools/internal/x3d-nodes-to-pascal/ && \
92 PATH=${TMP_DIR} x3d-nodes-to-pascal \
93 --input-path nodes-specification/ \
94 --output-path ../../../src/scene/x3d/auto_generated_node_helpers/
95
96 # For reproducible builds we need to make sure the timestamp of the just
97 # created files is fixed. Let's use SOURCE_DATE_EPOCH for that. For the
98 # future, this needs to be even smarter, because now every Debian revision
99 # will require all the reverse dependencies generating ppu files to be
100 # rebuild.
101 touch --no-dereference --date="@$${SOURCE_DATE_EPOCH}" \
102 src/scene/x3d/auto_generated_node_helpers/*.inc \
103 src/fonts/castletexturefont_*.pas \
104 src/ui/castlecontrols_*.inc
105 # And touch patched files
106 fp-fix-timestamps touch
107
108 touch prepare-source-stamp
109
110 # Annoying thing is we need to do this very early to save lots of overhead. If
111 # it can be done on a clean tree, right after prepare-source we don't need
112 # cleaning, right.
113 install-source: install-source-stamp
114 install-source-stamp:
115 @echo "--- Copying the source code"
116 dh_testdir
117 ${MKDIR} ${SRC_DIR}
118 ${CP} -t ${SRC_DIR} \
119 $(CURDIR)/src/*
120 # Remove statically linked libraries and object files from source packages
121 find ${SRC_DIR} -name '*.a' -o -name '*.o' -o -name '*.obj' -delete
122 # Fix files permission
123 find $(SRC_DIR) -name '*.bmp' -o -name '*.pas' -exec chmod 644 '{}' ';'
124 # Remove empty directories
125 find ${SRC_DIR} -empty -delete
126 touch install-source-stamp
127
128 override_dh_auto_build-arch: prepare-source install-source
129 # Build the real engine
130 ${MAKE} build-using-fpmake tools CASTLE_ENGINE_TOOL_OPTIONS='$(BUILDOPTS)'
131 # Generate man pages
132 ${MAKE} -C doc/man/man1
133
134 override_dh_auto_install-arch:
135 # Install units
136 ${MKDIR} ${UNITS_DIR}
137 ${CP} -t ${UNITS_DIR} units/${FPCTARGET}/*
138 # Mark package as manually compilable and install them
139 for package in $$(find * -name '*.lpk') ; \
140 do \
141 pkgDir=$$(dirname "${LIB_DIR}/$${package}") ; \
142 ${MKDIR} "$${pkgDir}" ; \
143 sed -e 's@\(\W*\)<CompilerOptions>.*@\1<AutoUpdate Value="Manually"/>\n&@' \
144 -e "s@\.\./src/@$$(relpath ${SRC_DIR} $${pkgDir})/@g" \
145 -e "s@\(\W*\)<UnitOutputDirectory .*@<UnitOutputDirectory Value=\"$$(relpath ${UNITS_DIR} $${pkgDir})\"/>@" \
146 "$${package}" > "${LIB_DIR}/$${package}" ; \
147 done
148 # Call upstream install target for the tools
149 ${MAKE} PREFIX=${INSTALL_DIR}/usr install
150 # Install configration file so we can use: fpc @castle-game-engine progname
151 ${MKDIR} ${CFG_DIR}
152 ${CP} debian/castle-game-engine.cfg ${CFG_DIR}/castle-game-engine
153 # Perform cleanup
154 find ${INSTALL_DIR} -empty -delete
155 fpc-depends
156
157 override_dh_auto_build-indep: prepare-source install-source
158 @echo "--- Building Documentation"
159 # Create logo first, before generating documentation
160 ${MAKE} -C doc/pasdoc/logo
161 ${MAKE} -C doc/pasdoc ${DOCTYPE}
162 # pasdoc create a jquery file, but we link from jquery instead
163 ${RM} doc/reference/tipuesearch/jquery.min.js
164 # Remove .npmignore file as Lintian complains about it.
165 ${RM} doc/reference/castle-engine-website-base/node_modules/slick-carousel/.npmignore
166 # Remove windows executable files as Lintian complains about them.
167 ${RM} tools/contrib/x86_64-win64
168
169 override_dh_auto_install-indep: install-source
170
171 execute_before_dh_debputy:
172 mkdir -p ${INSTALL_DIR}/packages
173 echo 'If you are looking for CGE documentation, please install the package named' > ${INSTALL_DIR}/packages/README.txt
174 echo 'castle-game-engine-doc.' >> ${INSTALL_DIR}/packages/README.txt
175
176 .PHONY:prepare-source install-source
177
178 lintian:
179 lintian -I -i ../${DEB_SOURCE}_${DEB_VERSION}.dsc