3538a619be31b6c55c3e466387ba70bd5f52f241
[alioth/cvs.git] / debian / rules
1 #!/usr/bin/make -f
2
3 DEB_BUILD_ARCH=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
4 DEB_HOST_ARCH=$(shell dpkg-architecture -qDEB_HOST_ARCH)
5 ifneq (${DEB_BUILD_ARCH},${DEB_HOST_ARCH})
6 DEB_BUILD_GNU_TYPE=$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
7 DEB_HOST_GNU_TYPE=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
8 endif
9
10 # is ${CC} defined anywhere (other than implicit rules?)
11 ifneq (,$(findstring $(origin CC),default undefined))
12 # no - then default to gcc (or cross-gcc)
13 ifneq (${DEB_BUILD_ARCH},${DEB_HOST_ARCH})
14 CC=                     ${DEB_HOST_GNU_TYPE}-gcc
15 else
16 CC=                     gcc
17 endif
18 endif
19
20 CONFIGURE_ENV:=         CC='${CC}'
21 EXTRA_CFLAGS=           -Wall -fno-strict-aliasing -Wformat
22 # addresses part of #698908
23 EXTRA_CFLAGS+=          -fwrapv
24 # for now. uses are mostly checked.
25 EXTRA_CFLAGS+=          -Wno-unused-result
26 EXTRA_CPPFLAGS=         -D_GNU_SOURCE -DUSE_LIBBSD
27
28 ifneq (,$(wildcard /usr/share/dpkg/buildflags.mk))
29 # dpkg-dev (>= 1.16.1~)
30 DEB_CFLAGS_MAINT_APPEND=${EXTRA_CFLAGS}
31 DEB_CPPFLAGS_MAINT_APPEND=${EXTRA_CPPFLAGS}
32 DEB_BUILD_MAINT_OPTIONS=hardening=+all
33 DPKG_EXPORT_BUILDFLAGS= Yes
34 include /usr/share/dpkg/buildflags.mk
35 else
36 # old-fashioned way to determine build flags
37 CFLAGS=                 -O$(if $(findstring noopt,${DEB_BUILD_OPTIONS}),0,2) -g
38 CFLAGS+=                ${EXTRA_CFLAGS}
39 CPPFLAGS+=              ${EXTRA_CPPFLAGS}
40 CONFIGURE_ENV+=         CFLAGS='${CFLAGS}'
41 CONFIGURE_ENV+=         CPPFLAGS='${CPPFLAGS}'
42 CONFIGURE_ENV+=         LDFLAGS='${LDFLAGS}'
43 endif
44
45 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
46 NUMJOBS=                $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
47 MAKEFLAGS+=             -j${NUMJOBS}
48 endif
49
50 LIBS+=                  -lbsd
51
52 CONFIGURE_ENV+=         LIBS='${LIBS}'
53 CONFIGURE_ENV+=         CSH=/bin/csh
54
55 CONFIGURE_ARGS:=        --prefix=/usr \
56                         --infodir=/usr/share/info \
57                         --mandir=/usr/share/man \
58                         --sysconfdir=/etc \
59                         --disable-dependency-tracking \
60                         --disable-maintainer-mode \
61                         --disable-pam \
62                         --disable-nls \
63                         --enable-client \
64                         --enable-password-authenticated-client \
65                         --enable-server \
66                         --enable-proxy \
67                         --enable-case-sensitivity \
68                         --enable-encryption \
69                         --disable-lock-compatibility \
70                         --enable-rootcommit \
71                         --disable-old-info-format-support \
72                         --enable-config-override=no \
73                         --without-krb4 \
74                         --with-gssapi \
75                         --with-external-zlib \
76                         --with-rsh=ssh \
77                         --with-editor=/usr/bin/editor \
78                         --with-tmpdir=/var/tmp \
79                         --with-umask=002 \
80                         --with-cvs-admin-group=_cvsadmin
81
82 ifneq (${DEB_BUILD_ARCH},${DEB_HOST_ARCH})
83 CONFIGURE_ARGS+=        --build=${DEB_BUILD_GNU_TYPE} \
84                         --host=${DEB_HOST_GNU_TYPE}
85 endif
86
87 MAKE_ARGS:=             MAKEINFO=makeinfo
88 MAKE_ARGS+=             MAKEINFOFLAGS=--no-split
89
90 CLEANFILES:=            autom4te.cache build-aux/config.guess \
91                         build-aux/config.sub cvs.spec debian/.*_stamp \
92                         debian/CVSTEMP debian/builddir debian/stagedir \
93                         doc/cvs-paper.pdf doc/cvs.1 doc/cvs.info* \
94                         doc/cvs.pdf doc/cvsclient.info* doc/cvsclient.pdf \
95                         doc/getdate-cvs.texi emx/Makefile os2/Makefile \
96                         vms/config.h windows-NT/config.h
97
98 debian/.configure_stamp:
99         dh_testdir
100         -rm -rf ${CLEANFILES}
101         cp /usr/share/misc/config.guess /usr/share/misc/config.sub build-aux/
102         dh_autoreconf
103         mkdir debian/builddir debian/stagedir
104         cd debian/builddir && \
105             env ${CONFIGURE_ENV} sh ../../configure ${CONFIGURE_ARGS}
106         @:>$@
107
108 build-indep:
109 build build-arch: debian/.build_stamp
110
111 debian/.build_stamp: debian/.configure_stamp
112         dh_testdir
113         cd debian/builddir && ${MAKE} ${MAKE_ARGS}
114         cd debian/builddir && ${MAKE} -C doc ${MAKE_ARGS} doc html info pdf txt
115 ifneq (,$(filter sanity,$(DEB_BUILD_OPTIONS)))
116         # run the testsuite after build (DEB_BUILD_OPTIONS=sanity)
117         # warning: this takes a *lot* of time!
118         cd debian/builddir && ${MAKE} ${MAKE_ARGS} check
119 endif
120         @:>$@
121
122 clean:
123         dh_testdir
124         dh_autoreconf_clean
125         -rm -rf ${CLEANFILES}
126         dh_clean
127
128 binary-indep:
129
130 binary-arch: debian/.build_stamp
131         dh_testdir
132         dh_testroot
133         if test -x "$$(which dh_prep)"; then dh_prep; else dh_clean -k; fi
134         -rm -rf debian/stagedir
135         mkdir -p debian/stagedir/clogs
136         cd debian/builddir && \
137             ${MAKE} ${MAKE_ARGS} DESTDIR=${CURDIR}/debian/stagedir install
138         cat ChangeLog ChangeLog.zoo >debian/stagedir/clogs/ChangeLog
139         cat doc/ChangeLog doc/ChangeLog.fsf >debian/stagedir/clogs/ChangeLog.doc
140         #cat lib/ChangeLog lib/ChangeLog.fsf >debian/stagedir/clogs/ChangeLog.lib
141         #cat src/ChangeLog src/ChangeLog-97 src/ChangeLog-96 src/ChangeLog-9395 \
142         #    src/ChangeLog-9194 >debian/stagedir/clogs/ChangeLog.src
143         cp src/ChangeLog debian/stagedir/clogs/ChangeLog.src
144         cp contrib/ChangeLog debian/stagedir/clogs/ChangeLog.contrib
145         cp diff/ChangeLog debian/stagedir/clogs/ChangeLog.diff
146         #cp m4/ChangeLog debian/stagedir/clogs/ChangeLog.m4
147         #cp man/ChangeLog debian/stagedir/clogs/ChangeLog.man
148         #cp tools/ChangeLog debian/stagedir/clogs/ChangeLog.tools
149         # fat and nonsensical to ship this
150         rm -f debian/stagedir/usr/share/cvs/contrib/rcs-5.7-commitid.patch
151         # uses csh
152         rm -f debian/stagedir/usr/share/cvs/contrib/sccs2rcs
153         # unsafe
154         rm -f debian/stagedir/usr/share/cvs/contrib/commit_prep
155         rm -f debian/stagedir/usr/share/cvs/contrib/cvs_acls
156         rm -f debian/stagedir/usr/share/cvs/contrib/log
157         rm -f debian/stagedir/usr/share/cvs/contrib/log_accum
158         rm -f debian/stagedir/usr/share/cvs/contrib/mfpipe
159         rm -f debian/stagedir/usr/share/cvs/contrib/rcslock
160         # we ship cvs-switchroot(1) instead
161         rm -f debian/stagedir/usr/share/cvs/contrib/newcvsroot
162         dh_installchangelogs debian/stagedir/clogs/ChangeLog
163         dh_installdocs
164         dh_install
165         dh_installinfo
166         dh_installman
167         dh_link
168         dh_strip
169         dh_compress -X.pdf
170         cd debian/cvs/usr/share/cvs/contrib && chmod +x descend.sh rcs2sccs.sh
171         dh_fixperms
172         dh_installdeb
173         dh_shlibdeps
174         dh_gencontrol
175         dh_md5sums
176         dh_builddeb -- -Zgzip -z9
177
178 binary: binary-indep binary-arch
179 .PHONY: binary binary-arch binary-indep build build-arch build-indep clean