summaryrefslogtreecommitdiff
path: root/debian/rules
blob: e083ab35a43e65a844557b4af8d1feae2b0eba19 (plain)
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

DISTRO :=$(shell lsb_release -is 2>/dev/null || echo Debian)

DEB_HOST_GNU_TYPE=$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE=$(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_MULTIARCH=$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
CROSS= --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE) --cache-file=$(DEB_HOST_GNU_TYPE).cache
else
CROSS=
endif

ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
STRIP=y
endif

ifndef DEB_HOST_ARCH
DEB_BUILD_ARCH := $(shell dpkg --print-installation-architecture)
DEB_HOST_ARCH = $(DEB_BUILD_ARCH)
endif

ifndef DEB_HOST_ARCH_OS
DEB_HOST_ARCH_OS := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
endif

export arch = $(DEB_HOST_ARCH)
version := $(shell sed -e '1{;s|^util-linux (\(.*\))\ .*|\1|;q;}' debian/changelog)
Upstream := $(shell sed 's/^.*(\(.*\)-.*).*/\1/; q' debian/changelog)

CONFOPTS= --enable-raw --enable-partx --with-slang
ifneq ($(DEB_HOST_ARCH_OS),hurd)
CONFOPTS += --enable-rdev
endif
ifeq ($(DEB_HOST_ARCH_OS),linux)
CONFOPTS += --with-selinux
endif
ifeq ($(DEB_HOST_ARCH_OS),illumos)
CPPFLAGS = "-DBYTE_ORDER=LITTLE_ENDIAN -DLITTLE_ENDIAN=1234 -D__sighandler_t=sighandler_t -Difr_hwaddr=ifr_addr -DNGROUPS=NGROUPS_MAX"
# /bin is a symlink to /usr/bin:
CONFOPTS += --bindir=/usr/bin
CONFOPTS += --sbindir=/usr/sbin
CONFOPTS += --libdir=/usr/lib/$(DEB_HOST_MULTIARCH)
# No /proc/partitions on Illumos/Solaris:
CONFOPTS += --disable-libblkid
CONFOPTS += --disable-mount
CONFOPTS += --disable-fsck
CONFOPTS += --disable-agetty
CONFOPTS += CPPFLAGS=$(CPPFLAGS)
endif

build: build-stamp
build-stamp:
	dh_testdir
	./configure $(CONFOPTS) $(CROSS)
	$(MAKE) all CPU=$(arch) arch=$(arch)
	touch build-stamp

autofiles:
	AM_OPTS=--copy ./autogen.sh
	rm -rf autom4te.cache

clean-preunpatch: 
	dh_testdir
	dh_testroot
	dh_clean
	test ! -d ${base} || rm -rf ${base}
	-$(MAKE) distclean

clean: clean-preunpatch
	find . -name \*.o -exec rm {} \;
	rm -f build-stamp

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	$(MAKE) install DESTDIR=`pwd`/debian/util-linux INSTALL_STRIP_FLAG=""
	dh_installdocs -i -s
	install -m 644 login-utils/README.modems-with-agetty debian/util-linux/usr/share/doc/util-linux/README.modems-with-agetty
	install -m 755 debian/util-linux.initramfs debian/util-linux/usr/share/initramfs-tools/hooks/utillinux
	dh_installexamples -i -s
	dh_installmenu -i -s
	dh_installcron -i -s
	dh_installinfo -i -s
	dh_installchangelogs docs/v*-ReleaseNotes -i -s
	dh_movefiles --sourcedir=debian/util-linux -i -s
	#
	# XXX - push things to where debian has always(?) had them...
ifeq ($(DEB_HOST_ARCH_OS),linux)
	mv debian/util-linux/usr/sbin/*part* debian/util-linux/usr/bin
	mv debian/util-linux/usr/bin/cytune debian/util-linux/usr/sbin
endif
	mv debian/util-linux/usr/bin/tailf debian/util-linux/bin
	mv debian/util-linux/usr/bin/isosize debian/util-linux/sbin
	mv debian/util-linux/usr/share/man/man8/linux32.8 debian/util-linux/usr/share/man/man1/linux32.1
	mv debian/util-linux/usr/share/man/man8/linux64.8 debian/util-linux/usr/share/man/man1/linux64.1
	# the version in bsdmainutils seems newer.
	rm -f debian/bsdutils/usr/bin/look debian/bsdutils/usr/share/man/man1/look.1
	rm -f debian/bsdutils/usr/bin/hexdump debian/bsdutils/usr/share/man/man1/hexdump.1
	# and it's less pain to just let bsmainutils deliver col for now.
	rm -f debian/bsdutils/usr/bin/col* debian/bsdutils/usr/share/man/man1/col*.1
	rm -f debian/bsdutils/usr/bin/ul debian/bsdutils/usr/share/man/man1/ul*.1
	rm -f debian/bsdutils/usr/bin/cal debian/bsdutils/usr/share/man/man1/cal.1
	# remove *.la files and empty directories which do not belong into util-linux
	rm -f debian/util-linux/usr/lib/*.la
	rm -rf debian/util-linux/usr/include
	rm -rf debian/util-linux/usr/lib/pkgconfig
	# perl gets to do rename, not us.
	mv debian/util-linux/usr/bin/rename debian/util-linux/usr/bin/rename.ul
	mv debian/util-linux/usr/share/man/man1/rename.1 debian/util-linux/usr/share/man/man1/rename.ul.1
	rm -f debian/util-linux/usr/share/info/dir
	#
	#
	mv debian/util-linux/usr/share/getopt/* debian/util-linux/usr/share/doc/util-linux/examples
	rmdir  debian/util-linux/usr/share/getopt
	install -m 644 debian/lintian-override debian/util-linux/usr/share/lintian/overrides/util-linux
	install -m 644 debian/mime.util-linux debian/util-linux/usr/lib/mime/packages/util-linux
	if [ -f debian/util-linux/sbin/hwclock ] ; then \
	    install -m 755 debian/hwclock.sh debian/util-linux/etc/init.d/hwclock.sh; \
	    install -m 755 debian/hwclock.sh debian/util-linux/etc/init.d/hwclockfirst.sh; \
	    sed -i -e '/^FIRST=/s/no/yes/' -e '/Provides:/s/ck/ckfirst/' \
		-e '/Required-Start:/s/checkroot/mountdevsubfs/' \
		-e '/Required-Start:/a# Required-Stop:' -e '/Required-Stop:/d' \
		-e '/Default-Start:/a# X-Start-Before:    checkroot' \
		-e '/Default-Start:/a# Default-Stop:' -e '/Default-Stop:/d' \
		debian/util-linux/etc/init.d/hwclockfirst.sh; \
	fi
	if [ -f debian/util-linux/sbin/hwclock ] ; then \
	    install -m 644 debian/hwclock.rules debian/util-linux/lib/udev/rules.d/85-hwclock.rules; \
	    install -m 755 debian/hwclock-set debian/util-linux/lib/udev/hwclock-set; \
	fi
	# copy blkid library and symlink into udeb
	ln debian/libblkid1/lib/libblkid.so.1.* debian/libblkid1-udeb/lib/
	ln debian/libblkid1/lib/libblkid.so.1   debian/libblkid1-udeb/lib/
	ln debian/util-linux/sbin/blkid debian/util-linux-udeb/sbin/
	# overwrite copyright
	install -m 644 debian/libblkid.copyright debian/libblkid1/usr/share/doc/libblkid1/copyright
	install -m 644 debian/libblkid.copyright debian/libblkid-dev/usr/share/doc/libblkid-dev/copyright
	# copy uuid library and symlink into udeb
	ln debian/libuuid1/lib/libuuid.so.1.* debian/libuuid1-udeb/lib/
	ln debian/libuuid1/lib/libuuid.so.1   debian/libuuid1-udeb/lib/
	# overwrite copyright
	install -m 644 debian/libuuid.copyright debian/libuuid1/usr/share/doc/libuuid1/copyright
	install -m 644 debian/libuuid.copyright debian/uuid-dev/usr/share/doc/uuid-dev/copyright
	install -m 644 debian/libuuid.copyright debian/uuid-runtime/usr/share/doc/uuid-runtime/copyright
	#
	cd debian; if [ -f util-linux/sbin/fdisk ]; then \
	    ln util-linux/sbin/*fdisk fdisk-udeb/usr/sbin/; \
	    S=fdisk-udeb/usr/sbin/cfdisk; if [ -f $$S ]; then mv $$S cfdisk-udeb/usr/sbin/; fi; \
	fi
	cd debian/util-linux-locales && find usr/share/locale -type f | while read x; do ln $$x ../cfdisk-udeb/$$x; done
ifeq ($(DEB_HOST_ARCH_OS),linux)
	install -m 644 debian/mount.fstab debian/mount/usr/share/doc/mount/examples/fstab
ifeq ($(arch),$(findstring $(arch),powerpc ppc64))
	mv -f debian/util-linux/sbin/fdisk debian/util-linux/sbin/ddisk
	mv -f debian/util-linux/usr/share/man/man8/fdisk.8 debian/util-linux/usr/share/man/man8/ddisk.8
else
	cd debian/util-linux && if [ -f sbin/hwclock ] ; then ln -sf hwclock.8.gz usr/share/man/man8/clock.8.gz; fi
endif
endif
ifneq ($(DEB_HOST_ARCH_OS),hurd)
	cd debian/util-linux/sbin ; ln agetty getty
	cd debian/util-linux/usr/share/man/man8 ; ln agetty.8 getty.8
endif
ifneq ($(DEB_HOST_ARCH_OS),linux)
	cd debian/util-linux/sbin ; mv mkswap mkswap.linux
	cd debian/util-linux/usr/share/man/man8 ; mv mkswap.8 mkswap.linux.8
endif
	dh_compress -i -s
	dh_fixperms -i -s -Xusr/bin/wall -Xbin/mount -Xbin/umount
	rm -rf debian/*-udeb/usr/share/doc
	dh_link -i -s


# Build architecture-independent files here.
binary-indep: build install
	dh_testdir -i
	dh_testroot -i
	dh_installdeb -i
	dh_gencontrol -i -- -VUpstream=$(Upstream)
	dh_md5sums -i
	dh_builddeb -i

# Build architecture-dependent files here.
binary-arch: build install
	dh_testdir -s
	dh_testroot -s
	dh_installinit -s -- defaults 15 85
	[ -n "$(STRIP)" ] || dh_strip -s
	dh_makeshlibs -s
	dh_installdeb -s
	dh_shlibdeps -s
ifeq ($(DEB_HOST_ARCH_OS),hurd)
	echo util-linux:Conflicts=getty >> debian/util-linux.substvars
endif
	dh_gencontrol -s -Xbsdutils
	dh_gencontrol -pbsdutils -u-v1:$(version)
	dh_md5sums -s
	rm -f debian/*-udeb/DEBIAN/md5sums
	dh_builddeb -s


binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure