d649cc4c76ec1a6a2fe21ccf79c4157bdcda5459
[alioth/rs.git] / debian / rules
1 #!/usr/bin/make -f
2 # $MirOS: contrib/hosted/tg/deb/rs/debian/rules,v 1.4 2012/04/14 13:16:06 tg Exp $
3
4 CC?=                    gcc
5 EXTRA_CFLAGS=           -Wall -Wextra -Wformat
6 EXTRA_CPPFLAGS=         -DUSE_LIBBSD
7 EXTRA_LDFLAGS=          -Wl,--as-needed
8
9 ifneq (,$(wildcard /usr/share/dpkg/buildflags.mk))
10 # dpkg-dev (>= 1.16.1~)
11 DEB_CFLAGS_MAINT_APPEND=${EXTRA_CFLAGS}
12 DEB_CPPFLAGS_MAINT_APPEND=${EXTRA_CPPFLAGS}
13 DEB_LDFLAGS_MAINT_APPEND=${EXTRA_LDFLAGS}
14 DEB_BUILD_MAINT_OPTIONS=hardening=+all
15 include /usr/share/dpkg/buildflags.mk
16 else
17 # old-fashioned way to determine build flags
18 CFLAGS=                 -O$(if $(findstring noopt,${DEB_BUILD_OPTIONS}),0,2) -g
19 CFLAGS+=                ${EXTRA_CFLAGS}
20 CPPFLAGS+=              ${EXTRA_CPPFLAGS}
21 LDFLAGS+=               ${EXTRA_LDFLAGS}
22 endif
23
24 LDADD+=                 -lbsd
25
26 build build-arch: rs
27 build-indep:
28
29 rs:
30         dh_testdir
31         -rm -f rs
32         +for opts in '-flto=jobserver' '-fwhole-program --combine' ''; do \
33                 set -x; \
34                 ${CC} ${CPPFLAGS} ${CFLAGS} $$opts ${LDFLAGS} -o rs \
35                     rs.c ${LDADD}; \
36                 test -x rs && exit 0; \
37         done; echo >&2 Compiling failed.; exit 1
38 ifeq (,$(filter nocheck,${DEB_BUILD_OPTIONS}))
39         case $$(for i in 1 2 3 4 5 6 7 8 9; do echo $$i; done | \
40             ./rs 3 3 | md5sum) in \
41         d37c2eb45172c55279711a8e53041912*) echo pass test;; \
42         *) rm -f rs; echo FAIL test;; \
43         esac; test -x rs
44 endif
45
46 clean:
47         dh_testdir
48         -rm -f rs
49         dh_clean
50
51 binary-indep: build-indep
52
53 binary-arch: build-arch
54         dh_testdir
55         dh_testroot
56         if test -x "$$(which dh_prep)"; then dh_prep; else dh_clean -k; fi
57         dh_installchangelogs
58         dh_installdocs
59         dh_install
60         dh_installman
61         dh_link
62         dh_strip
63         dh_compress
64         dh_fixperms
65         dh_installdeb
66         dh_shlibdeps
67         dh_gencontrol
68         dh_md5sums
69         dh_builddeb
70
71 binary: binary-indep binary-arch
72 .PHONY: binary binary-arch binary-indep build build-arch build-indep clean