Import Debian changes 1.8.5-1
[hcoop/debian/openafs.git] / debian / module / rules
CommitLineData
b7cfede0
BK
1#!/usr/bin/make -f
2
3# Determine whether we're building with optimization. This doesn't really
4# work at the moment due to upstream problems.
5ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
6 DEBIAN_OPT_FLAGS = --disable-optimize --disable-optimize-lwp
7 DEBIAN_KERN_FLAGS = --disable-optimize-kernel
8else
9 DEBIAN_OPT_FLAGS =
10 DEBIAN_KERN_FLAGS =
11endif
12
13# Find kernel build information.
14ifndef KSRC
15 KSRC := /lib/modules/$(shell uname -r)/build
16endif
17ifndef KPKG_DEST_DIR
18 KPKG_DEST_DIR = ..
19endif
20KVERS := $(shell perl debian/kernel-version $(KSRC))
21export KSRC
22export KVERS
23export KPKG_DEST_DIR
24
25SYS_NAME := $(shell KSRC="$(KSRC)" KVERS="$(KVERS)" ARCH="$(ARCH)" \
26 sh debian/sysname)
27
28package = openafs
29modulepkg := openafs-modules-$(KVERS)${INT_SUBARCH}
30moduledir := debian/$(modulepkg)/lib/modules/$(KVERS)/fs
31
32# After building the package, m-a calls debian/rules with the target
33# echo-debfile. Without this dummy rule, this would trigger the setup
34# target (by way of the wildcard rule for dh), which re-creates the setup
35# flag file that we removed during make clean.
36#
37# Then, if module-assistant unpacks a new version of the source, the setup
38# file already exists so the setup rule isn't run again. But the
39# debian/control file is the template from the new source, which doesn't
40# contain any buildable packages.
41#
42# Add a dummy target for echo-debfile to ensure that setup isn't run again
43# after clean. If there are further changes to module-assistant, causing it
44# to run other targets after clean, more similar dummy rules may need to be
45# added.
46echo-debfile:
47 @true
48
49# make-kpkg tries to rebuild debian/rules first, so add a dummy target to
50# avoid our dh wildcard rule and a fatal error.
51debian/rules ./debian/rules:
52 @true
53
54# This setup must be done before running any other target if it hasn't
55# already been done.
56setup:
57 @if test x"$(SYS_NAME)" = x"UNKNOWN" ; then exit 1 ; fi
58 @if test x"$(KVERS)" = x ; then \
59 echo 'No version in $(KSRC)/include/linux/version.h' >&2 ; \
60 exit 1 ; \
61 fi
62 sh debian/prep-modules $(KSRC)
63 touch $@
64
65%: setup
66 dh $@
67
68override_dh_auto_configure:
69 sh configure --prefix=$(CURDIR)/debian/tmp \
70 --with-afs-sysname=$(SYS_NAME) \
71 --disable-linux-syscall-probing \
72 --with-linux-kernel-headers=$(KSRC) \
73 --with-linux-kernel-packaging \
74 --enable-debug --enable-debug-lwp --enable-debug-kernel \
75 $(DEBIAN_OPT_FLAGS) $(DEBIAN_KERN_FLAGS)
76
77override_dh_auto_install:
78 cd src/libafs && make install DESTDIR=$(CURDIR)/debian/tmp
79 install -d -g root -o root -m 755 $(moduledir)
80 install -g root -o root -m 644 \
81 debian/tmp/lib/modules/*/extra/openafs/*o $(moduledir)/
82
83override_dh_clean:
84 rm -rf src/libafs/MODLOAD-* *-stamp
85 dh_clean Makefile config.log config.status setup src/libafs/Makefile \
86 src/libafs/Makefile.common src/libafs/asm src/libafs/asm-generic \
87 src/libafs/h src/libafs/linux src/libafs/net src/libafs/netinet \
88 src/libafs/rpc src/libafs/sys
89
90override_dh_gencontrol:
91 dh_gencontrol -- -v`cat debian/VERSION`
92
93override_dh_builddeb:
94 dh_builddeb --destdir="$(KPKG_DEST_DIR)"
95
96kdist_configure: override_dh_auto_configure
97
98kdist_image:
99 $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules binary-arch
100 $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules clean
101
102kdist:
103 $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules binary-arch
104 KSRC="$(KSRC)" KMAINT="$(KMAINT)" KEMAIL="$(KEMAIL)" \
105 sh -v debian/genchanges
106 $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules clean
107
108kdist_clean:
109 $(ROOT_CMD) $(MAKE) $(MFLAGS) -f debian/rules clean
110
111.PHONY: kdist kdist_clean kdist_configure kdist_image