]> git.donarmstrong.com Git - lilypond.git/blob - debian/rules
e528bbdfcc069d195c6304db755f963630017221
[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         GUILE_LOAD_PATH=$(GUILE_LOAD_PATH) \
106                 dh_auto_configure -- --disable-checking --enable-debugging $(config_opt)
107
108 override_dh_auto_build-indep:
109         dh_auto_build
110         $(MAKE) doc $(DOC_OPTIONS)
111
112 override_dh_auto_install-indep: debian/guile.reloc
113         $(MAKE) install-doc $(DOC_OPTIONS) prefix=$(CURDIR)/debian/tmp/usr/
114         $(MAKE) install-info $(DOC_OPTIONS) prefix=$(CURDIR)/debian/tmp/usr
115         rm -rf $(CURDIR)/debian/tmp/usr/share/omf
116         rm -rf $(CURDIR)/debian/tmp/usr/share/doc/lilypond/html/input
117         perl debian/move_info_images_from_html_doc $(CURDIR)/debian/tmp/usr/share/info/ $(CURDIR)/debian/tmp/usr/share/doc/lilypond/html/Documentation/
118         perl debian/symlink_html_images_to_info_images $(CURDIR)/debian/tmp/usr/share/info/lilypond
119         perl debian/remove_w3c_callback $(CURDIR)/debian/tmp/usr/share/doc/lilypond/ $(CURDIR)/debian/tmp/usr/share/info/
120
121 ## Unfortunately, lilypond is kind of broken, and installs the wrong
122 ## info documentation (missing images) if we call their makefile
123 ## directly. They also don't provide an install rule which doesn't
124 ## install the documentation, which we don't care about for the
125 ## architecture dependent build
126 override_dh_auto_install-arch: debian/lilypond.sh debian/lilypond-invoke-editor.sh
127         for dir in `echo */*makefile|xargs -n 1 dirname|grep -v Documentation`; do \
128                 $(MAKE) --no-builtin-rules PACKAGE=LILYPOND package=lilypond -C $$dir install $(DOC_OPTIONS) prefix=$(CURDIR)/debian/tmp/usr/; \
129         done
130         sed -i -e '1s!$(CURDIR)/out/guile/usr/bin/guile!/usr/bin/guile!' \
131                 debian/tmp/usr/bin/lilypond-invoke-editor
132
133 ## we need to nuke the parser files, because if there is a mismatch
134 ## between upstreams bison and our bison, the build will fail epically
135 override_dh_auto_clean:
136         rm -rf no-trespassing
137         -$(MAKE) -C guile18 maintainer-clean
138         rm -f lily/out/parser.*
139         dh_auto_clean --no-parallel
140
141 ## we need to install only the png, jpg, css, ly and english html
142 ## files into the doc-html package, and only the english pdfs into the
143 ## doc-pdf package. Because dh_install doesn't support regexes, we'll
144 ## use find to replace the contents of the .install file before we
145 ## call dh_install
146 override_dh_install:
147         /bin/echo -e 'usr/share/doc/lilypond/html/*/*/*.ly\nusr/share/doc/lilypond/html/*/*/*.png' \
148                 > $(CURDIR)/debian/lilypond-doc-html.install
149         /bin/echo -e 'usr/share/doc/lilypond/html/*/*/*.jpg\nusr/share/doc/lilypond/html/*/*/*.css' \
150                 >> $(CURDIR)/debian/lilypond-doc-html.install
151         find $(CURDIR)/debian/tmp/ -type f \
152                 -regex '.*usr/share/doc/lilypond/.*/[^\.]+.html' \
153                 -printf '%P\n' >> $(CURDIR)/debian/lilypond-doc-html.install
154         /bin/echo -e ''> $(CURDIR)/debian/lilypond-doc-pdf.install
155         find $(CURDIR)/debian/tmp/ -type f \
156                 -regex '.*usr/share/doc/lilypond/.*/[^\.]+.pdf' \
157                 -printf '%P\n' >> $(CURDIR)/debian/lilypond-doc-pdf.install
158         find $(CURDIR)/debian/tmp/ -type f \
159                 -regex '.*usr/share/doc/lilypond/.*/[^\.]+.preview.pdf' \
160                 -printf '%P\n' >> $(CURDIR)/debian/lilypond-doc-pdf.install
161         dh_install --list-missing
162
163 override_dh_python2:
164         dh_python2 --verbose
165         dh_python2 --verbose usr/share/lilypond/$(MAJOR_VERSION).$(MINOR_VERSION).$(PATCH_LEVEL)/python/
166
167 override_dh_compress:
168         dh_compress -X.ly
169
170 override_dh_installdocs:
171         dh_installdocs
172         for a in $(wildcard $(CURDIR)/debian/*.doc-base-special); do \
173                 package=`basename $$a .doc-base-special`; \
174                 install -d debian/$$package/usr/share/doc-base; \
175                 install -m0644 $$a debian/$$package/usr/share/doc-base/$$package; \
176         done
177
178 override_dh_shlibdeps:
179         $(eval unexport LD_LIBRARY_PATH)
180         dh_shlibdeps -lusr/lib/$(DEB_HOST_MULTIARCH)/lilypond/$(LILYPOND_VERSION)/guile
181
182 override_dh_auto_test:
183 ifneq (,$(filter $(DEB_BUILD_OPTIONS),nocheck))
184         $(MAKE) test-baseline
185         $(MAKE) test
186 endif
187
188 ## this rule will update debian/control and the per-language install
189 ## files; all of the files it generates/modifies should be included in
190 ## the Debian package and should not need to be regenerated or
191 ## modified.
192 update-doc-packages:
193         perl debian/update_doc_packages