summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 2a657ca95ce2841772e5a2edd14ae5ec8094932c (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
#!/usr/bin/make -f
############################ -*- Mode: Makefile -*- ###########################
## rules ---
## Author           : Marcus Brinkmann <brinkmd@debian.org>
## Created On       : Sat,  1 Aug 1998 21:33:31 +0200
## Created On Node  : localhost
## Last Modified By : Marcus Brinkmann
## Last Modified On : Thu, 23 Sep 1999 01:41:38 +0200
## Last Machine Used: localhost
## Update Count     : 2
## Status           : Unknown, Use with caution!
## HISTORY          :
## Description      :
##
###############################################################################

# The name of the package (for example, `emacs').
package   := hurd

DEB_BUILD_GNU_TYPE = $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE = $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

# Configuration variables (these should be pretty generic)
CC = cc
CFLAGS = -O2 -g -pipe -Wall
LDFLAGS = -s
PREFIX = /usr
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/man
INFODIR = $(PREFIX)/info
DOCDIR = $(PREFIX)/share/doc/$(package)

#  Package specific stuff.  The idea is to try to make the rules
#  generic (gradually).

FILES_TO_CLEAN	= debian/files include/*.h
DIRS_TO_CLEAN	= debian/tmp debian/$(package)-dev build
STAMPS_TO_CLEAN	= stamp-build stamp-config

install_file	= install -o root -g root -m 644
install_program	= install -s -o root -g root -m 755
install_script  = install -o root -g root -m 755
make_directory	= install -d -o root -g root -m 755

define checkdir
	test -f debian/rules
endef

define checkroot
	@test 0 = "`id -u`" || (echo need root priviledges; exit 1)
endef

# Next is NOT a phony target.

configure: configure.in
	autoconf

# The next IS a phony target.

config: stamp-config
stamp-config: configure
	$(checkdir)
	-mkdir build
	cd build && ../configure --disable-profile \
	  --build=$(DEB_BUILD_GNU_TYPE) \
	  --host=$(DEB_HOST_GNU_TYPE) --prefix=
	touch stamp-config

all build: config stamp-build 
stamp-build:
	$(checkdir)
	cd build && $(MAKE)
# XXX-doc
	cd build && $(MAKE) -C doc hurd.info
	cd build && $(MAKE) -C doc hurd.ps
	touch stamp-build

clean:
	$(checkdir)
#	-cd build && make clean no_deps=t
	-rm -f  $(FILES_TO_CLEAN) $(STAMPS_TO_CLEAN)
	-rm -rf $(DIRS_TO_CLEAN)
# XXX-doc
	-rm -f doc/hurd.d doc/hurd.info* version.texi
	for NAME in hurd/*.h; do \
	  if [ -L $$NAME ] ; then \
	    rm -f $$NAME ; \
	  fi \
	done
	-rm -f core `find . \( -name '*.o' -name '*.orig' -o -name '*.rej' -o -name '*~' \
                -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
                -o -name '.*.rej' -o -name '.SUMS' \) -print`

binary: binary-indep binary-arch

binary-indep:
# We have nothing to do here.

binary-arch: build
	$(checkdir)
	$(checkroot)
	-rm -rf			debian/{tmp,$(package)-dev}

# first the general install
	$(make_directory)	debian/tmp/boot
	cd build && $(MAKE)	install prefix=`pwd`/../debian/tmp no_prof=t
# kill the profiling libs
	-rm -f			debian/tmp/lib/*_p.a
# /etc/motd is in base-files!
	-rm -f			debian/tmp/etc/motd
# probably we'll make debug packages later, for now, strip'em
	-strip --strip-unneeded	debian/tmp/lib/lib*.so
	-strip --strip-debug	debian/tmp/lib/lib*.a
	-strip --strip-all	debian/tmp/bin/*
	-strip --strip-all	debian/tmp/sbin/*
	-strip --strip-all	debian/tmp/boot/*
	-strip --strip-all	debian/tmp/hurd/*
	-strip --strip-all	debian/tmp/libexec/*
	chmod			0644 debian/tmp/lib/lib*.a
	chmod			0755 $(addprefix debian/tmp/,		\
						 include include/hurd	\
						 lib hurd bin sbin	\
						 dev libexec etc etc/login)

# now distribute the files
# first the source package
	$(make_directory)	debian/$(package)-dev/{DEBIAN,usr/{share/doc,bin,lib}}
	ln -s			$(package) debian/$(package)-dev$(DOCDIR)-dev
	mv			debian/tmp/include debian/$(package)-dev/usr/.
	mv			debian/tmp/lib/*.a debian/$(package)-dev/usr/lib/.
	# Create development library links.
	for file in `cd debian/tmp/lib && ls *.so.*`; do \
	  linkname=`echo "$$file" | sed 's/\..*$$/.so/'`; \
	  ln -sf /lib/$$file debian/$(package)-dev/usr/lib/$$linkname; \
	done
	rm -f debian/tmp/lib/*.so

	dpkg-gencontrol		-isp -p$(package)-dev -Pdebian/$(package)-dev
	chown -R root.root	debian/$(package)-dev
	dpkg --build		debian/$(package)-dev ..

# now the shared libs and other stuff
	$(make_directory)	debian/tmp/DEBIAN
	$(make_directory)	debian/tmp$(DOCDIR)
	$(make_directory)	debian/tmp$(INFODIR)

	gzip -9fq		debian/tmp/boot/serverboot

# Only found in CVS, not the distribution.
#	$(install_file)		BUGS debian/tmp$(DOCDIR)
#	$(install_file)		TODO debian/tmp$(DOCDIR)
	$(install_file)		INSTALL debian/tmp$(DOCDIR)
	$(install_file)		NEWS debian/tmp$(DOCDIR)
	$(install_file)		README debian/tmp$(DOCDIR)
	$(install_file)		tasks debian/tmp$(DOCDIR)
	$(install_file)		ChangeLog debian/tmp$(DOCDIR)/changelog
	$(install_file)		debian/README.Debian debian/tmp$(DOCDIR)
	$(install_file)		debian/changelog debian/tmp$(DOCDIR)/changelog.Debian
# XXX-doc
	$(install_file)		build/doc/hurd.ps debian/tmp$(DOCDIR)
	gzip -9frq		debian/tmp$(DOCDIR)/.
	$(install_file)		debian/copyright debian/tmp$(DOCDIR)

# XXX-doc
	$(install_file)		build/doc/hurd.info* debian/tmp$(INFODIR)
	-gzip -9frq		debian/tmp$(INFODIR)
# XXX Remove the vague attempt of the makefiles to install the docs.
	rm -fR			debian/tmp/info

	$(install_file)		debian/servers.boot debian/tmp/boot/servers.boot
	$(make_directory)	debian/tmp/servers

# libexec/runsystem is managed by update-alternatives
	mv			debian/tmp/libexec/runsystem debian/tmp/libexec/runsystem.gnu

# We have our own rc, slightly modified.
	cp			debian/rc debian/tmp/libexec/rc
	$(install_script)	debian/update-rc.d debian/tmp/sbin

	$(install_file)		debian/conffiles debian/tmp/DEBIAN/conffiles
	$(install_file)		debian/shlibs debian/tmp/DEBIAN/shlibs
	$(install_script)	debian/postinst debian/tmp/DEBIAN/postinst
	$(install_script)	debian/prerm debian/tmp/DEBIAN/prerm

	# Get list of dynamically linked executables
	dpkg-shlibdeps		-p$(package) \
				`file debian/tmp/bin/* \
				      debian/tmp/hurd/* \
				      debian/tmp/lib/* \
				      debian/tmp/libexec/* \
				      debian/tmp/sbin/* \
				| egrep '(executable.*dynamic)|(shared object)' \
				| cut -f 1 -d ':'`
	dpkg-gencontrol         -isp -p$(package) -Pdebian/tmp
	chown -R root.root      debian/tmp
	dpkg --build            debian/tmp ..

.PHONY: build config clean binary-indep binary-arch binary