diff from NMU by Thorsten Glaser that fixes FTBFS issues in the -1 upload
[debian/gzip] / debian / rules
1 #!/usr/bin/make -f
2 #       Debian rules file for gzip, requires the debhelper package.
3 #       Crafted by Bdale Garbee, bdale@gag.com, 5 November 2000
4 #       Cleanup by Thorsten Glaser, tg@debian.org, 20 June 2012
5 #       based on the rules file of the jupp package
6
7 # Comment this to turn off debhelper verbose mode.
8 export DH_VERBOSE=1
9
10 shellescape='$(subst ','\'',$(1))'
11 shellexport=$(1)=$(call shellescape,${$(1)})
12
13 DEB_BUILD_ARCH=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
14 DEB_HOST_ARCH=$(shell dpkg-architecture -qDEB_HOST_ARCH)
15 DEB_HOST_GNU_TYPE=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
16
17 # Automatic ${CC} selection for cross-compiles
18
19 # is ${CC} defined anywhere (other than implicit rules?)
20 ifneq (,$(findstring $(origin CC),default undefined))
21 # no - then default to gcc (or cross-gcc)
22 ifneq (${DEB_BUILD_ARCH},${DEB_HOST_ARCH})
23 CC=                     ${DEB_HOST_GNU_TYPE}-gcc
24 else
25 CC=                     gcc
26 endif
27 endif
28
29 EXTRA_CFLAGS=           -Wall
30 EXTRA_CPPFLAGS=
31
32 ifeq (${DEB_HOST_ARCH},amd64)
33 EXTRA_CPPFLAGS+=        -DUNALIGNED_OK
34 endif
35
36 # Automatic dpkg-buildflags selection, backport-friendly
37
38 ifneq (,$(wildcard /usr/share/dpkg/buildflags.mk))
39 # dpkg-dev (>= 1.16.1~)
40 DEB_CFLAGS_MAINT_APPEND=${EXTRA_CFLAGS}
41 DEB_CPPFLAGS_MAINT_APPEND=${EXTRA_CPPFLAGS}
42 # maybe turn this on later
43 #DEB_BUILD_MAINT_OPTIONS=hardening=+all
44 include /usr/share/dpkg/buildflags.mk
45 else
46 # old-fashioned way to determine build flags
47 CFLAGS=                 -O$(if $(findstring noopt,${DEB_BUILD_OPTIONS}),0,2) -g
48 CFLAGS+=                ${EXTRA_CFLAGS}
49 LDFLAGS+=               ${EXTRA_LDFLAGS}
50 endif
51
52 # maybe turn this on later
53 #ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
54 #NUMJOBS=               $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
55 #MAKEFLAGS+=            -j${NUMJOBS}
56 #endif
57
58 # whitespace-safe path to source directory
59 _topdir=$(call shellescape,$(shell pwd))
60
61 CONFIGURE_ARGS=         --prefix=/usr \
62                         --bindir=/bin \
63                         --infodir=${_topdir}/debian/gzip/usr/share/info \
64                         --mandir=${_topdir}/debian/gzip/usr/share/man
65
66 ifneq (${DEB_BUILD_ARCH},${DEB_HOST_ARCH})
67 CONFIGURE_ARGS+=        --host=${DEB_HOST_GNU_TYPE}
68 endif
69
70 reconf-stamp:
71         cp -f /usr/share/misc/config.sub build-aux/config.sub
72         cp -f /usr/share/misc/config.guess build-aux/config.guess
73         autoreconf -v
74         :>$@
75
76 configure: configure-stamp
77 configure-stamp: reconf-stamp
78         dh_testdir
79         mkdir -p builddir
80         cd builddir && env \
81             $(foreach i,CC CFLAGS CPPFLAGS LDFLAGS,$(call shellexport,$i)) \
82             ../configure ${CONFIGURE_ARGS}
83         :>$@
84
85 configure-indep: configure-indep-stamp
86 configure-indep-stamp: reconf-stamp
87         dh_testdir
88         mkdir -p builddir-indep
89         cd builddir-indep && ../configure --host=i686-w64-mingw32
90         :>$@
91
92 build: build-stamp build-indep-stamp
93
94 build-arch: build-stamp
95 build-stamp: configure-stamp
96         dh_testdir
97         ${MAKE} -C builddir
98 ifeq (,$(filter nocheck,${DEB_BUILD_OPTIONS}))
99 ifeq (${DEB_BUILD_ARCH},${DEB_HOST_ARCH})
100         ${MAKE} -C builddir check
101 endif
102 endif
103         :>$@
104
105 build-indep: build-indep-stamp
106 build-indep-stamp: configure-indep-stamp
107         dh_testdir
108         ${MAKE} -C builddir-indep
109         :>$@
110
111 clean:
112         dh_testdir
113         dh_testroot
114         -rm -f build-stamp build-indep-stamp configure-stamp configure-indep-stamp reconf-stamp
115         -rm -rf builddir builddir-indep
116         dh_clean
117
118 binary: binary-arch binary-indep
119
120 binary-indep: build-indep-stamp
121         dh_testdir
122         dh_testroot
123         if test -x "$$(which dh_prep)"; then dh_prep; else dh_clean -k; fi
124         dh_installdirs
125         i686-w64-mingw32-strip builddir-indep/gzip.exe
126         install -m 0755 builddir-indep/gzip.exe \
127             debian/gzip-win32/usr/share/win32/
128         dh_installdocs -i README* TODO
129         dh_installchangelogs -i ChangeLog
130         dh_lintian -i
131         dh_compress -i
132         dh_fixperms -i
133         dh_installdeb -i
134         dh_gencontrol -i
135         dh_md5sums -i
136         dh_builddeb -i
137
138 binary-arch: build-stamp
139         dh_testdir
140         dh_testroot
141         if test -x "$$(which dh_prep)"; then dh_prep; else dh_clean -k; fi
142         dh_installdirs
143         ${MAKE} -C builddir install \
144             prefix=${_topdir}/debian/gzip/usr \
145             bindir=${_topdir}/debian/gzip/bin
146         dh_testdir -s
147         dh_testroot -s
148         dh_installdocs -s README* TODO
149         dh_installman *.1
150         dh_installinfo -s doc/gzip.info
151         dh_installchangelogs -s ChangeLog
152         dh_link -s
153         dh_lintian -s
154         dh_strip -s
155         dh_compress -s
156         ln -s gunzip.1.gz debian/gzip/usr/share/man/man1/uncompress.1.gz
157         ln -s zgrep.1.gz debian/gzip/usr/share/man/man1/zegrep.1.gz
158         ln -s zgrep.1.gz debian/gzip/usr/share/man/man1/zfgrep.1.gz
159         dh_fixperms -s
160         dh_makeshlibs -s
161         dh_installdeb -s
162         dh_shlibdeps -s
163         dh_gencontrol -s
164         dh_md5sums -s
165         dh_builddeb -s
166
167 .PHONY: binary binary-arch binary-indep build build-arch build-indep clean
168 .PHONY: configure configure-indep