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
|
#! /usr/bin/make -f
# for SOURCE_DATE_EPOCH
include /usr/share/dpkg/pkg-info.mk
DATE_MONTH_YEAR=$(shell env LC_ALL=C.UTF-8 date --utc --date=@${SOURCE_DATE_EPOCH} +"%B %Y")
# retrieve the first part of the upstream version matching [0-9.]+
VERSION_UPSTREAM = $(shell dpkg-parsechangelog -SVersion | sed 's/\([0-9.]\+\).*/\1/')
# for DEB_HOST_GNU_TYPE
include /usr/share/dpkg/architecture.mk
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk
# On mips and mipsel, each process is limited to 2 GB of memory. Because
# gcc manages its memory badly, it will randomly run out of memory. As a
# workaround we force the garbage collector to drop memory more aggressively.
#
# See Debian bug #849657 and
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79030
ifneq (,$(filter $(DEB_HOST_ARCH), mips mipsel))
export DEB_CXXFLAGS_MAINT_APPEND+=--param ggc-min-expand=5
endif
BUILDDIR=$(CURDIR)/obj-$(DEB_HOST_GNU_TYPE)
%:
dh $@ --builddirectory=$(BUILDDIR)
# override disabled by default rpath - we need to find libvcmi.so with it:
override_dh_auto_configure:
ln -s /usr/src/googletest/googletest test/googletest
dh_auto_configure -- \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON \
-DCMAKE_INSTALL_RPATH=/usr/lib/$(DEB_HOST_MULTIARCH)/vcmi \
-DCMAKE_BUILD_RPATH_USE_ORIGIN=ON \
-DBIN_DIR=games \
-DFORCE_BUNDLED_FL=OFF \
-DENABLE_GITVERSION=OFF \
-DENABLE_INNOEXTRACT=OFF \
-DENABLE_TEST=0
execute_before_dh_auto_build:
# cmake checking for compiler flags without setting CPPFLAGS
# False positive from blhc. See #994422
@echo 'blhc: ignore-line-regexp: /usr/(bin|lib)/(ccache/)?c\+\+ -std=gnu\+\+17 -dM -E -c /usr/share/cmake-[0-9.]+/Modules/CMakeCXXCompilerABI.cpp .*'
execute_before_dh_installman:
ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
# NATIVE BUILD
# ============
# Verify that the contents of debian/*.1 files are up-to-date.
#
# We have to set HOME to a temporary directory when running vcmiserver because
# - when running vcmiserver it wants to create $HOME/.config/vcmi,
# $HOME/.cache/vcmi and $HOME/.local/share/vcmi/Saves
# - sbuild uses the non-existing path /sbuild-nonexistent and the vcmiserver
# invocation would fail because it cannot create it
# - we don't want to touch the home directory of the user running dpkg-buildpackage
#
# We have to set QT_QPA_PLATFORM=minimal or otherwise vcmieditor wlil
# error out with:
# qt.qpa.xcb: could not connect to display
# qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
# This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
# Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.
# Aborted (core dumped)
#
# We have to set LC_ALL=C.UTF-8 so that perl's strftime() produces the
# same output independent of the environment's locale setting. Just
# setting LC_TIME will not have the intended effect if the environment
# has set LC_ALL to a different value.
set -e; for bin in server editor client; do \
env LC_ALL=C.UTF-8 QT_QPA_PLATFORM=minimal HOME=$(BUILDDIR) \
help2man --version-string=$(VERSION_UPSTREAM) \
--include=debian/vcmi$$bin.1.in \
--output=vcmi$$bin.1 $(BUILDDIR)/bin/vcmi$$bin; \
done
# Prepend the first line and replace version string before comparing
# This is its own loop because we cannot put this comment inside the
# loop body or otherwise it breaks the multi-line shell string
set -e; for bin in server editor client; do \
{ \
awk 'NR == 1 && /DO NOT MODIFY THIS FILE! It was generated by help2man/ { print }' vcmi$$bin.1; \
sed 's/@@VERSION@@/$(VERSION_UPSTREAM)/;s/@@DATE@@/$(DATE_MONTH_YEAR)/' debian/vcmi$$bin.1; \
} | diff -u - vcmi$$bin.1; \
done
endif
# if this was a cross-build, we can just use the cached debian/*.1 files
# if this was a native build, we verified their contents above
set -e; for bin in server editor client; do \
sed 's/@@VERSION@@/$(VERSION_UPSTREAM)/;s/@@DATE@@/$(DATE_MONTH_YEAR)/' debian/vcmi$$bin.1 > vcmi$$bin.1; \
done
# vcmibuilder is a shell script so we can run this even when cross-building
LC_ALL=C.UTF-8 help2man --version-string=$(VERSION_UPSTREAM) --include=debian/vcmibuilder.1.in --output=vcmibuilder.1 $(CURDIR)/vcmibuilder
override_dh_auto_install:
dh_auto_install --destdir=debian/vcmi
execute_after_dh_auto_clean:
# test/googletest is either an empty directory from the upstream
# tarball or a symlink we created
rmdir test/googletest || rm -f test/googletest
|