]> git.donarmstrong.com Git - lilypond.git/blob - debian/rules
Cherry-pick 6a73776004 with minor adaptions in d/control and d/rules
[lilypond.git] / debian / rules
1 #!/usr/bin/make -f
2 # debian/rules for LilyPond in Debian.
3 #
4 # This is free software; see the GNU General Public Licence
5 # version 2 or later for copying conditions.  There is NO warranty.
6 #
7
8 include VERSION
9
10 export MAILADDRESS = lilypond@packages.debian.org
11
12 DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
13 DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
14 CFLAGS := $(shell dpkg-buildflags --get CFLAGS)
15 CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS)
16 ifneq (,$(filter $(DEB_HOST_ARCH), i386 kfreebsd-i386))
17   config_opt = --disable-optimising
18   CFLAGS := $(filter-out -O%, $(CFLAGS))
19   CXXFLAGS := $(filter-out -O%, $(CXXFLAGS))
20 else
21 ifneq (,$(filter $(DEB_BUILD_OPTIONS),noopt))
22   config_opt = --disable-optimising
23 else
24   config_opt = --enable-optimising
25 endif
26 endif
27
28 DOC_OPTIONS := WEB_TARGETS="offline"
29 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
30         DOC_OPTIONS := $(DOC_OPTIONS) CPU_COUNT=$(firstword $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))))
31         guile_make_args := -j$(firstword $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))))
32 endif
33
34 ########################################################################
35 # START: Definitions from the old guile-1.8 (1.8.8+1-10) package
36 ########################################################################
37
38 # Make sure the build process doesn't touch the real HOME.
39 export HOME := $(CURDIR)/no-trespassing
40
41 # These are used for cross-compiling and for saving the configure script
42 # from having to guess our platform (since we know it already)
43 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
44 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
45
46 ifeq (alpha,$(shell dpkg-architecture -qDEB_HOST_ARCH))
47   # The -O2 option breaks make check on alpha right now.
48   guile_deb_cflags := -Os -g
49 else ifeq (sh4,$(shell dpkg-architecture -qDEB_HOST_ARCH))
50   # Renesas SH(sh4) needs -mieee.  Without it, test-conversion fails.
51   # (Bug: 531378)
52   guile_deb_cflags := -O2 -g -mieee
53 else
54   guile_deb_cflags := -O2 -g
55 endif
56
57 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
58         CFLAGS += -g
59 endif
60 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
61         INSTALL_PROGRAM += -s
62 endif
63
64 guile_configure_args = \
65   --host=$(DEB_HOST_GNU_TYPE) \
66   --build=$(DEB_BUILD_GNU_TYPE) \
67   --with-threads=no \
68   --disable-error-on-warning \
69   --prefix=/usr
70
71 ifeq (hurd-i386,$(shell dpkg-architecture -qDEB_HOST_ARCH))
72   guile_configure_args += LIBS=-lpthread
73 endif
74
75 ########################################################################
76 # END: Definitions from the old guile-1.8 (1.8.8+1-10) package
77 ########################################################################
78
79 export PATH := $(CURDIR)/out/guile/usr/bin:$(PATH)
80 export LD_LIBRARY_PATH := $(CURDIR)/out/guile/usr/lib:$(LD_LIBRARY_PATH)
81 export GUILE_LOAD_PATH := $(CURDIR)/out/guile/usr/share/guile/1.8
82 export LILYPOND_VERSION := $(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_LEVEL)
83
84 %.reloc: %.reloc.in
85         sed < $< > $@ \
86                 -e 's!@LILYPOND_VERSION@!$(LILYPOND_VERSION)!g'
87
88 %.sh: %.sh.in
89         sed < $< > $@ \
90                 -e 's!@DEB_HOST_MULTIARCH@!$(DEB_HOST_MULTIARCH)!g' \
91                 -e 's!@LILYPOND_VERSION@!$(LILYPOND_VERSION)!g'
92
93 %:
94         dh $@ --parallel --with autotools-dev --with python2 --with quilt
95
96 ## we need to nuke the parser files, because if there is a mismatch
97 ## between upstreams bison and our bison, the build will fail epically
98 override_dh_auto_configure:
99         $(eval unexport GUILE_LOAD_PATH)
100         cd guile18 && ./autogen.sh
101         cd guile18 && CFLAGS="$(guile_deb_cflags)" ./configure ${guile_configure_args}
102         cd guile18 && $(MAKE) ${guile_make_args}
103         $(MAKE) -C guile18 install DESTDIR=$(CURDIR)/out/guile
104         rm -f lily/out/parser.*
105         ./autogen.sh --noconfigure
106         GUILE_LOAD_PATH=$(GUILE_LOAD_PATH) \
107                 dh_auto_configure -- --disable-checking --enable-debugging $(config_opt)
108
109 override_dh_auto_build-indep:
110         dh_auto_build -i -O--parallel
111         $(MAKE) doc $(DOC_OPTIONS)
112
113 override_dh_auto_install-indep: debian/guile.reloc
114         $(MAKE) install-doc $(DOC_OPTIONS) prefix=$(CURDIR)/debian/tmp/usr/
115         $(MAKE) install-info $(DOC_OPTIONS) prefix=$(CURDIR)/debian/tmp/usr
116         rm -rf $(CURDIR)/debian/tmp/usr/share/omf
117         rm -rf $(CURDIR)/debian/tmp/usr/share/doc/lilypond/html/input
118         perl debian/move_info_images_from_html_doc $(CURDIR)/debian/tmp/usr/share/info/ $(CURDIR)/debian/tmp/usr/share/doc/lilypond/html/Documentation/
119         perl debian/symlink_html_images_to_info_images $(CURDIR)/debian/tmp/usr/share/info/lilypond
120         perl debian/remove_w3c_callback $(CURDIR)/debian/tmp/usr/share/doc/lilypond/ $(CURDIR)/debian/tmp/usr/share/info/
121
122 ## Unfortunately, lilypond is kind of broken, and installs the wrong
123 ## info documentation (missing images) if we call their makefile
124 ## directly. They also don't provide an install rule which doesn't
125 ## install the documentation, which we don't care about for the
126 ## architecture dependent build
127 override_dh_auto_install-arch: debian/lilypond.sh debian/lilypond-invoke-editor.sh
128         for dir in `echo */*makefile|xargs -n 1 dirname|grep -v Documentation`; do \
129                 $(MAKE) --no-builtin-rules PACKAGE=LILYPOND package=lilypond -C $$dir install $(DOC_OPTIONS) prefix=$(CURDIR)/debian/tmp/usr/; \
130         done
131         sed -i -e '1s!$(CURDIR)/out/guile/usr/bin/guile!/usr/bin/guile!' \
132                 debian/tmp/usr/bin/lilypond-invoke-editor
133
134 ## We need the non-Documentation arch-independent files installed by
135 ## the arch-dependent "$(MAKE) install" too, hence the dependency
136 ## on override_dh_auto_install-arch
137 override_dh_auto_install-indep: override_dh_auto_install-arch
138         $(MAKE) install-doc $(DOC_OPTIONS) prefix=$(CURDIR)/debian/tmp/usr/
139         $(MAKE) install-info $(DOC_OPTIONS) prefix=$(CURDIR)/debian/tmp/usr
140         rm -rf $(CURDIR)/debian/tmp/usr/share/omf
141         rm -rf $(CURDIR)/debian/tmp/usr/share/doc/lilypond/html/input
142         perl debian/move_info_images_from_html_doc $(CURDIR)/debian/tmp/usr/share/info/ $(CURDIR)/debian/tmp/usr/share/doc/lilypond/html/Documentation/
143         perl debian/symlink_html_images_to_info_images $(CURDIR)/debian/tmp/usr/share/info/lilypond
144         perl debian/remove_w3c_callback $(CURDIR)/debian/tmp/usr/share/doc/lilypond/ $(CURDIR)/debian/tmp/usr/share/info/
145
146 ## we need to nuke the parser files, because if there is a mismatch
147 ## between upstreams bison and our bison, the build will fail epically
148 override_dh_auto_clean:
149         rm -rf no-trespassing
150         -$(MAKE) -C guile18 maintainer-clean
151         rm -f lily/out/parser.*
152         dh_auto_clean --no-parallel
153
154 override_dh_install-arch:
155         dh_install -a -O--parallel --list-missing
156
157 ## we need to install only the png, jpg, css, ly and english html
158 ## files into the doc-html package, and only the english pdfs into the
159 ## doc-pdf package. Because dh_install doesn't support regexes, we'll
160 ## use find to replace the contents of the .install file before we
161 ## call dh_install
162 override_dh_install-indep:
163         /bin/echo -e 'usr/share/doc/lilypond/html/*/*/*.ly\nusr/share/doc/lilypond/html/*/*/*.png' \
164                 > $(CURDIR)/debian/lilypond-doc-html.install
165         /bin/echo -e 'usr/share/doc/lilypond/html/*/*/*.jpg\nusr/share/doc/lilypond/html/*/*/*.css' \
166                 >> $(CURDIR)/debian/lilypond-doc-html.install
167         find $(CURDIR)/debian/tmp/ -type f \
168                 -regex '.*usr/share/doc/lilypond/.*/[^\.]+.html' \
169                 -printf '%P\n' >> $(CURDIR)/debian/lilypond-doc-html.install
170         /bin/echo -e ''> $(CURDIR)/debian/lilypond-doc-pdf.install
171         find $(CURDIR)/debian/tmp/ -type f \
172                 -regex '.*usr/share/doc/lilypond/.*/[^\.]+.pdf' \
173                 -printf '%P\n' >> $(CURDIR)/debian/lilypond-doc-pdf.install
174         find $(CURDIR)/debian/tmp/ -type f \
175                 -regex '.*usr/share/doc/lilypond/.*/[^\.]+.preview.pdf' \
176                 -printf '%P\n' >> $(CURDIR)/debian/lilypond-doc-pdf.install
177         dh_install -i -O--parallel --list-missing
178
179 override_dh_python2:
180         dh_python2 --verbose
181         dh_python2 --verbose usr/share/lilypond/$(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_LEVEL)/python/
182
183 override_dh_compress:
184         dh_compress -X.ly -X.pdf
185
186 override_dh_installdocs:
187         dh_installdocs
188         for a in $(wildcard $(CURDIR)/debian/*.doc-base-special); do \
189                 package=`basename $$a .doc-base-special`; \
190                 install -d debian/$$package/usr/share/doc-base; \
191                 install -m0644 $$a debian/$$package/usr/share/doc-base/$$package; \
192         done
193
194 override_dh_shlibdeps:
195         $(eval unexport LD_LIBRARY_PATH)
196         dh_shlibdeps -lusr/lib/$(DEB_HOST_MULTIARCH)/lilypond/$(LILYPOND_VERSION)/guile
197
198 override_dh_auto_test:
199 ifneq (,$(filter $(DEB_BUILD_OPTIONS),nocheck))
200         $(MAKE) test-baseline
201         $(MAKE) test
202 endif
203
204 ## this rule will update debian/control and the per-language install
205 ## files; all of the files it generates/modifies should be included in
206 ## the Debian package and should not need to be regenerated or
207 ## modified.
208 update-doc-packages:
209         perl debian/update_doc_packages