QGIS/debian/rules
2023-10-02 12:02:08 +02:00

388 lines
12 KiB
Makefile
Executable File

#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
# This has to be exported to make some magic below work.
export DH_OPTIONS
# Enable hardening build flags
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export DEB_PYTHON_INSTALL_LAYOUT=deb_system
include /usr/share/dpkg/pkg-info.mk
# These are used for cross-compiling and for saving the configure script
# from having to guess our platform (since we know it already)
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
DEB_BUILD_MULTIARCH ?= $(shell dpkg-architecture -qDEB_BUILD_MULTIARCH)
DEB_TEST_TARGET ?= Experimental
QGIS_BUILDDIR ?= debian/build
export QGIS_TEST_ACCEPT_GITSTATUS_CHECK_FAILURE=1
export QT_SELECT=5
QGIS_VERSION=$(shell echo $(DEB_VERSION_UPSTREAM) | sed -e 's/\+.*//')
ifeq (,$(DIST))
DISTRIBUTION := $(DEB_DISTRIBUTION)
else
DISTRIBUTION := $(DIST)
endif
ifneq (,$(findstring -oracle,$(DISTRIBUTION)))
DISTRIBUTION := $(subst -oracle,,$(DISTRIBUTION))
WITH_ORACLE=1
endif
QT_PLUGINS_DIR = lib/$(DEB_BUILD_MULTIARCH)/qt5/plugins
ifneq ($(DISTRIBUTION),$(findstring $(DISTRIBUTION),"bullseye bookworm jammy kinetic lunar"))
DISTRIBUTION := sid
endif
DEB_BUILD_NAME ?= $(DISTRIBUTION)-$(DEB_BUILD_ARCH)
QGIS_MAJOR=$(shell sed -ne 's/SET(CPACK_PACKAGE_VERSION_MAJOR "\([0-9]*\)")/\1/ip' CMakeLists.txt)
QGIS_MINOR=$(shell sed -ne 's/SET(CPACK_PACKAGE_VERSION_MINOR "\([0-9]*\)")/\1/ip' CMakeLists.txt)
QGIS_PATCH=$(shell sed -ne 's/SET(CPACK_PACKAGE_VERSION_PATCH "\([0-9]*\)")/\1/ip' CMakeLists.txt)
QGIS_ABI=$(QGIS_MAJOR).$(QGIS_MINOR).$(QGIS_PATCH)
GRASS=grass$(subst .,,$(shell pkg-config --modversion grass|cut -d. -f1,2))
GRASSVER=$(subst .,,$(shell pkg-config --modversion grass|cut -d. -f1))
GRASSABI=$(subst .,,$(shell pkg-config --modversion grass|cut -d. -f1,2,3|sed -e 's/RC/-/'))
# Include percentage of started edges
export NINJA_STATUS=[%f/%t %p]
ifeq (,$(filter terse,$(DEB_BUILD_OPTIONS)))
NINJA_OPTS += -v
endif
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
MAKEFLAGS += -j$(NUMJOBS)
NINJA_OPTS += -j$(NUMJOBS)
endif
ifeq (,$(DISPLAY))
TESTMAKE=xvfb-run -a -n 1 -s "-screen 0 1280x1024x24 -dpi 96" ninja $(NINJA_OPTS)
else
TESTMAKE=ninja $(NINJA_OPTS)
endif
PYTHON_LIBRARY=$(shell python3-config --ldflags --embed | sed -e 's,-L\(.*\) -L[^ ]* -l\([^ ]*\) .*$$,\1/lib\2.so,')
CMAKE_OPTS := \
-G Ninja \
-DBUILDNAME=$(DEB_BUILD_NAME) \
-DCMAKE_VERBOSE_MAKEFILE=1 \
-DCMAKE_INSTALL_PREFIX=/usr \
-DBINDINGS_GLOBAL_INSTALL=TRUE \
-DSIP_GLOBAL_INSTALL=TRUE \
-DPEDANTIC=TRUE \
-DSERVER_SKIP_ECW=TRUE \
-DQGIS_CGIBIN_SUBDIR=/usr/lib/cgi-bin \
-DWITH_APIDOC=TRUE \
-DGENERATE_QHP=TRUE \
-DWITH_CUSTOM_WIDGETS=TRUE \
-DWITH_SERVER=TRUE \
-DWITH_SERVER_PLUGINS=TRUE \
-DWITH_QWTPOLAR=FALSE \
-DQT_PLUGINS_DIR=$(QT_PLUGINS_DIR) \
-DPYTHON_LIBRARY=$(PYTHON_LIBRARY) \
-DDOXYGEN_ON_DEMAND=TRUE \
-DWITH_QSPATIALITE=TRUE \
-DWITH_3D=TRUE \
-DGEOS_LIBRARY=/usr/lib/$(DEB_BUILD_MULTIARCH)/libgeos_c.so \
-DWITH_HANA=TRUE \
-DWITH_EPT=TRUE \
-DSUBMIT_URL="https://cdash.orfeo-toolbox.org/submit.php?project=QGIS"
ifneq ($(SHA),)
CMAKE_OPTS += -DSHA=$(SHA)
endif
ifneq (,$(findstring $(DISTRIBUTION),"jammy bullseye"))
CMAKE_OPTS += -DWITH_PDAL=TRUE
else
CMAKE_OPTS += -DWITH_PDAL=FALSE
endif
ifneq (,$(findstring ;$(GRASSVER);, ";7;8;"))
CMAKE_OPTS += \
-DWITH_GRASS=TRUE \
-DWITH_GRASS$(GRASSVER)=TRUE \
-DGRASS_PREFIX$(GRASSVER)=/usr/lib/$(GRASS)
endif
ifneq (,$(findstring $(DISTRIBUTION),"sid kinetic lunar"))
CMAKE_OPTS += -DGDAL_LIBRARY=/usr/lib/$(DEB_BUILD_MULTIARCH)/libgdal.so
endif
$(shell test -f /usr/include/$(DEB_BUILD_MULTIARCH)/qt5/Qt3DExtras/qt3dextrasversion.h -a -f /usr/lib/$(DEB_BUILD_MULTIARCH)/cmake/Qt53DExtras/Qt53DExtrasConfig.cmake)
ifneq (0,$(.SHELLSTATUS))
# Qt3DExtras intentionally removed from debian (#895386) and in turn ubuntu
CMAKE_OPTS += \
-DQt53DExtras_DIR=$(realpath external/qt3dextra-headers/cmake/Qt53DExtras) \
-DQT5_3DEXTRA_INCLUDE_DIR=$(realpath external/qt3dextra-headers) \
-DQT5_3DEXTRA_LIBRARY=/usr/lib/$(DEB_BUILD_MULTIARCH)/libQt53DExtras.so
endif
ifneq (,$(WITH_ORACLE))
ifeq ($(DEB_BUILD_ARCH),amd64)
ORACLE_INCLUDEDIR=/usr/include/oracle/21/client64/
ORACLE_LIBDIR=/usr/lib/oracle/21/client64/lib/
endif
ifeq ($(DEB_BUILD_ARCH),i386)
ORACLE_INCLUDEDIR=/usr/include/oracle/21/client/
ORACLE_LIBDIR=/usr/lib/oracle/21/client/lib/
endif
CMAKE_OPTS += \
-DWITH_ORACLE=TRUE \
-DORACLE_LIBDIR=$(ORACLE_LIBDIR) \
-DORACLE_INCLUDEDIR=$(ORACLE_INCLUDEDIR)
endif
ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
CMAKE_OPTS += -DCMAKE_BUILD_TYPE=Debug
endif
ifneq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
CMAKE_OPTS += -DENABLE_TESTS=FALSE
else
CMAKE_OPTS += -DENABLE_TESTS=TRUE -DDART_TESTING_TIMEOUT=60 -DPUSH_TO_CDASH=TRUE
endif
CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS)
CFLAGS := $(shell dpkg-buildflags --get CFLAGS) $(CPPFLAGS)
CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS) $(CPPFLAGS)
LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
INSTALL_PROGRAM += -s
endif
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
CXXFLAGS += -O0
else
CFLAGS += -O2
CXXFLAGS += -O2
endif
ifneq (,$(findstring profile,$(DEB_BUILD_OPTIONS)))
CFLAGS += -pg
CXXFLAGS += -pg
LDFLAGS += -pg
endif
ifeq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
CFLAGS += -DNDEBUG
CXXFLAGS += -DNDEBUG
endif
# multi distribution support:
# - remove lines with applicable excludes
# - remove prefixes with applicable includes
# - remove prefixes with not applicable excludes
# - remove remaining comments
CONTROL_EXPRESSIONS = $(DISTRIBUTION) grass$(GRASSVER)
ifneq (,$(WITH_ORACLE))
CONTROL_EXPRESSIONS += oracle
endif
ifeq ($(shell pkg-config --exists pdal && dpkg --compare-versions $$(pkg-config --modversion pdal) ge 2.5 && echo 1 || echo 0),1)
CONTROL_EXPRESSIONS += pdal_wrench
endif
define gentemplate
$(2): $(1)
sed -r \
-e '/#(.+ |)!($(subst $(eval) ,|,$(CONTROL_EXPRESSIONS)))( .+|)#/d' \
-e 's/#([^#]+ |)($(subst $(eval) ,|,$(CONTROL_EXPRESSIONS)))( [^#]+|)#//g' \
-e 's/#([^#]+ |)![^#]+( [^#]*|)#//g' \
-e '/^#/d' \
-e "s/\{DEB_BUILD_GNU_TYPE\}/$(DEB_BUILD_GNU_TYPE)/g" \
-e "s/\{QGIS_ABI\}/$(QGIS_ABI)/g" \
-e "s/\{GRASS\}/$(GRASS)/g" \
-e "s/\{GRASSVER\}/$(GRASSVER)/g" \
-e "s/\{GRASSVER_QGISABI\}/$(GRASSVER)-$(QGIS_ABI)/g" \
$$^ >$$@
templates:: $(2)
templateclean::
rm -f $(2)
endef
$(foreach t,$(wildcard debian/*.in),$(eval $(call gentemplate,$(t),$(basename $(t)))))
$(foreach t,$(wildcard debian/*{GRASSVER_QGIS_ABI}*),$(eval $(call gentemplate,$(t),$(subst {GRASSVER_QGIS_ABI},$(GRASSVER)-$(QGIS_ABI),$(t)))))
$(foreach t,$(wildcard debian/*{QGIS_ABI}*),$(eval $(call gentemplate,$(t),$(subst {QGIS_ABI},$(QGIS_ABI),$(t)))))
cleantemplates:
$(MAKE) -f debian/rules templateclean
$(MAKE) -f debian/rules debian/control debian/compat
binary binary-arch binary-indep build build-arch build-indep clean install install-arch install-indep: templates
dh $@ --with python3 --parallel --builddirectory=$(QGIS_BUILDDIR)
override_dh_clean: cleantemplates
dh_clean qgis.bin.1
-$(RM) -r $(CURDIR)/$(QGIS_BUILDDIR)/
override_dh_auto_configure:
dh_auto_configure -- $(CMAKE_OPTS)
override_dh_auto_build:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
ninja $(NINJA_OPTS) -C $(QGIS_BUILDDIR) $(DEB_TEST_TARGET)Build
! grep -q "<Error>" $(QGIS_BUILDDIR)/Testing/$$(head -1 $(QGIS_BUILDDIR)/Testing/TAG)/Build.xml || { \
cat $(QGIS_BUILDDIR)/Testing/Temporary/LastBuild_$$(head -1 $(QGIS_BUILDDIR)/Testing/TAG).log; \
ninja $(NINJA_OPTS) -C $(QGIS_BUILDDIR) $(DEB_TEST_TARGET)Submit; \
false; }
else
ninja $(NINJA_OPTS) -C $(QGIS_BUILDDIR)
endif
ninja $(NINJA_OPTS) -C $(QGIS_BUILDDIR) apidoc
override_dh_auto_test: test-stamp
test-stamp:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
# Code to run the package test suite
rm -f $(QGIS_BUILDDIR)/.error
mkdir -p debian/tmp/locale/
localedef -f UTF-8 -i en_US ./debian/tmp/locale/en_US.UTF-8/
LOCPATH=$(CURDIR)/debian/tmp/locale/ \
LC_ALL=en_US.UTF-8 \
LD_LIBRARY_PATH=$(CURDIR)/$(QGIS_BUILDDIR)/output/lib:$(LD_LIBRARY_PATH) \
PATH=/usr/sbin:$(PATH) \
$(TESTMAKE) -C $(QGIS_BUILDDIR) $(DEB_TEST_TARGET)Test || touch $(QGIS_BUILDDIR)/.error
# ignore submission errors
-$(TESTMAKE) -C $(QGIS_BUILDDIR) $(DEB_TEST_TARGET)Submit
# ignore the test outcome for now
# ! [ -f $(QGIS_BUILDDIR)/.error ]
else
@echo Skipping tests.
endif
touch test-stamp
override_dh_auto_install:
DESTDIR=$(CURDIR)/debian/tmp ninja $(NINJA_OPTS) -C $(QGIS_BUILDDIR) install
# remove unwanted files
$(RM) $(CURDIR)/debian/tmp/usr/share/qgis/doc/api/installdox
# replace leaflet and jquery urls
perl -i -p \
-e 's#http://.*/leaflet.css#leaflet/leaflet.css#;s#http://.*/leaflet.js#leaflet/leaflet.js#;s#http://.*/jquery-.*.min.js#jquery-min.js#' \
$(CURDIR)/debian/tmp/usr/share/qgis/doc/developersmap.html
# Don't include a copy of the world.tif also included in osgearth-data
$(RM) $(CURDIR)/debian/tmp/usr/share/qgis/globe/world.tif
# remove extra license files
-find $(CURDIR)/debian/tmp/usr/share/qgis/resources/cpt-city-qgis-min/ -name COPYING.xml -delete
$(RM) $(CURDIR)/debian/tmp/usr/share/qgis/doc/LICENSE
$(RM) $(CURDIR)/debian/tmp/usr/share/qgis/python/plugins/db_manager/LICENSE
$(RM) $(CURDIR)/debian/tmp/usr/share/qgis/python/plugins/MetaSearch/LICENSE.txt
$(RM) $(CURDIR)/debian/tmp/usr/bin/test_provider_wcs
$(RM) $(CURDIR)/debian/tmp/usr/bin/qgis_bench
$(RM) $(CURDIR)/debian/tmp/usr/share/qgis/resources/wcs-servers.json
# remove documentation outside usr/share/doc
$(RM) $(CURDIR)/debian/tmp/usr/share/qgis/python/plugins/db_manager/README
$(RM) $(CURDIR)/debian/tmp/usr/share/qgis/python/plugins/db_manager/TODO
$(RM) $(CURDIR)/debian/tmp/usr/share/qgis/resources/cpt-city-qgis-min/README-qgis.txt
$(RM) $(CURDIR)/debian/tmp/usr/share/qgis/resources/cpt-city-qgis-min/README.txt
# Man pages are installed by dh_installman
$(RM) $(CURDIR)/debian/tmp/usr/man/man1/qgis.1
# Don't ship srs.db, automatically updated in postinst with crssync
mv $(CURDIR)/debian/tmp/usr/share/qgis/resources/srs.db $(CURDIR)/debian/tmp/usr/share/qgis/resources/srs-template.db
# Mime info
install -o root -g root -d $(CURDIR)/debian/tmp/usr/share/mime/packages
install -o root -g root -m 644 $(CURDIR)/debian/qgis.xml $(CURDIR)/debian/tmp/usr/share/mime/packages
# qgis binaries
install -o root -g root -m 755 -d $(CURDIR)/debian/qgis/usr/bin
install -o root -g root -m 755 $(CURDIR)/debian/tmp/usr/bin/qgis $(CURDIR)/debian/qgis/usr/bin/qgis.bin
install -o root -g root -m 755 $(CURDIR)/debian/tmp/usr/bin/qgis_process $(CURDIR)/debian/qgis/usr/bin/qgis_process.bin
$(RM) $(CURDIR)/debian/tmp/usr/bin/qgis $(CURDIR)/debian/tmp/usr/bin/qgis_process
# qgis binary wrappers
sed -r \
-e "s/\{GRASS\}/$(GRASS)/g" \
-e "s#\{ORACLE_LIBDIR\}#$(ORACLE_LIBDIR)#g" \
$(CURDIR)/debian/qgis.sh.in >$(CURDIR)/debian/qgis.sh
install -o root -g root -m 755 $(CURDIR)/debian/qgis.sh $(CURDIR)/debian/qgis/usr/bin/qgis
install -o root -g root -m 755 $(CURDIR)/debian/qgis.sh $(CURDIR)/debian/qgis/usr/bin/qgis_process
ifeq (,$(findstring $(DISTRIBUTION),"bullseye"))
mkdir -p $(CURDIR)/debian/libqgis-dev
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,'
find $(CURDIR)/debian/tmp/ -depth -empty -type d -delete
endif
override_dh_missing:
dh_missing --fail-missing
override_dh_install:
dh_install --autodest
override_dh_installchangelogs:
dh_installchangelogs ChangeLog
override_dh_installman:
cp qgis.1 qgis.bin.1
dh_installman -pqgis qgis.1 qgis.bin.1
override_dh_installmime:
dh_installmime -pqgis
override_dh_python3:
dh_python3
dh_python3 usr/share/qgis/grass/scripts
ifneq (,$(findstring $(DISTRIBUTION),"bullseye"))
dh_sip3 -ppython3-qgis
endif
override_dh_compress:
dh_compress --exclude=pdf
override_dh_makeshlibs:
ifneq (,$(WITH_ORACLE))
dh_makeshlibs -Xqgis-plugin-grass -Xlibqgis-customwidgets -Xqgis-provider-oracle -- -c0 -v$(QGIS_VERSION)
else
dh_makeshlibs -Xqgis-plugin-grass -Xlibqgis-customwidgets -- -c0 -v$(QGIS_VERSION)
endif
override_dh_shlibdeps:
ifneq (,$(WITH_ORACLE))
dh_shlibdeps -l/usr/lib/$(GRASS)/lib -l$(ORACLE_LIBDIR)
else
dh_shlibdeps -l/usr/lib/$(GRASS)/lib
endif
override_dh_strip:
dh_strip --dbg-package=qgis-dbg
override_dh_gencontrol:
dh_gencontrol -- -Vgrass:Depends="grass$(GRASSABI)"