summaryrefslogtreecommitdiff
path: root/debian/rules
blob: c21dd5da3f0bbe678c9eb30112b1be601c7e10e5 (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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/usr/bin/make -f

DEB_BUILD_GNU_TYPE = $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE = $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
CONFARGS = --host=$(DEB_HOST_GNU_TYPE)
endif

CFLAGS = -W -Wall -g
INSTALL = install
INSTALL_FILE    = $(INSTALL) -p    -o root -g root  -m  644
INSTALL_PROGRAM = $(INSTALL) -p    -o root -g root  -m  755
INSTALL_SCRIPT  = $(INSTALL) -p    -o root -g root  -m  755
INSTALL_DIR     = $(INSTALL) -p -d -o root -g root  -m  755

ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
else
CFLAGS += -O2
endif

ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
INSTALL_PROGRAM += -s
endif

ifeq (x86_64-linux-gnu,$(DEB_HOST_GNU_TYPE))
BIARCH_LIB_DIR=usr/lib32
else
ifneq (,$(findstring $(DEB_HOST_GNU_TYPE), ppc64-linux-gnu x86_64-kfreebsd-gnu))
BIARCH_LIB_DIR=usr/lib32
else
BIARCH_LIB_DIR=usr/lib64
endif
endif

fakeroot_version := $(shell dpkg-parsechangelog | sed -n '/^Version: \(.*\)$$/ {s//\1/;p}')

build: build-stamp
build-stamp:
	$(checkdir)

	mkdir obj-sysv obj-tcp
	cd obj-sysv && CFLAGS="$(CFLAGS)" ../configure --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib/libfakeroot --program-suffix=-sysv $(CONFARGS)

	cd obj-tcp && CFLAGS="$(CFLAGS)" ../configure --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib/libfakeroot --with-ipc=tcp --program-suffix=-tcp $(CONFARGS)

	cd obj-sysv && $(MAKE)
	cd obj-tcp && $(MAKE)

ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	cd obj-sysv && $(MAKE) check
	cd obj-tcp && $(MAKE) check
endif
endif

	touch build-stamp

clean: checkroot
	$(checkdir)
	rm -rf obj-sysv obj64-sysv obj-tcp obj64-tcp
	rm -f build-stamp build-biarch-stamp
#	 Add here commands to clean up after the build process.
	-cd obj-sysv && $(MAKE) distclean
	-cd obj-tcp && $(MAKE) distclean
ifneq (,$(findstring $(DEB_HOST_GNU_TYPE), sparc-linux-gnu s390-linux-gnu x86_64-linux-gnu i486-linux-gnu powerpc-linux-gnu ppc64-linux-gnu x86_64-kfreebsd-gnu))
	-cd obj64-sysv && $(MAKE) distclean
	-cd obj64-tcp && $(MAKE) distclean
endif
	rm -rf .deps
	rm -f debian/substvars debian/files
	rm -rf debian/tmp obj obj64 autom4te.cache
	find . -type f -a \( -name \#\*\# -o -name .\*\~ -o -name \*\~ -o -name DEADJOE -o -name \*.orig -o -name \*.rej -o -name \*.bak -o -name .\*.orig -o -name .\*.rej -o -name .SUMS -o -name TAGS -o -name core -o \( -path \*/.deps/\* -a -name \*.P \) \) -exec rm -f {} \;

# Build architecture-independent files here.
binary-indep: build
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build checkroot
	$(checkdir)

	cd obj-tcp && $(MAKE) DESTDIR="$(CURDIR)/debian/tmp" install

	chmod 644 debian/tmp/usr/lib/libfakeroot/libfakeroot-0.so
	mv debian/tmp/usr/lib/libfakeroot/libfakeroot-0.so debian/tmp/usr/lib/libfakeroot/libfakeroot-tcp.so
	rm debian/tmp/usr/lib/libfakeroot/libfakeroot.so

	cd obj-sysv && $(MAKE) DESTDIR="$(CURDIR)/debian/tmp" install

	chmod 644 debian/tmp/usr/lib/libfakeroot/libfakeroot-0.so
	mv debian/tmp/usr/lib/libfakeroot/libfakeroot-0.so debian/tmp/usr/lib/libfakeroot/libfakeroot-sysv.so
	rm debian/tmp/usr/lib/libfakeroot/libfakeroot.so

	$(INSTALL_DIR) debian/tmp/DEBIAN debian/tmp/usr/bin/
#	$(INSTALL_SCRIPT) scripts/fakeroot debian/tmp/usr/bin/
	$(INSTALL_DIR) debian/tmp/usr/share/doc/fakeroot \
		           debian/tmp/usr/lib/libfakeroot
	$(INSTALL_FILE) README doc/README.saving DEBUG debian/tmp/usr/share/doc/fakeroot/
	( echo "fakeroot was written originally by"; \
	  echo "joost witteveen"                   ; \
	  echo "------------------------------------------------"; \
	  cat COPYING) > debian/tmp/usr/share/doc/fakeroot/copyright
#	cd obj-sysv && ./libtool --finish $(CURDIR)/debian/tmp/usr/lib/fakeroot
	rm -f debian/tmp/usr/lib/libfakeroot/libfakeroot.*a*
	rm -f debian/tmp/usr/bin/simple
ifneq (,$(findstring $(DEB_HOST_GNU_TYPE), sparc-linux-gnu s390-linux-gnu x86_64-linux-gnu i486-linux-gnu powerpc-linux-gnu ppc64-linux-gnui x86_64-kfreebsd-gnu))
	$(MAKE) -f debian/rules binary-biarch
endif
	$(INSTALL_FILE) debian/copyright debian/tmp/usr/share/doc/fakeroot/copyright
	$(INSTALL_FILE) debian/changelog debian/tmp/usr/share/doc/fakeroot/changelog
	gzip -9f debian/tmp/usr/share/man/man1/faked-sysv.1 \
		 debian/tmp/usr/share/man/man1/fakeroot-sysv.1 \
		 debian/tmp/usr/share/man/man1/faked-tcp.1 \
		 debian/tmp/usr/share/man/man1/fakeroot-tcp.1 \
		 debian/tmp/usr/share/man/es/man1/faked-sysv.1 \
		 debian/tmp/usr/share/man/es/man1/fakeroot-sysv.1 \
		 debian/tmp/usr/share/man/es/man1/faked-tcp.1 \
		 debian/tmp/usr/share/man/es/man1/fakeroot-tcp.1 \
		 debian/tmp/usr/share/man/fr/man1/faked-sysv.1 \
		 debian/tmp/usr/share/man/fr/man1/fakeroot-sysv.1 \
		 debian/tmp/usr/share/man/fr/man1/faked-tcp.1 \
		 debian/tmp/usr/share/man/fr/man1/fakeroot-tcp.1 \
		 debian/tmp/usr/share/man/nl/man1/faked-sysv.1 \
		 debian/tmp/usr/share/man/nl/man1/fakeroot-sysv.1 \
		 debian/tmp/usr/share/man/nl/man1/faked-tcp.1 \
		 debian/tmp/usr/share/man/nl/man1/fakeroot-tcp.1 \
		 debian/tmp/usr/share/man/sv/man1/faked-sysv.1 \
		 debian/tmp/usr/share/man/sv/man1/fakeroot-sysv.1 \
		 debian/tmp/usr/share/man/sv/man1/faked-tcp.1 \
		 debian/tmp/usr/share/man/sv/man1/fakeroot-tcp.1 \
		 debian/tmp/usr/share/doc/fakeroot/changelog
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	strip --remove-section=.comment --remove-section=.note --strip-unneeded debian/tmp/usr/lib/libfakeroot/libfakeroot-sysv.so
	strip --remove-section=.comment --remove-section=.note --strip-unneeded debian/tmp/usr/lib/libfakeroot/libfakeroot-tcp.so
	strip --remove-section=.comment --remove-section=.note debian/tmp/usr/bin/faked-sysv
	strip --remove-section=.comment --remove-section=.note debian/tmp/usr/bin/faked-tcp
#	strip --strip-debug debian/tmp/usr/lib/libfakeroot.a
endif
	$(INSTALL_SCRIPT) debian/fakeroot.postrm debian/tmp/DEBIAN/postrm
	$(INSTALL_SCRIPT) debian/fakeroot.prerm debian/tmp/DEBIAN/prerm
ifneq ($(DEB_HOST_GNU_SYSTEM),gnu)
	sed 's/@FAKEROOT_SYSV_ALTPRIO@/50/;s/@FAKEROOT_TCP_ALTPRIO@/30/;' \
		debian/fakeroot.postinst.in > debian/fakeroot.postinst
else
	sed 's/@FAKEROOT_SYSV_ALTPRIO@/30/;s/@FAKEROOT_TCP_ALTPRIO@/50/;' \
		debian/fakeroot.postinst.in > debian/fakeroot.postinst
endif
	$(INSTALL_SCRIPT) debian/fakeroot.postinst debian/tmp/DEBIAN/postinst
	rm -f debian/fakeroot.postinst
	# We can just use the deps for faked.
	dpkg-shlibdeps -Tdebian/substvars \
		debian/tmp/usr/bin/faked-sysv \
		debian/tmp/usr/bin/faked-tcp
	dpkg-gencontrol -ldebian/changelog -isp -Tdebian/substvars -Pdebian/tmp
	chmod 644 debian/tmp/DEBIAN/control
	chown root:root debian/tmp/DEBIAN/control
	cd debian/tmp && find * -type f ! -regex '^DEBIAN/.*' -print0 | xargs -r0 md5sum > DEBIAN/md5sums
	dpkg-deb --build debian/tmp ..

binary-biarch:
	$(checkdir)
	mkdir obj64-sysv obj64-tcp

ifneq (,$(findstring $(DEB_HOST_GNU_TYPE),sparc-linux-gnu))
	cd obj64-sysv && CC="gcc -m64" ../configure --prefix=/usr --mandir=/usr/share/man --build=sparc-linux --host=sparc64-linux-gnu --program-suffix=-sysv $(CONFARGS)
	cd obj64-tcp && CC="gcc -m64" ../configure --prefix=/usr --mandir=/usr/share/man --build=sparc-linux --host=sparc64-linux-gnu --with-ipc=tcp --program-suffix=-tcp $(CONFARGS)
endif
ifneq (,$(findstring $(DEB_HOST_GNU_TYPE),s390-linux-gnu))
	cd obj64-sysv && CC="gcc -m64" ../configure --prefix=/usr --mandir=/usr/share/man --build=s390-linux --host=s390x-linux-gnu --program-suffix=-sysv $(CONFARGS)
	cd obj64-tcp && CC="gcc -m64" ../configure --prefix=/usr --mandir=/usr/share/man --build=s390-linux --host=s390x-linux-gnu --with-ipc=tcp --program-suffix=-tcp $(CONFARGS)
endif
ifneq (,$(findstring $(DEB_HOST_GNU_TYPE),x86_64-linux-gnu))
	cd obj64-sysv && CC="gcc -m32" ../configure --prefix=/usr --mandir=/usr/share/man --build=x86_64-linux --host=i486-linux-gnu --program-suffix=-sysv $(CONFARGS)
	cd obj64-tcp && CC="gcc -m32" ../configure --prefix=/usr --mandir=/usr/share/man --build=x86_64-linux --host=i486-linux-gnu --with-ipc=tcp --program-suffix=-tcp $(CONFARGS)
endif
ifneq (,$(findstring $(DEB_HOST_GNU_TYPE),i486-linux-gnu))
	cd obj64-sysv && CC="gcc -m64" ../configure --prefix=/usr --mandir=/usr/share/man --build=i486-linux --host=x86_64-linux-gnu --program-suffix=-sysv $(CONFARGS)
	cd obj64-tcp && CC="gcc -m64" ../configure --prefix=/usr --mandir=/usr/share/man --build=i486-linux --host=x86_64-linux-gnu --with-ipc=tcp --program-suffix=-tcp $(CONFARGS)
endif
ifneq (,$(findstring $(DEB_HOST_GNU_TYPE),powerpc-linux-gnu))
	cd obj64-sysv && CC="gcc -m64" ../configure --prefix=/usr --mandir=/usr/share/man --build=powerpc-linux --host=ppc64-linux-gnu --program-suffix=-sysv $(CONFARGS)
	cd obj64-tcp && CC="gcc -m64" ../configure --prefix=/usr --mandir=/usr/share/man --build=powerpc-linux --host=ppc64-linux-gnu --with-ipc=tcp --program-suffix=-tcp $(CONFARGS)
endif
ifneq (,$(findstring $(DEB_HOST_GNU_TYPE),ppc64-linux-gnu))
	cd obj64-sysv && CC="gcc -m32" ../configure --prefix=/usr --mandir=/usr/share/man --build=ppc64-linux --host=powerpc-linux-gnu --program-suffix=-sysv $(CONFARGS)
	cd obj64-tcp && CC="gcc -m32" ../configure --prefix=/usr --mandir=/usr/share/man --build=ppc64-linux --host=powerpc-linux-gnu --with-ipc=tcp --program-suffix=-tcp $(CONFARGS)
endif
ifneq (,$(findstring $(DEB_HOST_GNU_TYPE),x86_64-kfreebsd-gnu))
	cd obj64-sysv && CC="gcc -m32" ../configure --prefix=/usr --mandir=/usr/share/man --build=x86_64-kfreebsd --host=i486-kfreebsd-gnu --program-suffix=-sysv $(CONFARGS)
	cd obj64-tcp && CC="gcc -m32" ../configure --prefix=/usr --mandir=/usr/share/man --build=x86_64-kfreebsd --host=i486-kfreebsd-gnu --with-ipc=tcp --program-suffix=-tcp $(CONFARGS)
endif

	cd obj64-tcp && $(MAKE) libfakeroot.la
	$(INSTALL_DIR) debian/tmp/$(BIARCH_LIB_DIR)/libfakeroot
	cd obj64-tcp && $(SHELL) ./libtool --mode=install install libfakeroot.la \
		$(CURDIR)/debian/tmp/$(BIARCH_LIB_DIR)/libfakeroot/libfakeroot.la
	rm -f debian/tmp/$(BIARCH_LIB_DIR)/libfakeroot/libfakeroot.*a*
	chmod 644 debian/tmp/$(BIARCH_LIB_DIR)/libfakeroot/libfakeroot-0.so
	mv debian/tmp/$(BIARCH_LIB_DIR)/libfakeroot/libfakeroot-0.so debian/tmp/$(BIARCH_LIB_DIR)/libfakeroot/libfakeroot-tcp.so

	cd obj64-sysv && $(MAKE) libfakeroot.la
	$(INSTALL_DIR) debian/tmp/$(BIARCH_LIB_DIR)/libfakeroot
	cd obj64-sysv && $(SHELL) ./libtool --mode=install install libfakeroot.la \
		$(CURDIR)/debian/tmp/$(BIARCH_LIB_DIR)/libfakeroot/libfakeroot.la
	rm -f debian/tmp/$(BIARCH_LIB_DIR)/libfakeroot/libfakeroot.*a*
	chmod 644 debian/tmp/$(BIARCH_LIB_DIR)/libfakeroot/libfakeroot-0.so
	mv debian/tmp/$(BIARCH_LIB_DIR)/libfakeroot/libfakeroot-0.so debian/tmp/$(BIARCH_LIB_DIR)/libfakeroot/libfakeroot-sysv.so

	rm debian/tmp/$(BIARCH_LIB_DIR)/libfakeroot/libfakeroot.so
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
	strip --remove-section=.comment --remove-section=.note --strip-unneeded debian/tmp/$(BIARCH_LIB_DIR)/libfakeroot/libfakeroot-sysv.so
	strip --remove-section=.comment --remove-section=.note --strip-unneeded debian/tmp/$(BIARCH_LIB_DIR)/libfakeroot/libfakeroot-tcp.so
endif

source diff:
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

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

prebuild:
	printf "define(FAKEROOT_VERSION, %s)\n" $(fakeroot_version) >acinclude.m4

	autoreconf -fi

	cd doc && po4a -k 0 --rm-backups --variable "srcdir=$(CURDIR)/doc/" po4a/po4a.cfg

#	./configure
#	$(MAKE) dist
#	mv fakeroot-$(fakeroot_version).tar.gz ../fakeroot_$(fakeroot_version).tar.gz
#	$(MAKE) distclean

define checkdir
	test -f debian/rules
endef

checkroot:
	$(checkdir)
	test root = "`whoami`"