do the exchange dance properly
[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=musescore3
20 MSCPKG=${MSPPKG}-common
21 MSPDIR=debian/${MSPPKG}
22 MSCDIR=debian/${MSCPKG}
23 MSHARE=usr/share/mscore3-*
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_CPPFLAGS+=  -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_WEBENGINE=OFF
76 CMAKE_DEFS+=    -DOMR=ON
77 CMAKE_DEFS+=    -DUSE_SYSTEM_POPPLER=ON
78 CMAKE_DEFS+=    -DBUILD_CRASH_REPORTER=OFF
79
80 ifneq (linux,${DEB_HOST_ARCH_OS})
81 CMAKE_DEFS+=    -DBUILD_PORTMIDI=OFF
82 endif
83
84 CMAKE_DEFS+=    -DMSCORE_INSTALL_SUFFIX="3"
85
86 override_dh_auto_configure:
87         test -s fonts/mscore/mscore.old || \
88             mv fonts/mscore/mscore.ttf fonts/mscore/mscore.old
89         cp -f debian/upstream/mscore.ttf fonts/mscore/mscore.ttf
90         rm -rf debian/q-include
91         mkdir debian/q-include
92         printf '#define DEB_PKG_VERSION "%s (%s %s/%s)"\n' \
93             $(call shellescape,${DEB_VERSION}) \
94             "$$(lsb_release -si)" \
95             "$$(lsb_release -sc)" \
96             $(call shellescape,${DEB_HOST_ARCH}) \
97             >debian/q-include/DEB_PKG_VERSION.h
98         exec dh_auto_configure -- ${CMAKE_DEFS}
99
100 override_dh_auto_build:
101         env GNUMAKEFLAGS="$$GNUMAKEFLAGS --output-sync" \
102             dh_auto_build -- lrelease all
103         doxygen Doxyfile.plugins
104
105 override_dh_auto_test:
106         exec mksh debian/buildtest ${DEB_BUILD_OPTIONS}
107
108 execute_after_dh_install-indep:
109         # add doxygen-generated files
110         cd doc && exec cp -r plugins ../${MSCDIR}/${MSHARE}/manual/
111         dh_doxygen -p${MSCPKG} $$(cd ${MSCDIR} && \
112             echo ${MSHARE}/manual/plugins/html)
113         # doc-base insists on /usr/share/doc/ prefix
114         mkdir -p ${MSCDIR}/usr/share/doc/${MSCPKG}
115         ln -sfTr ${MSCDIR}/${MSHARE}/manual/plugins \
116             ${MSCDIR}/usr/share/doc/${MSCPKG}/plugin-doxy
117         # make system-wide soundfonts available
118         cd ${MSCDIR}/${MSHARE} && mkdir -p sound && \
119             ln -sf ../../sounds/sf2 ../../sounds/sf3 ../../sounds/sfz sound/
120
121 execute_after_dh_auto_clean:
122         test '!' -s fonts/mscore/mscore.old || \
123             mv -f fonts/mscore/mscore.old fonts/mscore/mscore.ttf
124         rm -rf debian/q-include
125         # remove possible doxygen remnants
126         rm -rf doc/plugins
127         -chmod -R g-w . # work around #796257 for Debian reproducible-builds