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