summaryrefslogtreecommitdiff
path: root/libc/debian/rules
blob: 1db69ab8b2dfc9a75d3fe13ed7275c6239eea82b (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
#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

# only for testing:
#make = -m '/home/sunmake/make -j2 --sun'

# libs having "install_h" target to install headers first:
libs_headers := \
libc \
libmd \
libsocket \
libnsl \
libgen \

# Actually, order is important:
libs_core := \
common \
libavl \
libc \
libgen \
libcrypt \
libmd \
libmp \
libnsl \
libsocket \
libresolv \
libresolv2 \
crypt_modules \

libs_filters := \
libpthread \
librt \

libs := $(libs_core) $(libs_filters)

# usr/src/lib/nsswitch/* :
nsswitch := \
files \
user \
nis \
dns \
compat \

# usr/src/cmd/sgs/* :
sgs := \
libconv \
libdl \
liblddbg \
libelf \
libld \
librtld \
rtld \
lddstub \

# usr/src/cmd/* for libc functionality:
#
# NOTES:
# 1. tzselect is under zic
cmd := \
utmp_update \
utmpd \
zic \
getconf \
locale \
localedef \
zdump \
rpcinfo \
rpcgen \
getent \
gencat \

unpack: unpack-stamp
unpack-stamp:
	dh_testdir
	dh_illumos_gate
	echo 'export DEB_CRYPT_MODULE_DIR_32="$$DEB_LIBDIR_32/security"' >> illumos-gate/env.sh
	echo 'export DEB_CRYPT_MODULE_DIR_64="$$DEB_LIBDIR_64/security"' >> illumos-gate/env.sh
	touch $@

libc-mapfile := illumos-gate/usr/src/lib/libc/port/mapfile-vers
patch: patch-stamp
patch-stamp: unpack-stamp
	dh_testdir
	[ ! -f debian/patches/series ] || QUILT_PATCHES=debian/patches quilt push -a || test $$? = 2
	[ -f $(libc-mapfile).orig ] || mv $(libc-mapfile) $(libc-mapfile).orig
	. illumos-gate/env.sh; sed -r \
		-e "s,/usr/lib/ld.so.1,$$DEB_LIBDIR_32/ld.so.1," \
		-e "s,/usr/lib/amd64/ld.so.1,$$DEB_LIBDIR_64/ld.so.1," \
		$(libc-mapfile).orig > $(libc-mapfile)
	touch $@

unpatch:
	dh_testdir
	[ ! -f debian/patches/series ] || QUILT_PATCHES=debian/patches quilt pop -a -f || test $$? = 2
	[ ! -f $(libc-mapfile).orig ] || mv $(libc-mapfile).orig $(libc-mapfile)
	rm -f patch-stamp

fix-x-stamp: patch-stamp
	find illumos-gate/usr/src/head -name \*.x \
		-exec ./debian/fix.x.pl {} \;
	touch $@

dirs-stamp:
	. illumos-gate/env.sh; mkdir -p \
		debian/tmp$$DEB_CRYPT_MODULE_DIR_32 \
		debian/tmp$$DEB_CRYPT_MODULE_DIR_64 \
		debian/tmp$$DEB_LIBDIR_32 \
		debian/tmp$$DEB_LIBDIR_64 \
		debian/tmp$$DEB_USRLIBDIR_32 \
		debian/tmp$$DEB_USRLIBDIR_64 \
		debian/tmp/etc/default \
		debian/tmp/usr/bin \
		debian/tmp/usr/sbin

	# We are changing soname, but keep links for build time.
	# These links also will go into libsunXXX-dev packages.
	# Watch out: libc build-conflicts with other libelf-dev and libavl-dev
	# implementations, and libsunXXX-dev will do too.
	. illumos-gate/env.sh; \
	ln -sf $(CURDIR)/debian/tmp$$DEB_LIBDIR_32/libsunelf.so.1 \
		debian/tmp$$DEB_USRLIBDIR_32/libelf.so && \
	ln -sf $(CURDIR)/debian/tmp$$DEB_LIBDIR_64/libsunelf.so.1 \
		debian/tmp$$DEB_USRLIBDIR_64/libelf.so && \
	ln -sf $(CURDIR)/debian/tmp$$DEB_LIBDIR_32/libsunavl.so.1 \
		debian/tmp$$DEB_USRLIBDIR_32/libavl.so && \
	ln -sf $(CURDIR)/debian/tmp$$DEB_LIBDIR_64/libsunavl.so.1 \
		debian/tmp$$DEB_USRLIBDIR_64/libavl.so

	touch $@

headers-stamp: patch-stamp dirs-stamp fix-x-stamp
	dh_illumos_make $(make) usr/src/head -t install_h
	dh_illumos_make $(make) $(libs_headers:%=usr/src/lib/%) -t install_h
	touch $@

lib-stamp: headers-stamp
	dh_illumos_make $(make) $(libs:%=usr/src/lib/%)
	touch $@

nsswitch-stamp: lib-stamp
	dh_illumos_make $(make) $(nsswitch:%=usr/src/lib/nsswitch/%)
	touch $@

# Some libs and, more important, runtime linker are in usr/src/cmd/sgs.
# We will not build all sgs stuff, but only related to libc.
sgs-stamp: lib-stamp
	dh_illumos_make $(make) --native usr/src/cmd/sgs/tools
	dh_illumos_make $(make) $(sgs:%=usr/src/cmd/sgs/%)
	# We have patched it:
	dh_illumos_make $(make) --native usr/src/cmd/sgs/ldd/i386
	touch $@


cmd-stamp: lib-stamp sgs-stamp
	dh_illumos_make --native $(make) $(cmd:%=usr/src/cmd/%)
	touch $@

build-stamp: lib-stamp sgs-stamp nsswitch-stamp headers-stamp cmd-stamp debian/LC_DATA.gz debian/locales.config
	for l in `find debian/tmp/lib32 -maxdepth 1 -type l -name \*.so`; do \
		ln -sf `readlink -f $$l` debian/tmp/usr/lib32/`basename $$l`; \
	done
	for l in `find debian/tmp/lib/$(DEB_HOST_MULTIARCH) -maxdepth 1 -type l -name \*.so`; do \
		ln -sf `readlink -f $$l` debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/`basename $$l`; \
	done
	symlinks -c debian/tmp/usr/lib32
	symlinks -c debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)

	touch $@

install build build-arch build-indep: build-stamp
binary binary-arch binary-indep: binary-stamp

binary-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_install
	find debian/locales/usr/share/i18n/locales -name *.UTF-8.src | \
		xargs sed -i '/^LC_CTYPE/,/^END LC_CTYPE/d'
	dh_installman
	dh_installdocs
	dh_installexamples
	dh_installchangelogs
	dh_installdebconf
	dh_link
	dh_compress
	dh_makeshlibs
	dh_shlibdeps

	dh_fixperms
	chmod 0755 \
		debian/*/usr/lib/*/lddstub \
		debian/*/usr/lib?*/lddstub \
		debian/*/lib/*/ld.so.* \
		debian/*/lib?*/ld.so.* \

	chmod 4755 debian/*/usr/lib/utmp_update

	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb
	touch $@

# We remove LC_DATA from all *.UTF-8.src
# and when regenerating locales will insert contents of LC_DATA
# into source locale file. Illumos localedef does not support
# copy action for including other files source files.
debian/LC_DATA.gz:
	sh illumos-gate/usr/src/cmd/localedef/data/ctype.sh \
		illumos-gate/usr/src/cmd/localedef/data/*.UTF-8.src \
		| gzip -c -9 > $@

debian/locales.config: debian/locales.config.in
	perl -pe 'BEGIN {undef $$/; open(IN, "debian/SUPPORTED"); $$j=<IN>;} s/__PROVIDED_LOCALES__/$$j/g;' \
		$< > $@

clean: unpatch
	dh_testdir
	dh_testroot
	dh_clean
	rm -f debian/LC_DATA.*
	rm -f debian/locales.config
	rm -rf illumos-gate