use more pre-baked dpkg Makefile snippets in rules file
[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 include /usr/share/dpkg/architecture.mk
14
15 # Automatic ${CC} selection for cross-compiles
16
17 # is ${CC} defined anywhere (other than implicit rules?)
18 ifneq (,$(findstring $(origin CC),default undefined))
19 # no - then default to gcc (or cross-gcc)
20 ifneq (${DEB_BUILD_ARCH},${DEB_HOST_ARCH})
21 CC=                     ${DEB_HOST_GNU_TYPE}-gcc
22 else
23 CC=                     gcc
24 endif
25 endif
26
27 export DEFS=NO_ASM # Avoid TEXTRELs on i386
28 DEB_CFLAGS_MAINT_APPEND := -Wall
29 DEB_CPPFLAGS_MAINT_APPEND := -DUNALIGNED_OK
30
31 # Automatic dpkg-buildflags selection, backport-friendly
32
33 # maybe turn this on later
34 #DEB_BUILD_MAINT_OPTIONS=hardening=+all
35 include /usr/share/dpkg/buildflags.mk
36
37 # maybe turn this on later
38 #ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
39 #NUMJOBS=               $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
40 #MAKEFLAGS+=            -j${NUMJOBS}
41 #endif
42
43 # whitespace-safe path to source directory
44 _topdir=$(call shellescape,$(shell pwd))
45
46 CONFIGURE_ARGS=         --prefix=/usr \
47                         --bindir=/bin \
48                         --infodir=${_topdir}/debian/gzip/usr/share/info \
49                         --mandir=${_topdir}/debian/gzip/usr/share/man \
50                         --disable-silent-rules
51
52 ifneq (${DEB_BUILD_ARCH},${DEB_HOST_ARCH})
53 CONFIGURE_ARGS+=        --host=${DEB_HOST_GNU_TYPE}
54 endif
55
56 reconf-stamp:
57         cp -f /usr/share/misc/config.sub build-aux/config.sub
58         cp -f /usr/share/misc/config.guess build-aux/config.guess
59         autoreconf -v
60         :>$@
61
62 configure: configure-stamp
63 configure-stamp: reconf-stamp
64         dh_testdir
65         mkdir -p builddir
66         cd builddir && env \
67             $(foreach i,CC CFLAGS CPPFLAGS LDFLAGS,$(call shellexport,$i)) \
68             CONFIG_SHELL=/bin/sh GREP=grep ../configure ${CONFIGURE_ARGS}
69         :>$@
70
71 configure-indep: configure-indep-stamp
72 configure-indep-stamp: reconf-stamp
73         dh_testdir
74         mkdir -p builddir-indep
75         cd builddir-indep && ../configure --host=i686-w64-mingw32 \
76                 LIBS="-Wl,--as-needed -lssp" --disable-silent-rules
77         :>$@
78
79 build: build-stamp build-indep-stamp
80
81 build-arch: build-stamp
82 build-stamp: configure-stamp
83         dh_testdir
84         ${MAKE} -C builddir
85 ifeq (,$(filter nocheck,${DEB_BUILD_OPTIONS}))
86 ifeq (${DEB_BUILD_ARCH},${DEB_HOST_ARCH})
87         ${MAKE} -C builddir check
88 endif
89 endif
90         :>$@
91
92 build-indep: build-indep-stamp
93 build-indep-stamp: configure-indep-stamp
94         dh_testdir
95         ${MAKE} -C builddir-indep
96         :>$@
97
98 clean:
99         dh_testdir
100         dh_testroot
101         -rm -f build-stamp build-indep-stamp configure-stamp configure-indep-stamp reconf-stamp
102         -rm -rf builddir builddir-indep
103         dh_clean
104
105 binary: binary-arch binary-indep
106
107 binary-indep: build-indep-stamp
108         dh_testdir
109         dh_testroot
110         dh_prep
111         dh_installdirs
112         i686-w64-mingw32-strip builddir-indep/gzip.exe
113         install -m 0755 builddir-indep/gzip.exe \
114             debian/gzip-win32/usr/share/win32/
115         dh_installdocs -i README* TODO NEWS
116         dh_installchangelogs -i ChangeLog
117         dh_lintian -i
118         dh_compress -i
119         dh_fixperms -i
120         dh_installdeb -i
121         dh_gencontrol -i
122         dh_md5sums -i
123         dh_builddeb -i
124
125 binary-arch: build-stamp
126         dh_testdir
127         dh_testroot
128         dh_prep
129         dh_installdirs
130         ${MAKE} -C builddir install \
131             prefix=${_topdir}/debian/gzip/usr \
132             bindir=${_topdir}/debian/gzip/bin
133         dh_testdir -a
134         dh_testroot -a
135         dh_installdocs -a README* TODO NEWS
136         dh_installman *.1
137         dh_installinfo -a doc/gzip.info
138         dh_installchangelogs -a ChangeLog
139         dh_link -a
140         dh_lintian -a
141         dh_strip -a
142         dh_compress -a
143         ln -s gunzip.1.gz debian/gzip/usr/share/man/man1/uncompress.1.gz
144         ln -s zgrep.1.gz debian/gzip/usr/share/man/man1/zegrep.1.gz
145         ln -s zgrep.1.gz debian/gzip/usr/share/man/man1/zfgrep.1.gz
146         rm -f ${_topdir}/debian/gzip/usr/share/info/dir.gz
147         dh_fixperms -a
148         dh_makeshlibs -a
149         dh_installdeb -a
150         dh_shlibdeps -a
151         dh_gencontrol -a
152         dh_md5sums -a
153         dh_builddeb -a
154
155 .PHONY: binary binary-arch binary-indep build build-arch build-indep clean
156 .PHONY: configure configure-indep