]> git.donarmstrong.com Git - lilypond.git/blob - debian/rules
Update d/copyright
[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 # These are used for cross-compiling and for saving the configure script
39 # from having to guess our platform (since we know it already)
40 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
41 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
42
43 ifeq (alpha,$(shell dpkg-architecture -qDEB_HOST_ARCH))
44   # The -O2 option breaks make check on alpha right now.
45   guile_deb_cflags := -Os -g
46 else ifeq (sh4,$(shell dpkg-architecture -qDEB_HOST_ARCH))
47   # Renesas SH(sh4) needs -mieee.  Without it, test-conversion fails.
48   # (Bug: 531378)
49   guile_deb_cflags := -O2 -g -mieee
50 else
51   guile_deb_cflags := -O2 -g
52 endif
53
54 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
55         CFLAGS += -g
56 endif
57 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
58         INSTALL_PROGRAM += -s
59 endif
60
61 guile_configure_args = \
62   --host=$(DEB_HOST_GNU_TYPE) \
63   --build=$(DEB_BUILD_GNU_TYPE) \
64   --with-threads=no \
65   --disable-error-on-warning \
66   --prefix=/usr
67
68 ifeq (hurd-i386,$(shell dpkg-architecture -qDEB_HOST_ARCH))
69   guile_configure_args += LIBS=-lpthread
70 endif
71
72 ########################################################################
73 # END: Definitions from the old guile-1.8 (1.8.8+1-10) package
74 ########################################################################
75
76 export PATH := $(CURDIR)/out/guile/usr/bin:$(PATH)
77 export LD_LIBRARY_PATH := $(CURDIR)/out/guile/usr/lib:$(LD_LIBRARY_PATH)
78 export GUILE_LOAD_PATH := $(CURDIR)/out/guile/usr/share/guile/1.8
79 export LILYPOND_VERSION := $(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_LEVEL)
80
81 %.reloc: %.reloc.in
82         sed < $< > $@ \
83                 -e 's!@LILYPOND_VERSION@!$(LILYPOND_VERSION)!g'
84
85 %.sh: %.sh.in
86         sed < $< > $@ \
87                 -e 's!@DEB_HOST_MULTIARCH@!$(DEB_HOST_MULTIARCH)!g' \
88                 -e 's!@LILYPOND_VERSION@!$(LILYPOND_VERSION)!g'
89
90 # Do not use debhelper's autoreconf, the build currently
91 # fails with this option and we take care of that
92 # ourselves anyway.
93 %:
94         dh $@ --without autoreconf --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
111         $(MAKE) doc $(DOC_OPTIONS)
112
113 ## Unfortunately, lilypond is kind of broken, and installs the wrong
114 ## info documentation (missing images) if we call their makefile
115 ## directly. They also don't provide an install rule which doesn't
116 ## install the documentation, which we don't care about for the
117 ## architecture dependent build
118 override_dh_auto_install-arch: debian/lilypond.sh debian/lilypond-invoke-editor.sh
119         for dir in `echo */*makefile|xargs -n 1 dirname|grep -v Documentation`; do \
120                 $(MAKE) --no-builtin-rules PACKAGE=LILYPOND package=lilypond -C $$dir install $(DOC_OPTIONS) prefix=$(CURDIR)/debian/tmp/usr/; \
121         done
122         sed -i -e '1s!$(CURDIR)/out/guile/usr/bin/guile!/usr/bin/guile!' \
123                 debian/tmp/usr/bin/lilypond-invoke-editor
124
125 ## We need the non-Documentation arch-independent files installed by
126 ## the arch-dependent "$(MAKE) install" too, hence the dependency
127 ## on override_dh_auto_install-arch
128 override_dh_auto_install-indep: override_dh_auto_install-arch debian/guile.reloc
129         $(MAKE) install-doc $(DOC_OPTIONS) prefix=$(CURDIR)/debian/tmp/usr/
130         $(MAKE) install-info $(DOC_OPTIONS) prefix=$(CURDIR)/debian/tmp/usr
131         rm -rf $(CURDIR)/debian/tmp/usr/share/omf
132         rm -rf $(CURDIR)/debian/tmp/usr/share/doc/lilypond/html/input
133         perl debian/move_info_images_from_html_doc $(CURDIR)/debian/tmp/usr/share/info/ $(CURDIR)/debian/tmp/usr/share/doc/lilypond/html/Documentation/
134         perl debian/symlink_html_images_to_info_images $(CURDIR)/debian/tmp/usr/share/info/lilypond
135         perl debian/remove_w3c_callback $(CURDIR)/debian/tmp/usr/share/doc/lilypond/ $(CURDIR)/debian/tmp/usr/share/info/
136
137 ## we need to nuke the parser files, because if there is a mismatch
138 ## between upstreams bison and our bison, the build will fail epically
139 override_dh_auto_clean:
140         [ ! -f guile18/Makefile ] || $(MAKE) -C guile18 maintainer-clean
141         rm -f lily/out/parser.*
142         dh_auto_clean --no-parallel
143
144 override_dh_install-arch:
145         dh_install -a --list-missing
146
147 ## we need to install only the png, jpg, css, ly and english html
148 ## files into the doc-html package, and only the english pdfs into the
149 ## doc-pdf package. Because dh_install doesn't support regexes, we'll
150 ## use find to replace the contents of the .install file before we
151 ## call dh_install
152 override_dh_install-indep:
153         /bin/echo -e 'usr/share/doc/lilypond/html/*/*/*.ly\nusr/share/doc/lilypond/html/*/*/*.png' \
154                 > $(CURDIR)/debian/lilypond-doc-html.install
155         /bin/echo -e 'usr/share/doc/lilypond/html/*/*/*.jpg\nusr/share/doc/lilypond/html/*/*/*.css' \
156                 >> $(CURDIR)/debian/lilypond-doc-html.install
157         find $(CURDIR)/debian/tmp/ -type f \
158                 -regex '.*usr/share/doc/lilypond/.*/[^\.]+.html' \
159                 -printf '%P\n' >> $(CURDIR)/debian/lilypond-doc-html.install
160         /bin/echo -e ''> $(CURDIR)/debian/lilypond-doc-pdf.install
161         find $(CURDIR)/debian/tmp/ -type f \
162                 -regex '.*usr/share/doc/lilypond/.*/[^\.]+.pdf' \
163                 -printf '%P\n' >> $(CURDIR)/debian/lilypond-doc-pdf.install
164         find $(CURDIR)/debian/tmp/ -type f \
165                 -regex '.*usr/share/doc/lilypond/.*/[^\.]+.preview.pdf' \
166                 -printf '%P\n' >> $(CURDIR)/debian/lilypond-doc-pdf.install
167         dh_install -i --list-missing
168
169 override_dh_python2:
170         dh_python2 --verbose
171         dh_python2 --verbose usr/share/lilypond/$(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_LEVEL)/python/
172
173 override_dh_compress:
174         dh_compress -X.ly -X.pdf
175
176 override_dh_installdocs:
177         dh_installdocs
178         for a in $(wildcard $(CURDIR)/debian/*.doc-base-special); do \
179                 package=`basename $$a .doc-base-special`; \
180                 install -d debian/$$package/usr/share/doc-base; \
181                 install -m0644 $$a debian/$$package/usr/share/doc-base/$$package; \
182         done
183
184 override_dh_shlibdeps-arch:
185         $(eval unexport LD_LIBRARY_PATH)
186         dh_shlibdeps -a -lusr/lib/$(DEB_HOST_MULTIARCH)/lilypond/$(LILYPOND_VERSION)/guile
187
188 # Skip tests for architecture-dependent-only build because
189 # the test would fail without built documentation.
190 override_dh_auto_test-arch:
191
192 override_dh_auto_test-indep:
193 ifeq (,$(filter $(DEB_BUILD_OPTIONS),nocheck))
194         $(MAKE) test-baseline
195         $(MAKE) test
196 endif
197
198 ## this rule will update debian/control and the per-language install
199 ## files; all of the files it generates/modifies should be included in
200 ## the Debian package and should not need to be regenerated or
201 ## modified.
202 update-doc-packages:
203         perl debian/update_doc_packages