enable hardening build flags
[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
5 # Comment this to turn off debhelper verbose mode.
6 export DH_VERBOSE=1
7
8 DEB_BUILD_GNU_TYPE = $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
9 DEB_HOST_GNU_TYPE = $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
10 ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
11 CONFARGS = --host=$(DEB_HOST_GNU_TYPE)
12 endif
13
14 CFLAGS = `dpkg-buildflags --get CFLAGS`
15 CFLAGS += -Wall
16 LDFLAGS = `dpkg-buildflags --get LDFLAGS`
17 CPPFLAGS = `dpkg-buildflags --get CPPFLAGS`
18
19 ifeq ($(shell dpkg-architecture -qDEB_HOST_ARCH),amd64)
20 CFLAGS += -DUNALIGNED_OK
21 endif
22
23 reconf-stamp:
24         cp -f /usr/share/misc/config.sub build-aux/config.sub
25         cp -f /usr/share/misc/config.guess build-aux/config.guess
26         autoreconf -v
27         touch $@
28
29 configure: configure-stamp
30 configure-stamp: reconf-stamp
31         dh_testdir
32         mkdir -p build
33         cd build && CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" ../configure \
34                 --prefix=/usr --bindir=/bin \
35                 --infodir=`pwd`/debian/gzip/usr/share/info \
36                 --mandir=`pwd`/debian/gzip/usr/share/man $(CONFARGS)
37         touch $@
38
39 configure-indep: configure-indep-stamp
40 configure-indep-stamp: reconf-stamp
41         dh_testdir
42         mkdir -p build-indep
43         cd build-indep && ../configure --host=i686-w64-mingw32
44         touch $@
45
46 build: build-arch build-indep
47
48 build-arch: build-stamp 
49 build-stamp: configure-stamp
50         dh_testdir
51         $(MAKE) -C build
52 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
53 ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
54         $(MAKE) -C build check
55 endif
56 endif
57         touch $@
58
59 build-indep: build-indep-stamp
60 build-indep-stamp: configure-indep-stamp
61         dh_testdir
62         $(MAKE) -C build-indep
63         touch $@
64
65 clean:
66         dh_testdir
67         dh_testroot
68         -rm -f build-stamp build-indep-stamp configure-stamp configure-indep-stamp reconf-stamp
69         -rm -rf build build-indep
70         dh_clean
71
72 install: build
73         dh_testdir
74         dh_testroot
75         dh_clean -k
76         dh_installdirs
77         $(MAKE) -C build install prefix=`pwd`/debian/gzip/usr bindir=`pwd`/debian/gzip/bin 
78
79 install-indep: build-indep
80         dh_testdir
81         dh_testroot
82         dh_clean -k
83         dh_installdirs
84         i686-w64-mingw32-strip build-indep/gzip.exe
85         install -m 0755 build-indep/gzip.exe debian/gzip-win32/usr/share/win32/
86
87 binary-indep:   build-indep install-indep
88         dh_testdir -i
89         dh_testroot -i
90         dh_installdocs -i README* TODO
91         dh_installchangelogs -i ChangeLog
92         dh_lintian -i
93         dh_compress -i
94         dh_fixperms -i
95         dh_installdeb -i
96         dh_gencontrol -i
97         dh_md5sums -i
98         dh_builddeb -i
99
100 binary-arch:    build install
101         dh_testdir -s
102         dh_testroot -s
103         dh_installdocs -s README* TODO
104         dh_installman *.1
105         dh_installinfo -s doc/gzip.info
106         dh_installchangelogs -s ChangeLog
107         dh_link -s
108         dh_lintian -s
109         dh_strip -s
110         dh_compress -s
111         ln -s gunzip.1.gz debian/gzip/usr/share/man/man1/uncompress.1.gz
112         ln -s zgrep.1.gz debian/gzip/usr/share/man/man1/zegrep.1.gz
113         ln -s zgrep.1.gz debian/gzip/usr/share/man/man1/zfgrep.1.gz
114         dh_fixperms -s
115         # You may want to make some executables suid here.
116         dh_makeshlibs -s
117         dh_installdeb -s
118         dh_shlibdeps -s
119         dh_gencontrol -s
120         dh_md5sums -s
121         dh_builddeb -s
122
123 binary: binary-indep binary-arch
124 .PHONY: build clean binary-indep binary-arch binary install configure
125 .PHONY: build-indep install-indep configure-indep
126