1#!/usr/bin/make -f 2# -*- makefile -*- 3 4# Uncomment this to turn on verbose mode. 5#export DH_VERBOSE=1 6 7# This has to be exported to make some magic below work. 8export DH_OPTIONS 9 10# Enable hardening build flags 11export DEB_BUILD_MAINT_OPTIONS=hardening=+all 12 13include /usr/share/dpkg/pkg-info.mk 14 15# These are used for cross-compiling and for saving the configure script 16# from having to guess our platform (since we know it already) 17DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) 18DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) 19DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH) 20DEB_BUILD_MULTIARCH ?= $(shell dpkg-architecture -qDEB_BUILD_MULTIARCH) 21 22DEB_TEST_TARGET ?= Experimental 23 24QGIS_BUILDDIR ?= debian/build 25 26export QT_SELECT=5 27 28QGIS_VERSION=$(shell echo $(DEB_VERSION_UPSTREAM) | sed -e 's/\+.*//') 29 30ifeq (,$(DIST)) 31 DISTRIBUTION := $(DEB_DISTRIBUTION) 32else 33 DISTRIBUTION := $(DIST) 34endif 35 36ifneq (,$(findstring -oracle,$(DISTRIBUTION))) 37 DISTRIBUTION := $(subst -oracle,,$(DISTRIBUTION)) 38 WITH_ORACLE=1 39endif 40 41QT_PLUGINS_DIR = lib/$(DEB_BUILD_MULTIARCH)/qt5/plugins 42 43ifneq ($(DISTRIBUTION),$(findstring $(DISTRIBUTION),"buster bullseye bionic focal groovy hirsute impish")) 44 DISTRIBUTION := sid 45endif 46 47DEB_BUILD_NAME ?= $(DISTRIBUTION)-$(DEB_BUILD_ARCH) 48 49QGIS_MAJOR=$(shell sed -ne 's/SET(CPACK_PACKAGE_VERSION_MAJOR "\([0-9]*\)")/\1/ip' CMakeLists.txt) 50QGIS_MINOR=$(shell sed -ne 's/SET(CPACK_PACKAGE_VERSION_MINOR "\([0-9]*\)")/\1/ip' CMakeLists.txt) 51QGIS_PATCH=$(shell sed -ne 's/SET(CPACK_PACKAGE_VERSION_PATCH "\([0-9]*\)")/\1/ip' CMakeLists.txt) 52QGIS_ABI=$(QGIS_MAJOR).$(QGIS_MINOR).$(QGIS_PATCH) 53GRASS=grass$(subst .,,$(shell pkg-config --modversion grass|cut -d. -f1,2)) 54GRASSVER=$(subst .,,$(shell pkg-config --modversion grass|cut -d. -f1)) 55GRASSABI=$(subst .,,$(shell pkg-config --modversion grass|cut -d. -f1,2,3|sed -e 's/RC/-/')) 56 57# Include percentage of started edges 58export NINJA_STATUS=[%f/%t %p] 59 60ifeq (,$(filter terse,$(DEB_BUILD_OPTIONS))) 61 NINJA_OPTS += -v 62endif 63 64ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) 65 NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) 66 MAKEFLAGS += -j$(NUMJOBS) 67 NINJA_OPTS += -j$(NUMJOBS) 68endif 69 70ifeq (,$(DISPLAY)) 71TESTMAKE=xvfb-run -a -n 1 -s "-screen 0 1280x1024x24 -dpi 96" ninja $(NINJA_OPTS) 72else 73TESTMAKE=ninja $(NINJA_OPTS) 74endif 75 76ifeq (,$(findstring $(DISTRIBUTION),"focal groovy hirsute impish sid")) 77PYTHON_LIBRARY=$(shell python3-config --ldflags | sed -e 's,-L\(.*\) -L/usr/lib -l\([^ ]*\) .*$$,\1/lib\2.so,') 78else 79PYTHON_LIBRARY=$(shell python3-config --ldflags --embed | sed -e 's,-L\(.*\) -L[^ ]* -l\([^ ]*\) .*$$,\1/lib\2.so,') 80endif 81 82CMAKE_OPTS := \ 83 -G Ninja \ 84 -DBUILDNAME=$(DEB_BUILD_NAME) \ 85 -DCMAKE_VERBOSE_MAKEFILE=1 \ 86 -DCMAKE_INSTALL_PREFIX=/usr \ 87 -DBINDINGS_GLOBAL_INSTALL=TRUE \ 88 -DSIP_GLOBAL_INSTALL=TRUE \ 89 -DPEDANTIC=TRUE \ 90 -DSERVER_SKIP_ECW=TRUE \ 91 -DQGIS_CGIBIN_SUBDIR=/usr/lib/cgi-bin \ 92 -DWITH_APIDOC=TRUE \ 93 -DGENERATE_QHP=TRUE \ 94 -DWITH_CUSTOM_WIDGETS=TRUE \ 95 -DWITH_SERVER=TRUE \ 96 -DWITH_SERVER_PLUGINS=TRUE \ 97 -DWITH_QWTPOLAR=FALSE \ 98 -DQT_PLUGINS_DIR=$(QT_PLUGINS_DIR) \ 99 -DPYTHON_LIBRARY=$(PYTHON_LIBRARY) \ 100 -DDOXYGEN_ON_DEMAND=TRUE \ 101 -DWITH_QSPATIALITE=TRUE \ 102 -DWITH_3D=TRUE \ 103 -DGEOS_LIBRARY=/usr/lib/$(DEB_BUILD_MULTIARCH)/libgeos_c.so \ 104 -DWITH_HANA=TRUE \ 105 -DWITH_PDAL=TRUE \ 106 -DWITH_EPT=TRUE \ 107 -DSUBMIT_URL="https://cdash.orfeo-toolbox.org/submit.php?project=QGIS" 108 109ifneq ($(SHA),) 110 CMAKE_OPTS += -DSHA=$(SHA) 111endif 112 113ifeq ($(GRASSVER),7) 114 CMAKE_OPTS += \ 115 -DWITH_GRASS=TRUE \ 116 -DWITH_GRASS7=TRUE \ 117 -DGRASS_PREFIX7=/usr/lib/$(GRASS) 118endif 119 120ifneq (,$(findstring $(DISTRIBUTION),"sid buster")) 121 CMAKE_OPTS += -DPOSTGRES_LIBRARY=/usr/lib/$(DEB_BUILD_MULTIARCH)/libpq.so 122endif 123 124$(shell test -f /usr/include/$(DEB_BUILD_MULTIARCH)/qt5/Qt3DExtras/qt3dextrasversion.h -a -f /usr/lib/$(DEB_BUILD_MULTIARCH)/cmake/Qt53DExtras/Qt53DExtrasConfig.cmake) 125ifneq (0,$(.SHELLSTATUS)) 126# Qt3DExtras intentionally removed from debian (#895386) and in turn ubuntu 127 CMAKE_OPTS += \ 128 -DQt53DExtras_DIR=$(realpath external/qt3dextra-headers/cmake/Qt53DExtras) \ 129 -DQT5_3DEXTRA_INCLUDE_DIR=$(realpath external/qt3dextra-headers) \ 130 -DQT5_3DEXTRA_LIBRARY=/usr/lib/$(DEB_BUILD_MULTIARCH)/libQt53DExtras.so 131endif 132 133ifneq (,$(WITH_ORACLE)) 134ifeq ($(DEB_BUILD_ARCH),amd64) 135 ORACLE_INCLUDEDIR=/usr/include/oracle/18.5/client64/ 136 ORACLE_LIBDIR=/usr/lib/oracle/18.5/client64/lib/ 137endif 138ifeq ($(DEB_BUILD_ARCH),i386) 139 ORACLE_INCLUDEDIR=/usr/include/oracle/18.5/client/ 140 ORACLE_LIBDIR=/usr/lib/oracle/18.5/client/lib/ 141endif 142 CMAKE_OPTS += \ 143 -DWITH_ORACLE=TRUE \ 144 -DORACLE_LIBDIR=$(ORACLE_LIBDIR) \ 145 -DORACLE_INCLUDEDIR=$(ORACLE_INCLUDEDIR) 146endif 147 148ifneq (,$(findstring $(DISTRIBUTION),"sid buster")) 149 CMAKE_OPTS += -DSPATIALINDEX_LIBRARY=/usr/lib/$(DEB_BUILD_MULTIARCH)/libspatialindex.so 150endif 151 152ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) 153 CMAKE_OPTS += -DCMAKE_BUILD_TYPE=Debug 154endif 155 156ifneq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) 157 CMAKE_OPTS += -DENABLE_TESTS=FALSE 158else 159 CMAKE_OPTS += -DENABLE_TESTS=TRUE -DDART_TESTING_TIMEOUT=60 -DPUSH_TO_CDASH=TRUE 160endif 161 162CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS) 163CFLAGS := $(shell dpkg-buildflags --get CFLAGS) $(CPPFLAGS) 164CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS) $(CPPFLAGS) 165LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS) 166 167ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) 168 INSTALL_PROGRAM += -s 169endif 170 171ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) 172 CFLAGS += -O0 173 CXXFLAGS += -O0 174else 175 CFLAGS += -O2 176 CXXFLAGS += -O2 177endif 178 179ifneq (,$(findstring profile,$(DEB_BUILD_OPTIONS))) 180 CFLAGS += -pg 181 CXXFLAGS += -pg 182 LDFLAGS += -pg 183endif 184 185ifeq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) 186 CFLAGS += -DNDEBUG 187 CXXFLAGS += -DNDEBUG 188endif 189 190# multi distribution support: 191# - remove lines with applicable excludes 192# - remove prefixes with applicable includes 193# - remove prefixes with not applicable excludes 194# - remove remaining comments 195 196CONTROL_EXPRESSIONS = $(DISTRIBUTION) grass$(GRASSVER) 197 198ifneq (,$(WITH_ORACLE)) 199 CONTROL_EXPRESSIONS += oracle 200endif 201 202define gentemplate 203$(2): $(1) 204 sed -r \ 205 -e '/#(.+ |)!($(subst $(eval) ,|,$(CONTROL_EXPRESSIONS)))( .+|)#/d' \ 206 -e 's/#([^#]+ |)($(subst $(eval) ,|,$(CONTROL_EXPRESSIONS)))( [^#]+|)#//g' \ 207 -e 's/#([^#]+ |)![^#]+( [^#]*|)#//g' \ 208 -e '/^#/d' \ 209 -e "s/\{DEB_BUILD_GNU_TYPE\}/$(DEB_BUILD_GNU_TYPE)/g" \ 210 -e "s/\{QGIS_ABI\}/$(QGIS_ABI)/g" \ 211 -e "s/\{GRASS\}/$(GRASS)/g" \ 212 -e "s/\{GRASSVER\}/$(GRASSVER)/g" \ 213 -e "s/\{GRASSVER_QGISABI\}/$(GRASSVER)-$(QGIS_ABI)/g" \ 214 $$^ >$$@ 215 216templates:: $(2) 217 218templateclean:: 219 rm -f $(2) 220endef 221 222$(foreach t,$(wildcard debian/*.in),$(eval $(call gentemplate,$(t),$(basename $(t))))) 223$(foreach t,$(wildcard debian/*{GRASSVER_QGIS_ABI}*),$(eval $(call gentemplate,$(t),$(subst {GRASSVER_QGIS_ABI},$(GRASSVER)-$(QGIS_ABI),$(t))))) 224$(foreach t,$(wildcard debian/*{QGIS_ABI}*),$(eval $(call gentemplate,$(t),$(subst {QGIS_ABI},$(QGIS_ABI),$(t))))) 225 226cleantemplates: 227 $(MAKE) -f debian/rules templateclean 228 $(MAKE) -f debian/rules debian/control debian/compat 229 230binary binary-arch binary-indep build build-arch build-indep clean install install-arch install-indep: templates 231 dh $@ --with python3 --parallel --builddirectory=$(QGIS_BUILDDIR) 232 233override_dh_clean: cleantemplates 234 dh_clean qgis.bin.1 235 236 -$(RM) -r $(CURDIR)/$(QGIS_BUILDDIR)/ 237 238override_dh_auto_configure: 239 dh_auto_configure -- $(CMAKE_OPTS) 240 241override_dh_auto_build: 242ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) 243 ninja $(NINJA_OPTS) -C $(QGIS_BUILDDIR) $(DEB_TEST_TARGET)Build 244 ! grep -q "<Error>" $(QGIS_BUILDDIR)/Testing/$$(head -1 $(QGIS_BUILDDIR)/Testing/TAG)/Build.xml || { \ 245 cat $(QGIS_BUILDDIR)/Testing/Temporary/LastBuild_$$(head -1 $(QGIS_BUILDDIR)/Testing/TAG).log; \ 246 ninja $(NINJA_OPTS) -C $(QGIS_BUILDDIR) $(DEB_TEST_TARGET)Submit; \ 247 false; } 248else 249 ninja $(NINJA_OPTS) -C $(QGIS_BUILDDIR) 250endif 251 252 ninja $(NINJA_OPTS) -C $(QGIS_BUILDDIR) apidoc 253 254override_dh_auto_test: test-stamp 255 256test-stamp: 257ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) 258 # Code to run the package test suite 259 rm -f $(QGIS_BUILDDIR)/.error 260 mkdir -p debian/tmp/locale/ 261 localedef -f UTF-8 -i en_US ./debian/tmp/locale/en_US.UTF-8/ 262 LOCPATH=$(CURDIR)/debian/tmp/locale/ \ 263 LC_ALL=en_US.UTF-8 \ 264 LD_LIBRARY_PATH=$(CURDIR)/$(QGIS_BUILDDIR)/output/lib:$(LD_LIBRARY_PATH) \ 265 PATH=/usr/sbin:$(PATH) \ 266 $(TESTMAKE) -C $(QGIS_BUILDDIR) $(DEB_TEST_TARGET)Test || touch $(QGIS_BUILDDIR)/.error 267 # ignore submission errors 268 -$(TESTMAKE) -C $(QGIS_BUILDDIR) $(DEB_TEST_TARGET)Submit 269 # ignore the test outcome for now 270 # ! [ -f $(QGIS_BUILDDIR)/.error ] 271else 272 @echo Skipping tests. 273endif 274 touch test-stamp 275 276override_dh_auto_install: 277 DESTDIR=$(CURDIR)/debian/tmp ninja $(NINJA_OPTS) -C $(QGIS_BUILDDIR) install 278 279 # remove unwanted files 280 $(RM) $(CURDIR)/debian/tmp/usr/share/qgis/doc/api/installdox 281 282 # replace leaflet and jquery urls 283 perl -i -p \ 284 -e 's#http://.*/leaflet.css#leaflet/leaflet.css#;s#http://.*/leaflet.js#leaflet/leaflet.js#;s#http://.*/jquery-.*.min.js#jquery-min.js#' \ 285 $(CURDIR)/debian/tmp/usr/share/qgis/doc/developersmap.html 286 287 # Don't include a copy of the world.tif also included in osgearth-data 288 $(RM) $(CURDIR)/debian/tmp/usr/share/qgis/globe/world.tif 289 290 # remove extra license files 291 -find $(CURDIR)/debian/tmp/usr/share/qgis/resources/cpt-city-qgis-min/ -name COPYING.xml -delete 292 $(RM) $(CURDIR)/debian/tmp/usr/share/qgis/doc/LICENSE 293 $(RM) $(CURDIR)/debian/tmp/usr/share/qgis/python/plugins/db_manager/LICENSE 294 $(RM) $(CURDIR)/debian/tmp/usr/share/qgis/python/plugins/MetaSearch/LICENSE.txt 295 $(RM) $(CURDIR)/debian/tmp/usr/bin/test_provider_wcs 296 $(RM) $(CURDIR)/debian/tmp/usr/bin/qgis_bench 297 $(RM) $(CURDIR)/debian/tmp/usr/share/qgis/resources/wcs-servers.json 298 299 # remove documentation outside usr/share/doc 300 $(RM) $(CURDIR)/debian/tmp/usr/share/qgis/python/plugins/db_manager/README 301 $(RM) $(CURDIR)/debian/tmp/usr/share/qgis/python/plugins/db_manager/TODO 302 303 $(RM) $(CURDIR)/debian/tmp/usr/share/qgis/resources/cpt-city-qgis-min/README-qgis.txt 304 $(RM) $(CURDIR)/debian/tmp/usr/share/qgis/resources/cpt-city-qgis-min/README.txt 305 306 # Man pages are installed by dh_installman 307 $(RM) $(CURDIR)/debian/tmp/usr/man/man1/qgis.1 308 309 # Don't ship srs.db, automatically updated in postinst with crssync 310 mv $(CURDIR)/debian/tmp/usr/share/qgis/resources/srs.db $(CURDIR)/debian/tmp/usr/share/qgis/resources/srs-template.db 311 312 # Mime info 313 install -o root -g root -d $(CURDIR)/debian/tmp/usr/share/mime/packages 314 install -o root -g root -m 644 $(CURDIR)/debian/qgis.xml $(CURDIR)/debian/tmp/usr/share/mime/packages 315 316 # qgis binaries 317 install -o root -g root -m 755 -d $(CURDIR)/debian/qgis/usr/bin 318 install -o root -g root -m 755 $(CURDIR)/debian/tmp/usr/bin/qgis $(CURDIR)/debian/qgis/usr/bin/qgis.bin 319 install -o root -g root -m 755 $(CURDIR)/debian/tmp/usr/bin/qgis_process $(CURDIR)/debian/qgis/usr/bin/qgis_process.bin 320 321 $(RM) $(CURDIR)/debian/tmp/usr/bin/qgis $(CURDIR)/debian/tmp/usr/bin/qgis_process 322 323 # qgis binary wrappers 324 sed -r \ 325 -e "s/\{GRASS\}/$(GRASS)/g" \ 326 -e "s#\{ORACLE_LIBDIR\}#$(ORACLE_LIBDIR)#g" \ 327 $(CURDIR)/debian/qgis.sh.in >$(CURDIR)/debian/qgis.sh 328 329 install -o root -g root -m 755 $(CURDIR)/debian/qgis.sh $(CURDIR)/debian/qgis/usr/bin/qgis 330 install -o root -g root -m 755 $(CURDIR)/debian/qgis.sh $(CURDIR)/debian/qgis/usr/bin/qgis_process 331 332ifneq (,$(findstring $(DISTRIBUTION),"sid impish")) 333 mkdir -p $(CURDIR)/debian/libqgis-dev 334 cd $(CURDIR)/debian/tmp && find . -name "*.sip" | tar --remove-files -cf - -T - | tar -C $(CURDIR)/debian/libqgis-dev -xf - --xform 's,\./usr/lib/python./dist-packages/qgis,usr/share/sip/qgis,' 335 find $(CURDIR)/debian/tmp/ -depth -empty -type d -delete 336endif 337 338override_dh_missing: 339 dh_missing --fail-missing 340 341override_dh_install: 342 dh_install --autodest 343 344override_dh_installchangelogs: 345 dh_installchangelogs ChangeLog 346 347override_dh_installman: 348 cp qgis.1 qgis.bin.1 349 350 dh_installman -pqgis qgis.1 qgis.bin.1 351 352override_dh_installmime: 353 dh_installmime -pqgis 354 355override_dh_python3: 356 dh_python3 357 dh_python3 usr/share/qgis/grass/scripts 358ifeq (,$(findstring $(DISTRIBUTION),"sid impish")) 359 dh_sip3 -ppython3-qgis 360endif 361 362override_dh_compress: 363 dh_compress --exclude=pdf 364 365override_dh_makeshlibs: 366ifneq (,$(WITH_ORACLE)) 367 dh_makeshlibs -Xqgis-plugin-grass -Xlibqgis-customwidgets -Xqgis-provider-oracle -- -c0 -v$(QGIS_VERSION) 368else 369 dh_makeshlibs -Xqgis-plugin-grass -Xlibqgis-customwidgets -- -c0 -v$(QGIS_VERSION) 370endif 371 372override_dh_shlibdeps: 373ifneq (,$(WITH_ORACLE)) 374 dh_shlibdeps -l/usr/lib/$(GRASS)/lib -l$(ORACLE_LIBDIR) 375else 376 dh_shlibdeps -l/usr/lib/$(GRASS)/lib 377endif 378 379override_dh_strip: 380 dh_strip --dbg-package=qgis-dbg 381 382override_dh_gencontrol: 383 dh_gencontrol -- -Vgrass:Depends="grass$(GRASSABI)" 384