Don't include /var/run/shibboleth in the package and clean up on remove
[shibboleth/sp.git] / debian / rules
1 #!/usr/bin/make -f
2 # -*- makefile -*-
3
4 # Uncomment this to turn on verbose mode.
5 #export DH_VERBOSE=1
6
7 # This has to be exported to make some magic below work.
8 export DH_OPTIONS
9
10 CFLAGS = -g
11 CXXFLAGS = -g
12 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
13     DEBUG = --enable-debug
14 else
15     DEBUG =
16 endif
17
18 # Tell Autoconf the correct system types.
19 DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
20 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
21 ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
22     SYSTEM = --build $(DEB_HOST_GNU_TYPE)
23 else
24     SYSTEM = --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
25 endif
26
27 # These variable is used only by get-orig-source, which will normally only be
28 # run by maintainers.
29 DEBVERS := $(shell dpkg-parsechangelog | grep ^Version: | cut -d' ' -f2 \
30                 | cut -d- -f1)
31 VERSION := $(shell echo '$(DEBVERS)' | sed -e 's/[+-].*//' -e 's/~//g')
32 URL      = http://shibboleth.internet2.edu/downloads/shibboleth/cppsp
33
34 # Download the upstream source and do the repackaging that we have to do for
35 # DFSG reasons.  Depends on wget.
36 get-orig-source:
37         wget $(URL)/$(VERSION)/shibboleth-sp-$(VERSION).tar.gz
38         tar xfz shibboleth-sp-$(VERSION).tar.gz
39         rm shibboleth-sp-$(VERSION).tar.gz
40         rm shibboleth-$(VERSION)/schemas/WS-Trust.xsd
41         mv shibboleth-$(VERSION) shibboleth-sp2_$(DEBVERS).orig
42         tar cf shibboleth-sp2_$(DEBVERS).orig.tar \
43             shibboleth-sp2_$(DEBVERS).orig
44         rm -r shibboleth-sp2_$(DEBVERS).orig
45         gzip -9 shibboleth-sp2_$(DEBVERS).orig.tar
46
47 configure: configure-stamp
48 configure-stamp:
49         dh_testdir
50         cp /usr/share/misc/config.guess config.guess
51         cp /usr/share/misc/config.sub config.sub
52         rm -f libtool.m4
53         libtoolize --force
54         autoreconf --force
55         rm -rf autom4te.cache
56         CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" ./configure --prefix=/usr \
57             --sysconfdir=/etc --libexecdir=/usr/lib/shibboleth \
58             --localstatedir=/var --enable-apache-22 \
59             --with-apxs2=/usr/bin/apxs2 --disable-dependency-tracking \
60             $(SYSTEM)
61         touch $@
62
63 build: build-arch build-indep
64 build-arch: build-stamp
65 build-indep:
66 build-stamp: configure-stamp
67         dh_testdir
68         $(MAKE)
69         touch $@
70
71 clean:
72         dh_testdir
73         dh_testroot
74         rm -f configure-stamp build-stamp install-stamp
75         [ ! -f Makefile ] || $(MAKE) distclean
76         find . -name Makefile.in -print0 | xargs -0r rm
77         dh_clean aclocal.m4 config.h config.h.in config.status configure \
78             config.guess config.sub libtool.m4 ltmain.sh \
79             debian/libapache2-mod-shib2.shibd.init
80
81 install: install-stamp
82 install-stamp:
83         dh_testdir
84         dh_testroot
85         dh_clean -k
86         $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
87         rm -r $(CURDIR)/debian/tmp/usr/share/doc/shibboleth
88         rm -r $(CURDIR)/debian/tmp/var/run
89         rm $(CURDIR)/debian/tmp/etc/shibboleth/*.dist
90         rm $(CURDIR)/debian/tmp/etc/shibboleth/*.config
91         rm $(CURDIR)/debian/tmp/etc/shibboleth/shibd-osx.plist
92         rm $(CURDIR)/debian/tmp/etc/shibboleth/shibd-redhat
93         rm $(CURDIR)/debian/tmp/etc/shibboleth/sp-*.pem
94         chmod +x $(CURDIR)/debian/tmp/etc/shibboleth/keygen.sh
95         mv $(CURDIR)/debian/tmp/etc/shibboleth/keygen.sh \
96             $(CURDIR)/debian/tmp/usr/sbin/shib-keygen
97         mv $(CURDIR)/debian/tmp/etc/shibboleth/shibd-debian \
98             $(CURDIR)/debian/libapache2-mod-shib2.shibd.init
99         dh_installdirs -s -i
100         mv $(CURDIR)/debian/tmp/usr/lib/shibboleth/mod_shib_22.so \
101             $(CURDIR)/debian/libapache2-mod-shib2/usr/lib/apache2/modules
102         rm $(CURDIR)/debian/tmp/usr/lib/shibboleth/mod_shib_22.la
103         pod2man $(CURDIR)/debian/man-pages/mdquery.pod --section 1 \
104             --center 'Shibboleth' --release 2.0 \
105             $(CURDIR)/debian/libapache2-mod-shib2/usr/share/man/man1/mdquery.1
106         pod2man $(CURDIR)/debian/man-pages/resolvertest.pod --section 1 \
107             --center 'Shibboleth' --release 2.0 \
108             $(CURDIR)/debian/libapache2-mod-shib2/usr/share/man/man1/resolvertest.1
109         pod2man $(CURDIR)/debian/man-pages/shib-keygen.pod --section 8 \
110             --center 'Shibboleth' --release 2.0 \
111             $(CURDIR)/debian/libapache2-mod-shib2/usr/share/man/man8/shib-keygen.8
112         pod2man $(CURDIR)/debian/man-pages/shibd.pod --section 8 \
113             --center 'Shibboleth' --release 2.0 \
114             $(CURDIR)/debian/libapache2-mod-shib2/usr/share/man/man8/shibd.8
115         dh_install -s -i --fail-missing
116         touch $@
117
118 binary: binary-arch binary-indep
119 binary-arch: DH_OPTIONS=-a
120 binary-arch: install-stamp
121         dh_testdir
122         dh_testroot
123         dh_installchangelogs
124         dh_installdocs -A doc/NOTICE.txt
125         dh_installinit --name=shibd
126         dh_installlogcheck
127         dh_strip
128         dh_compress
129         dh_fixperms
130         DH_OPTIONS="" dh_makeshlibs -plibshibsp2
131         dh_installdeb
132         dh_shlibdeps
133         dh_gencontrol
134         dh_md5sums
135         dh_builddeb
136
137 binary-indep: DH_OPTIONS=-i
138 binary-indep: install-stamp
139         dh_testdir
140         dh_testroot
141         dh_installchangelogs
142         dh_installdocs -A doc/NOTICE.txt
143         dh_compress
144         dh_fixperms
145         dh_installdeb
146         dh_gencontrol
147         dh_md5sums
148         dh_builddeb
149
150 .PHONY: binary binary-arch binary-indep build build-arch build-indep clean
151 .PHONY: install