chiark / gitweb /
finalise changelog
[bash.git] / debian / rules
1 #! /usr/bin/make -f
2 # -*- makefile -*-
3
4 #export DH_VERBOSE=1
5
6 unexport LANG LC_ALL LC_CTYPE LC_COLLATE LC_TIME LC_NUMERIC LC_MESSAGES
7
8 # architecture dependent variables
9 vafilt = $(subst $(2)=,,$(filter $(2)=%,$(1)))
10 DPKG_VARS := $(shell dpkg-architecture)
11 DEB_BUILD_GNU_TYPE      ?= $(call vafilt,$(DPKG_VARS),DEB_BUILD_GNU_TYPE)
12 DEB_HOST_ARCH           ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_ARCH)
13 DEB_HOST_ARCH_OS        ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_ARCH_OS)
14 DEB_HOST_GNU_CPU        ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_GNU_CPU)
15 DEB_HOST_GNU_SYSTEM     ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_GNU_SYSTEM)
16 DEB_HOST_GNU_TYPE       ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_GNU_TYPE)
17 DEB_HOST_MULTIARCH      ?= $(call vafilt,$(DPKG_VARS),DEB_HOST_MULTIARCH)
18
19 VERSION         := 4.2
20 #PKGVERSION     := $(shell dpkg-parsechangelog \
21 #                       | sed -n '/Version:/s/\(.* \)\(.*\)-2\(.*\)/\2\3/p')
22 #PKGVERSION     := 3.0
23 #dpkg_ctrl_args := -v$(PKGVERSION) -VBinary-Version=$(PKGVERSION)
24
25 with_gfdl       = no
26
27 ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
28   CC    = $(DEB_HOST_GNU_TYPE)-gcc
29 else
30   CC    = gcc
31 endif
32 dpkg_buildflags = DEB_CFLAGS_MAINT_APPEND=-Wall dpkg-buildflags
33 CFLAGS := $(shell $(dpkg_buildflags) --get CFLAGS)
34 CPPFLAGS := $(shell $(dpkg_buildflags) --get CPPFLAGS)
35 LDFLAGS := $(shell $(dpkg_buildflags) --get LDFLAGS)
36
37 SHELL   = /bin/bash
38 YACC    = bison -y
39
40 IX      = install -o 0 -g 0
41 ID      = install -o 0 -g 0 -m 644
42
43 # built with installed libreadline?
44 with_installed_rl = no
45
46 debflags =
47
48 p       = bash
49 p_stat  = bash-static
50 p_bins  = bash-builtins
51 p_doc   = bash-doc
52
53 d       = debian/$(p)
54 d_stat  = debian/$(p_stat)
55 d_bins  = debian/$(p_bins)
56 d_doc   = debian/$(p_doc)
57
58 termcap_lib := $(if $(wildcard /usr/lib/libtinfo.so /usr/lib/$(DEB_HOST_MULTIARCH)/libtinfo.so), \
59                  -ltinfo, \
60                  -lncurses)
61
62 conf_args = \
63         --with-curses \
64         --enable-largefile \
65         --prefix=/usr \
66         --infodir=/usr/share/info \
67         --mandir=/usr/share/man
68 ifeq ($(with_installed_rl),yes)
69     conf_args += --with-installed-readline
70 endif
71 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
72     conf_args += --build $(DEB_HOST_GNU_TYPE)
73 else
74     conf_args += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
75 endif
76
77 static_conf_args := $(conf_args) \
78         --enable-static-link \
79         --without-bash-malloc \
80
81 #build: bash-build static-build preinst-build check
82 build: before-build bash-build static-build preinst-build check
83 build-arch: build
84 build-indep: build
85
86 before-build:
87         : # see #327477, needed to have HAVE_DEV_STDIN defined
88         (test -d /dev/fd && test -r /dev/stdin < /dev/null) \
89           || (test -d /proc/self/fd && test -r /dev/stdin < /dev/null)
90 ifneq (,$(findstring $(DEB_HOST_ARCH_OS), linux freebsd))
91         $(CC) $(CFLAGS) $(LDFLAGS) $(CPPFLAGS) -o clear_console \
92             debian/clear_console.c $(termcap_lib)
93 endif
94
95 # ---------------------------------------------------------------------------
96 # build standard bash
97
98 bash-build:
99         $(MAKE) -f debian/rules do-build-bash \
100             bash_src=bash \
101             bash_patches="$(debian_patches)" \
102             build=bash \
103             configure_args="$(conf_args)"
104 bash-configure:
105         $(MAKE) -f debian/rules do-configure-bash \
106             bash_src=bash \
107             bash_patches="$(debian_patches)" \
108             build=bash \
109             configure_args="$(conf_args)"
110
111 # ---------------------------------------------------------------------------
112 # build static bash
113
114 static-build:
115         $(MAKE) -f debian/rules do-build-static \
116             bash_src=bash \
117             bash_patches="$(debian_patches)" \
118             build=static \
119             configure_args="$(static_conf_args)"
120 static-configure:
121         $(MAKE) -f debian/rules do-configure-static \
122             bash_src=bash \
123             bash_patches="$(debian_patches)" \
124             build=static \
125             configure_args="$(static_conf_args)"
126
127 # ---------------------------------------------------------------------------
128
129 bash-doc-build: stamps/stamp-build-bash-doc
130 stamps/stamp-build-bash-doc:
131 ifeq ($(with_gfdl),yes)
132         rm -f bash/doc/bashref.info
133         $(MAKE) -C build-bash/doc bashref.info bashref.pdf
134 endif
135         $(MAKE) -C build-bash/doc bash.html bash.pdf
136         touch stamps/stamp-build-bash-doc
137
138 # ---------------------------------------------------------------------------
139
140 check: stamps/stamp-check
141 stamps/stamp-check: bash-build
142         @echo BEGIN test
143 ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
144   ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
145         -sh debian/locale-gen
146         LOCPATH=$(CURDIR)/locales \
147                 time $(MAKE) -C build-bash test 2>&1 | tee build-bash/test-protocol
148   endif
149 else
150         @echo Suppress 'make' test, because this is cross build
151 endif
152         @echo END test
153         touch stamps/stamp-check
154
155 # ---------------------------------------------------------------------------
156
157 clean:
158         dh_testdir
159         dh_testroot
160         rm -rf stamps build-* bash
161         rm -f debian/bash.preinst debian/*.o
162         rm -f debian/README.Debian
163         rm -rf locales
164         rm -f clear_console
165         rm -f debian/patches/series
166         rm -rf .pc
167         dh_clean
168
169 preinst-build: debian/bash.preinst
170
171 STRIP = strip
172 ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
173     STRIP = : strip
174 endif
175
176 PREINST_OBJECTS = debian/bash.preinst.o debian/bash.preinst-lib.o
177
178 $(PREINST_OBJECTS): %.o: %.c debian/bash.preinst.h
179         $(CC) -c -o $@ $(CFLAGS) $(CPPFLAGS) $<
180
181 debian/bash.preinst: $(PREINST_OBJECTS)
182         $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(PREINST_OBJECTS)
183         $(STRIP) -R .comment -R .note debian/bash.preinst
184
185 # ---------------------------------------------------------------------------
186
187
188 install: bash-install
189
190 bash-install: bash-build stamps/stamp-install-bash
191 stamps/stamp-install-bash: before-build stamps/stamp-build-bash
192         dh_testdir
193         dh_testroot
194         dh_clean -k -p$(p) -p$(p_doc) -p$(p_bins)
195         dh_installdirs -p$(p) \
196                 bin \
197                 etc/skel \
198                 usr/share/doc/$(p)
199         dh_installdirs -p$(p_doc) \
200                 usr/share/doc/$(p)
201         dh_installdirs -p$(p_bins) \
202                 usr/share/doc/$(p)/examples/loadables \
203                 usr/include/bash/{builtins,lib/{glob,tilde}}
204
205 ifeq ($(with_gfdl),yes)
206 # XXXXX
207         cp -p build-bash/doc/*.info bash/doc/
208 endif
209
210         : # install it
211         $(MAKE) -C build-bash install \
212                 YACC="$(YACC)" \
213                 DESTDIR=$(CURDIR)/$(d)
214         mv $(d)/usr/bin/bash $(d)/bin/.
215         chmod 755 $(d)/usr/bin/bashbug
216         $(ID) debian/bashbug.1 $(d)/usr/share/man/man1/
217 ifneq ($(with_gfdl),yes)
218         mkdir -p $(d)/usr/share/man/man1
219         cp -p bash/doc/bash.1 $(d)/usr/share/man/man1/bash.1
220 endif
221
222         : # extra links
223         ln -sf bash $(d)/bin/rbash
224
225         : # skeleton files
226         $(ID) debian/etc.bash.bashrc $(d)/etc/bash.bashrc
227         $(ID) debian/skel.bashrc $(d)/etc/skel/.bashrc
228         $(ID) debian/skel.profile $(d)/etc/skel/.profile
229         $(ID) debian/skel.bash_logout $(d)/etc/skel/.bash_logout
230
231         : # clean_console
232 ifneq (,$(findstring $(DEB_HOST_ARCH_OS), linux freebsd))
233         $(IX) clear_console $(d)/usr/bin/
234         $(ID) debian/clear_console.1 $(d)/usr/share/man/man1/
235 endif
236
237 ifeq ($(with_gfdl),yes)
238         : # files for the bash-doc package
239         mv $(d)/usr/share/info/bash.info $(d)/usr/share/info/bashref.info
240         ln -sf bashref.info $(d)/usr/share/info/bash.info
241         mv $(d)/usr/share/info $(d_doc)/usr/share/
242 else
243         rm -rf $(d)/usr/share/info
244 endif
245
246         dh_installexamples -p$(p_doc) bash/examples/*
247         mv $(d_doc)/usr/share/doc/$(p_doc)/examples \
248                 $(d_doc)/usr/share/doc/$(p)/examples
249         rm -rf $(d_doc)/usr/share/doc/$(p)/examples/loadables
250         ln -sf ../$(p)/examples $(d_doc)/usr/share/doc/$(p_doc)/examples
251
252         rm -rf $(d_doc)/usr/share/doc/$(p)/examples/obashdb
253         cd $(d_doc)/usr/share/doc/$(p)/examples && chmod 755 \
254                 misc/aliasconv.*sh misc/cshtobash
255
256         cd $(d_doc)/usr/share/doc/$(p)/examples && chmod 644 \
257                 scripts/shprompt scripts/precedence \
258                 scripts/bcsh.sh scripts/krand.bash
259
260         : # files for the bash-builtins package
261         $(ID) bash/include/*.h bash/*.h  $(d_bins)/usr/include/bash/
262         $(ID) build-bash/*.h $(d_bins)/usr/include/bash/
263         rm -f $(d_bins)/usr/include/bash/y.tab.h
264         $(ID) bash/builtins/*.h $(d_bins)/usr/include/bash/builtins/
265         $(ID) bash/lib/glob/*.h $(d_bins)/usr/include/bash/lib/glob/
266         $(ID) bash/lib/tilde/*.h $(d_bins)/usr/include/bash/lib/tilde/
267         $(ID) bash/examples/loadables/{README,*.c} \
268                 $(d_bins)/usr/share/doc/$(p)/examples/loadables
269         $(ID) build-bash/examples/loadables/Makefile \
270                 $(d_bins)/usr/share/doc/$(p)/examples/loadables
271         ln -sf bash $(d_bins)/usr/share/doc/$(p_bins)
272
273         cat debian/README stamps/stamp-patch-bash > debian/README.Debian
274
275         touch stamps/stamp-install-bash
276
277 binary-doc: bash-install bash-doc-build
278         dh_testdir
279         dh_testroot
280         mkdir -p $(d_doc)/usr/share/doc/$(p)
281 ifeq ($(with_gfdl),yes)
282         dh_installdocs -p$(p_doc) 
283         cp -p build-bash/doc/bashref.pdf $(d_doc)/usr/share/doc/$(p)/.
284         dh_link -p$(p_doc) \
285             /usr/share/doc/$(p)/bashref.pdf /usr/share/doc/$(p_doc)/bashref.pdf
286 else
287         dh_installdocs -p$(p_doc) -X.doc-base
288         rm -f $(d_doc)/usr/share/doc-base/bashref
289 endif
290         rm -f $(d_doc)/usr/share/info/dir*
291         cp -p build-bash/doc/bash.html build-bash/doc/bash.pdf \
292             $(d_doc)/usr/share/doc/$(p)/
293         dh_link -p$(p_doc) \
294             /usr/share/doc/$(p)/bash.html /usr/share/doc/$(p_doc)/bash.html \
295             /usr/share/doc/$(p)/bash.pdf /usr/share/doc/$(p_doc)/bash.pdf
296         dh_installchangelogs -p$(p_doc) bash/CWRU/changelog
297         dh_compress -p$(p_doc) -Xexamples -X.pdf
298         dh_fixperms -p$(p_doc)
299         dh_installdeb -p$(p_doc)
300         dh_gencontrol -p$(p_doc)
301         dh_md5sums -p$(p_doc)
302         dh_builddeb -p$(p_doc)
303
304 binary-bash: bash-install debian/bash.preinst
305         dh_testdir
306         dh_testroot
307         dh_installchangelogs -p$(p)
308         dh_installdocs -p$(p) \
309                 bash/{CHANGES,NEWS,COMPAT,doc/INTRO,POSIX} \
310                 debian/{README.Debian,README.abs-guide,README.commands} \
311                 debian/inputrc.arrows
312 ifeq ($(with_gfdl),yes)
313         cp -p bash/doc/FAQ $(d)/usr/share/doc/$(p)/.
314 else
315         cp -p debian/FAQ $(d)/usr/share/doc/$(p)/.
316 endif
317         install -D -m 644 debian/bash.overrides \
318                 debian/bash/usr/share/lintian/overrides/bash
319         dh_installman -p$(p) bash/doc/rbash.1 debian/bash-builtins.7
320         dh_installmenu -p$(p)
321         dh_strip -p$(p)
322         dh_compress -p$(p)
323         dh_fixperms -p$(p)
324         dh_shlibdeps -p$(p) -- -dPre-Depends $(d)/bin/bash debian/bash.preinst
325         dh_installdeb -p$(p)
326         dh_gencontrol -p$(p)
327         dh_md5sums -p$(p)
328         dh_builddeb -p$(p)
329
330 # Even though it contains only headers and example files,
331 # bash-builtins is NOT arch-independent because the config.h* files
332 # differ on different archs.
333 binary-builtins: bash-install
334         dh_testdir
335         dh_testroot
336         dh_compress -p$(p_bins) -Xexamples
337         dh_fixperms -p$(p_bins)
338         dh_installdeb -p$(p_bins)
339         dh_gencontrol -p$(p_bins)
340         dh_md5sums -p$(p_bins)
341         dh_builddeb -p$(p_bins)
342
343 binary-static: static-build
344         dh_testdir
345         dh_testroot
346         dh_clean -k -p$(p_stat)
347         dh_installdirs -p$(p_stat) \
348                 bin \
349                 usr/share/man/man1
350         cp -p build-static/bash $(d_stat)/bin/bash-static
351         cp -p bash/doc/bash.1 $(d_stat)/usr/share/man/man1/bash-static.1
352         dh_installdocs -p$(p_stat)
353         dh_installchangelogs -p$(p_stat)
354         install -D -m 644 debian/bash-static.overrides \
355                 debian/bash-static/usr/share/lintian/overrides/bash-static
356         dh_strip -p$(p_stat)
357         dh_compress -p$(p_stat)
358         dh_fixperms -p$(p_stat)
359         dh_installdeb -p$(p_stat)
360         dh_gencontrol -p$(p_stat)
361         dh_md5sums -p$(p_stat)
362         dh_builddeb -p$(p_stat)
363
364 binary-indep: binary-doc
365 binary-arch: binary-bash binary-builtins binary-static
366 binary: binary-indep binary-arch
367
368 # ---------------------------------------------------------------------------
369 # common rules for all bash build variations
370
371 do-build-$(build): stamps/stamp-build-$(build)
372 stamps/stamp-build-$(build): stamps/stamp-configure-$(build)
373         dh_testdir
374 ifneq (,$(profiled_build))
375         $(MAKE) -C build-$(build) \
376                 CFLAGS='$(CFLAGS) -fprofile-generate' \
377                 YACC="$(YACC)" \
378                 TERMCAP_LIB="$(termcap_lib)" \
379                 deb_builddir=build-$(build)/ \
380                 $(debflags)
381         -sh debian/locale-gen
382         cp debian/run-my-gprof bash/tests/
383         LOCPATH=$(CURDIR)/locales \
384             time $(MAKE) -C build-$(build) TESTSCRIPT=run-my-gprof test 2>&1 \
385                 | tee build-bash/profile-protocol
386         $(MAKE) -C build-$(build) clean
387         rm -f build-$(build)/lib/malloc/malloc*.gc??
388         $(MAKE) -C build-$(build) \
389                 CFLAGS='$(CFLAGS) -fprofile-use' \
390                 YACC="$(YACC)" \
391                 TERMCAP_LIB="$(termcap_lib)" \
392                 deb_builddir=build-$(build)/ \
393                 $(debflags)
394 else
395         $(MAKE) -C build-$(build) \
396                 YACC="$(YACC)" \
397                 TERMCAP_LIB="$(termcap_lib)" \
398                 deb_builddir=build-$(build)/ \
399                 $(debflags)
400 endif
401 ifeq ($(with_gfdl),yes)
402         $(MAKE) -C build-$(build)/doc \
403                 bash.info
404 endif
405         touch stamps/stamp-build-$(build)
406
407 do-configure-$(build): stamps/stamp-configure-$(build)
408 stamps/stamp-configure-$(build): stamps/stamp-patch-$(bash_src)
409         dh_testdir
410         rm -rf build-$(build)
411         mkdir build-$(build)
412         cd build-$(build) && \
413             CC="$(CC)" \
414             CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" \
415             YACC="$(YACC)" \
416                 ../$(bash_src)/configure $(configure_args)
417         if ! grep -q '#define HAVE_DEV_STDIN 1' build-$(build)/config.h; then \
418           echo "HAVE_DEV_STDIN not defined, abortig build"; \
419           exit 1; \
420         fi
421         touch stamps/stamp-configure-$(build)
422
423 patchdir = debian/patches
424
425 $(patchdir)/series: $(patchdir)/series.in
426         cpp -E \
427           $(if $(filter no, $(with_gfdl)),,-DGFDL) \
428           -Darch_os_$(DEB_HOST_ARCH_OS) -Darch_$(DEB_HOST_ARCH) \
429           -o - $(patchdir)/series.in \
430           | egrep -v '^(#.*|$$)' > $(patchdir)/series
431
432 patch-$(bash_src): stamps/stamp-patch-$(bash_src)
433 stamps/stamp-patch-$(bash_src): $(patchdir)/series stamps/stamp-unpack-$(bash_src)
434         QUILT_PATCHES=$(patchdir) quilt push -a || test $$? = 2
435         mkdir -p stamps
436         echo ""; echo "Patches applied in this version:" > stamps/pxx
437         for i in $$(cat $(patchdir)/series); do \
438           echo ""; echo "$$i:"; \
439           sed -n 's/^# *DP: */  /p' $(patchdir)/$$i; \
440         done >> stamps/pxx
441         mv stamps/pxx $@
442
443 reverse-patches: unpatch
444 unpatch:
445         QUILT_PATCHES=$(patchdir) quilt pop -a -R || test $$? = 2
446         rm -f stamps/stamp-patch $(patchdir)/series
447         rm -rf configure autom4te.cache
448
449 update-patches: $(patchdir)/series stamps/stamp-unpack-$(bash_src)
450         export QUILT_PATCHES=$(patchdir); \
451         export QUILT_REFRESH_ARGS="--no-timestamps --no-index -p ab"; \
452         export QUILT_DIFF_ARGS="--no-timestamps --no-index -p ab"; \
453         while quilt push; do quilt refresh; done
454
455 unpack-$(bash_src): stamps/stamp-unpack-$(bash_src)
456 stamps/stamp-unpack-$(bash_src):
457         mkdir -p stamps
458         rm -rf bash-$(VERSION) $(bash_src)
459         rm -f stamps/stamp-patch-$(bash_src){,-*}
460         tar xf bash-$(VERSION)*.tar.xz
461         mv bash-$(VERSION) $(bash_src)
462         rm -f bash/y.tab.?
463         cp -p /usr/share/misc/config.* $(bash_src)/.
464         cp -p /usr/share/misc/config.* $(bash_src)/support/.
465         touch stamps/stamp-unpack-$(bash_src)
466
467 .PHONY: unpack patch binary binary-arch binary-indep clean \
468     build bash-build static-build preinst-build \
469     check \
470     bash-configure static-configure \
471     binary-doc binary-bash binary-builtins binary-static \
472     install bash-install
473
474 # Local Variables:
475 # mode: makefile
476 # end: