File: rules

package info (click to toggle)
modutils 2.4.26-1.2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,724 kB
  • ctags: 1,708
  • sloc: ansic: 16,932; sh: 2,998; makefile: 549; lex: 490; yacc: 375
file content (187 lines) | stat: -rwxr-xr-x 6,070 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/usr/bin/make -f

# Debian package information
package		:= modutils
arch		:= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
version		:= $(shell dpkg-parsechangelog | sed -ne 's/^Version: \(.*\)/\1/p')

docdir		:= /usr/share/doc/$(package)
build_dir	:= debian/build
udeb_build_dir	:= debian/build-udeb
tmpdir		:= $(shell pwd)/debian/tmp/
udeb_tmpdir	:= $(shell pwd)/debian/tmp-udeb/

stamp-config:
	mkdir -p $(build_dir)
	cd $(build_dir) ; ../../configure --sysconfdir=/etc \
		--infodir='$${prefix}'/share/info \
		--mandir='$${prefix}'/share/man
	touch stamp-config

stamp-build: stamp-config
	cd $(build_dir) ; $(MAKE)
	touch stamp-build

stamp-udeb-config:
	mkdir -p $(udeb_build_dir)
	cd $(udeb_build_dir) ; \
		CFLAGS="-Os -fomit-frame-pointer" ../../configure \
		--sysconfdir=/etc \
		--infodir='$${prefix}'/share/info \
		--mandir='$${prefix}'/share/man
	touch stamp-udeb-config

stamp-udeb-build: stamp-udeb-config
	cd $(udeb_build_dir) ; $(MAKE)
	touch stamp-udeb-build

build: stamp-build stamp-udeb-build

clean:
	test -d debian
	rm -rf $(build_dir) $(udeb_build_dir)
	rm -rf $(tmpdir) $(udeb_tmpdir)
	rm -rf debian/files* debian/substvars
	rm -f stamp-config stamp-build
	rm -f stamp-udeb-config stamp-udeb-build

binary-indep:
	@echo Nothing to do

binary-udeb-arch: stamp-udeb-build
	test -d debian
	-rm -rf $(udeb_tmpdir) $(tmpdir)
	install -d -m 755 -o root -g root $(tmpdir)
	install -d -m 755 -o root -g root $(udeb_tmpdir)

	# Do the basic install
	cd $(udeb_build_dir) ; $(MAKE) prefix=$(tmpdir)/usr \
		exec_prefix=$(tmpdir) \
		sysconfdir=$(tmpdir)/etc install

	# Trick trick: copy only the things we really need. Note we use
	# tar in order to preserve (hard)links
	set -e ; \
		( cd $(tmpdir) ; \
		  tar cf - sbin/modprobe sbin/insmod sbin/depmod ) | \
		( cd $(udeb_tmpdir) ; tar xvpf - ) 

	# Add some Debian flavour
	strip --strip-unneeded -R .comment $(udeb_tmpdir)/sbin/*
	install -d -m 755 -o root -g root $(udeb_tmpdir)/DEBIAN

	# Lets build the full udeb now
	dpkg-shlibdeps $(udeb_tmpdir)/sbin/*
	dpkg-gencontrol -pmodutils-full -P$(udeb_tmpdir) \
		-nmodutils-full_$(version)_$(arch).udeb
	dpkg --build $(udeb_tmpdir) ../modutils-full_$(version)_$(arch).udeb

	# Now remove a few more things and do the basic udeb
	rm -f $(udeb_tmpdir)/sbin/depmod
	dpkg-shlibdeps $(udeb_tmpdir)/sbin/*
	dpkg-gencontrol -pmodutils-basic -P$(udeb_tmpdir) \
		-nmodutils-basic_$(version)_$(arch).udeb
	dpkg --build $(udeb_tmpdir) ../modutils-basic_$(version)_$(arch).udeb


binary-arch: checkroot stamp-build binary-udeb-arch
	test -d debian
	-rm -rf $(tmpdir)
	install -d -m 755 -o root -g root $(tmpdir)

# Setup directories
	install -d -m 755 -o root -g root $(tmpdir)/sbin
	install -d -m 755 -o root -g root $(tmpdir)/bin
	install -d -m 755 -o root -g root $(tmpdir)/usr/share/man/man1
	install -d -m 755 -o root -g root $(tmpdir)/usr/share/man/man2
	install -d -m 755 -o root -g root $(tmpdir)/usr/share/man/man5
	install -d -m 755 -o root -g root $(tmpdir)/usr/share/man/man8
	install -d -m 755 -o root -g root $(tmpdir)/lib/modules

	cd $(build_dir) ; $(MAKE) prefix=$(tmpdir)/usr exec_prefix=$(tmpdir) \
		sysconfdir=$(tmpdir)/etc install

	rm -f $(tmpdir)/usr/share/man/man8/kdstat.8

# Do some changes for Debian
	-strip $(tmpdir)/sbin/*

# add links in /bin for FHS.
	ln -s ../sbin/kernelversion $(tmpdir)/bin

	chmod 644 $(tmpdir)/usr/share/man/*/*
	gzip -9 $(tmpdir)/usr/share/man/*/*
	install -d -m 755 -o root -g root $(tmpdir)/etc/cron.daily
	install -p -m 755 -o root -g root debian/cron.daily \
		$(tmpdir)/etc/cron.daily/modutils

# Install documentation
	install -d -m 755 -o root -g root $(tmpdir)$(docdir)
	set -e ; for i in CREDITS NEWS README TODO ; do \
		install -p -m 644 -g root -o root $$i $(tmpdir)/$(docdir)/ ; \
	done
	install -p -m 644 -g root -o root ChangeLog \
		$(tmpdir)/$(docdir)/changelog
	gzip -9f $(tmpdir)/$(docdir)/*

# Install examples
	install -d -m 755 -o root -g root $(tmpdir)$(docdir)/examples
	install -p -g root -o root debian/examples/* \
			$(tmpdir)/$(docdir)/examples

# Install Debian-only documentation
	install -p -g root -m 644 -o root debian/modules.5 \
			$(tmpdir)/usr/share/man/man5
	gzip -9q $(tmpdir)/usr/share/man/man5/modules.5
	install -p -g root -m 644 -o root debian/module-policy \
			$(tmpdir)/$(docdir)/module-policy.Debian
	install -p -g root -m 644 -o root debian/changelog \
			$(tmpdir)/$(docdir)/changelog.Debian
	install -p -g root -m 644 -o root debian/README \
			$(tmpdir)/$(docdir)/README.Debian
	gzip -9f $(tmpdir)/$(docdir)/*Debian
	install -p -g root -m 644 -o root debian/copyright $(tmpdir)/$(docdir)

# Install Debian utils
	install -p -m 755 -o root -g root debian/update-modules $(tmpdir)/sbin/
	install -p -m 644 -o root -g root debian/update-modules.8 \
			$(tmpdir)/usr/share/man/man8/
	gzip -9q $(tmpdir)/usr/share/man/man8/*8

# Install configuration files
	install -d -g root -m 755 -o root $(tmpdir)/etc/modutils
	cp -a debian/conf/* $(tmpdir)/etc/modutils/
	chown -R root.root $(tmpdir)/etc/modutils

	install -d -g root -m 755 -o root $(tmpdir)/etc/init.d
	install -p -g root -m 755 -o root debian/rc.modutils \
		$(tmpdir)/etc/init.d/modutils
	
# Install Debian system files
	install -d -m 755 -o root -g root $(tmpdir)/DEBIAN
	install -p -m 644 -o root -g root debian/conffiles $(tmpdir)/DEBIAN
	install -p -m 755 -o root -g root debian/preinst $(tmpdir)/DEBIAN
	install -p -m 755 -o root -g root debian/postinst $(tmpdir)/DEBIAN
	install -p -m 755 -o root -g root debian/prerm $(tmpdir)/DEBIAN
	install -p -m 755 -o root -g root debian/postrm $(tmpdir)/DEBIAN

# Some left-over stuff
	install -d -m 755 -o root -g root $(tmpdir)/usr/bin
	ln -s /sbin/genksyms $(tmpdir)/usr/bin/genksyms

	dpkg-shlibdeps $(tmpdir)/sbin/*
	dpkg-gencontrol -isp -pmodutils
	chown -R root.root $(tmpdir)
	chmod -R go=rX $(tmpdir)
	dpkg --build $(tmpdir) ..

# Below here is fairly generic really

binary:		binary-indep binary-arch

checkroot:
	test 0 = "`id -u`"

.PHONY: build binary binary-arch binary-indep binary-udeb-arch clean checkroot

# vi: ts=8 sw=8 ai nowrap