6d2e2d48441146047da9302f882018b1f08b897c
[alioth/musescore.git] / debian / rules
1 #!/usr/bin/make -f
2
3 CWD:=$(abspath .)
4
5 ifeq (,$(filter terse,${DEB_BUILD_OPTIONS}))
6 export DH_VERBOSE=1
7 export V=1
8 export VERBOSE=1
9 endif
10
11 LC_ALL:=C.UTF-8
12 export LC_ALL
13
14 shellescape='$(subst ','\'',$(1))'
15 shellexport=$(1)=$(call shellescape,${$(1)})
16
17 MSPPKG=musescore
18 MSCPKG=${MSPPKG}-common
19 MSPDIR=debian/${MSPPKG}
20 MSCDIR=debian/${MSCPKG}
21 MSHARE=usr/share/mscore-*
22
23 DEB_HOST_ARCH?=$(shell dpkg-architecture -qDEB_HOST_ARCH)
24 DEB_HOST_ARCH_OS?=$(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
25
26 OUR_CPPFLAGS:=
27 OUR_CFLAGS:=
28 OUR_CXXFLAGS:=
29 OUR_LDFLAGS:=
30
31 # unclutter build log; these are upstream’s to fix
32 OUR_CPPFLAGS+=  -Wno-deprecated-declarations
33
34 # only needed when backporting to buster and older
35 #OUR_LDFLAGS+=  -Wl,--as-needed
36
37 # defined for most of the code anyway; doing this here helps the PCH
38 OUR_CPPFLAGS+=  -DQT_NO_DEBUG
39 # avoid stray debugging output
40 OUR_CPPFLAGS+=  -DNDEBUG
41 # disable phoning home
42 OUR_CPPFLAGS+=  -DMSCORE_NO_UPDATE_CHECKER
43
44 # better debugging if requested
45 ifneq (,$(findstring optdbg,${DEB_BUILD_OPTIONS}))
46 OUR_CFLAGS+=    -Og -g3
47 OUR_CXXFLAGS+=  -Og -g3
48 endif
49
50 # things that cannot be passed via CPPFLAGS
51 OUR_CPPFLAGS+=  -I${CWD}/debian/q-include
52
53 dpkgbuildflagsmkescape=$(subst \,\\\,$(1))
54 export DEB_BUILD_MAINT_OPTIONS:=hardening=+all
55 export DEB_CPPFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${OUR_CPPFLAGS})
56 export DEB_CFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${OUR_CFLAGS})
57 export DEB_CXXFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${OUR_CXXFLAGS})
58 export DEB_LDFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${OUR_LDFLAGS})
59 include /usr/share/dpkg/buildflags.mk
60 ifneq (,$(wildcard /usr/share/dpkg/buildtools.mk))
61 include /usr/share/dpkg/buildtools.mk
62 endif
63 include /usr/share/dpkg/pkg-info.mk
64
65 %:
66         dh $@ --buildsystem=cmake
67
68 CMAKE_DEFS:=    -DCMAKE_SKIP_RPATH=ON
69 CMAKE_DEFS+=    -DDOWNLOAD_SOUNDFONT=OFF
70 CMAKE_DEFS+=    -DUSE_SYSTEM_FREETYPE=ON \
71                 -DFREETYPE_INCLUDE_DIRS=/usr/include/freetype2/
72 CMAKE_DEFS+=    -DBUILD_WEBKIT=OFF
73
74 ifneq (linux,${DEB_HOST_ARCH_OS})
75 CMAKE_DEFS+=    -DBUILD_PORTMIDI=OFF
76 endif
77
78 override_dh_auto_configure:
79         rm -rf debian/q-include
80         mkdir debian/q-include
81         printf '#define DEB_PKG_VERSION "%s (%s %s/%s)"\n' \
82             $(call shellescape,${DEB_VERSION}) \
83             "$$(lsb_release -si)" \
84             "$$(lsb_release -sc)" \
85             $(call shellescape,${DEB_HOST_ARCH}) \
86             >debian/q-include/DEB_PKG_VERSION.h
87         exec dh_auto_configure -- ${CMAKE_DEFS}
88
89 override_dh_auto_build:
90         env GNUMAKEFLAGS="$$GNUMAKEFLAGS --output-sync" \
91             dh_auto_build -- lrelease all
92
93 override_dh_auto_test:
94         exec mksh debian/buildtest ${DEB_BUILD_OPTIONS}
95
96 execute_after_dh_install-indep:
97         # make system-wide soundfonts available
98         cd ${MSCDIR}/${MSHARE} && mkdir -p sound && \
99             ln -sf ../../sounds/sf2 ../../sounds/sf3 ../../sounds/sfz sound/
100
101 execute_after_dh_auto_clean:
102         rm -rf debian/q-include
103         -chmod -R g-w . # work around #796257 for Debian reproducible-builds