summaryrefslogtreecommitdiffstats
path: root/build
blob: 67eb4cb08a817fbc85dbdb7a835877adb8032fb7 (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
#! /usr/bin/make -f

prefix = /usr
datarootdir = $(prefix)/share
datadir = $(prefix)/share
localedir = $(prefix)/lib/locale
docdir = $(prefix)/share/doc

SUPPORTED_LOCALES = \
	de_DE.UTF-8/UTF-8 de_DE/ISO-8859-1 de_DE@euro/ISO-8859-15 \
	en_HK.UTF-8/UTF-8 en_HK/ISO-8859-1 \
	en_PH.UTF-8/UTF-8 en_PH/ISO-8859-1 \
	en_US.UTF-8/UTF-8 en_US/ISO-8859-1 \
	es_MX.UTF-8/UTF-8 es_MX/ISO-8859-1 \
	fa_IR/UTF-8 \
	fr_FR.UTF-8/UTF-8 fr_FR/ISO-8859-1 fr_FR@euro/ISO-8859-15 \
	it_IT.UTF-8/UTF-8 it_IT/ISO-8859-1 \
	ja_JP.EUC-JP/EUC-JP ja_JP.UTF-8/UTF-8

nop:
	@:

configure-libc:
	[ ! -d libcbuild ] && mkdir libcbuild || true
	rm -f libcbuild/config.cache
	if [ 'x$(OPK_HOST_PLAT)' = 'xbootstrap1' ]; then \
		printf '%s\n' \
			'libc_cv_forced_unwind=yes' \
			'libc_cv_c_cleanup=yes' \
			'libc_cv_gnu89_inline=yes' \
			'libc_cv_ssp=no' \
			>>libcbuild/config.cache; \
	fi
	printf '%s\n' \
		'libc_cv_slibdir=/lib/$(OPK_HOST_ARCH)' \
		>>libcbuild/config.cache; \
	if [ 'x$(TOOLS_PREFIX)' != 'x' ]; then \
		BINUTILS="--with-binutils=$(TOOLS_PREFIX)/bin"; \
	else \
		BINUTILS=; \
	fi && \
	if [ 'x$(HEADERS_PREFIX)' != 'x' ]; then \
		HEADERS="--with-headers=$(HEADERS_PREFIX)/usr/include"; \
	else \
		HEADERS=; \
	fi && \
	BUILD_CC=gcc BUILD_CXX=g++ MAKEINFO=: oh-autoconfigure \
		-s "$${PWD}/src/libc" -B libcbuild -- \
		--datarootdir=$(datarootdir) --datadir=$(datadir) \
		--localedir=$(localedir) --docdir=$(docdir) \
		--disable-profile \
		--enable-add-ons=ports,nptl,libidn \
		--enable-kernel=3.2.0 \
		--with-tls --with-__thread --without-cvs \
		--without-selinux --without-gd \
		$(BINUTILS) \
		$(HEADERS) \
		--cache-file=config.cache
	touch $@

configure-locales:
	[ ! -d localesbuild ] && mkdir localesbuild || true
	CPPFLAGS=-DNOT_IN_libc oh-autoconfigure \
		-s "$${PWD}/src/localedef" -B localesbuild -- \
		--libdir='$${prefix}/lib' \
		--with-glibc=../src/libc
	touch $@

configure: configure-libc configure-locales
	touch $@

build-libc: configure-libc
	oh-autobuild -s "$${PWD}/src/libc" -B libcbuild -- -j $${JOBS:-1}
	touch $@

build-locales: configure-locales
	oh-autobuild -s "$${PWD}/src/localedef" -B localesbuild -- \
		-j $${JOBS:-1}
	touch $@

build: build-libc build-locales
	touch $@

install-libc: build-libc
	# Install /etc/ld.so.conf early to silence a warning from ldconfig.
	mkdir -p dest/etc/ld.so.conf.d
	printf 'include /etc/ld.so.conf.d/*.conf\n' \
		>'dest/etc/ld.so.conf'
	printf '/usr/local/lib\n/opt/lib\n' \
		>'dest/etc/ld.so.conf.d/local'
	printf '/lib/$(OPK_HOST_ARCH)\n/usr/lib/$(OPK_HOST_ARCH)\n' \
		>'dest/etc/ld.so.conf.d/$(OPK_HOST_ARCH)'
	oh-autoinstall -s "$${PWD}/src/libc" -B libcbuild
	rm -f dest/etc/ld.so.cache
	# Make a /usr/lib/<host>/ld.so link for GCC.
	# No ELF binary should reference this link in its INTERP field.  This is
	# strictly a development file that points to the system's dynamic
	# linker.
	ln -sf $$(printf '%s' dest/lib/$(OPK_HOST_ARCH)/ld*so.* | \
		sed 's/dest//') /usr/lib/$(OPK_HOST_ARCH)/ld.so
	rm -f dest/var/db/Makefile \
		dest/sbin/sln \
		dest/usr/bin/makedb \
		dest/usr/bin/pcprofiledump \
		dest/usr/bin/xtrace
	# TODO: PIC package?
	rm -Rf dest/usr/lib/*/*_pic.*
	rm -Rf dest/usr/lib/*/libc_pic/
	# pt_chown isn't necessary with Linux's devptsfs.
	[ "x${OPK_HOST_ARCH_KERNEL}" = 'xlinux' ] && \
		rm -f dest/usr/lib/*/pt_chown
	cp ../nsswitch.conf dest/etc
	cp src/libc/posix/gai.conf dest/etc
	cp src/libc/nscd/nscd.conf dest/etc

install-locales: build-locales
	oh-autoinstall -s "$${PWD}/src/localedef" -B localesbuild \
		-T install-locales \
		SUPPORTED-LOCALES='$(SUPPORTED_LOCALES)'

install: install-libc install-locales
	oh-fixperms
	oh-strip -k
	# oh-fixperms changes the mode of the ELF interpreter, which is one
	# shared object that must be executable.
	chmod a+x 'dest/lib/$(OPK_HOST_ARCH)/ld-'*.so
	oh-installfiles

clean-libc:
	oh-autoclean -s "$${PWD}/src/libc" -B libcbuild
	rm -f configure-libc build-libc

clean-locales:
	oh-autoclean -s "$${PWD}/src/localedef" -B localesbuild
	rm -f configure-locales build-locales

clean: clean-libc clean-locales
	rm -f configure build
	rm -Rf *.data

# POSIX.1-2008:
#   If the pathname does not begin with a '/' it shall be treated as relative to
#   the current working directory of the process, not relative to the directory
#   containing the makefile.
include ../source.mk