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

include ../source.mk

builddir = obj_$$(printf '%s' $@ | sed 's/^[^_]*_//')
abi_ver = $$(printf '%s\n' '$(OPK_SOURCE_VERSION_UPSTREAM)' | sed 's/[.].*//')
legacy_abi_ver = $$(($(abi_ver) - 1))
CFLAGS = -Os -g
common_opts = \
	--without-ada \
	--without-tests \
	--with-pkg-config-libdir='/usr/lib/$(OPK_HOST_ARCH)/pkgconfig' \
	--enable-pc-files \
	--with-install-prefix="$${PWD}/dest" \
	--with-shared \
	--with-cxx-shared \
	--without-debug \
	--without-profile \
	--with-termlib=tinfo \
	--with-ticlib=tic \
	--disable-termcap \
	--enable-symlinks \
	--enable-const
build_ncurses_opts = $(common_opts) \
	--with-install-prefix="$${PWD}/dest-ncurses" \
	--enable-overwrite
build_ncursesw_opts = $(common_opts) \
	--with-install-prefix="$${PWD}/dest-ncursesw" \
	--includedir=/usr/include/ncursesw \
	--without-progs \
	--disable-overwrite \
	--enable-widec
build_ncurses_legacy_opts = $(build_ncurses_opts) \
	--with-install-prefix="$${PWD}/dest-ncurses-legacy" \
	--with-abi-version=$(legacy_abi_ver)
build_ncursesw_legacy_opts = $(build_ncursesw_opts) \
	--with-install-prefix="$${PWD}/dest-ncursesw-legacy" \
	--with-abi-version=$(legacy_abi_ver)

nop:
	@:

build_ncurses build_ncursesw build_ncurses_legacy build_ncursesw_legacy:
	CFLAGS='$(CFLAGS)' oh-autoconfigure -B $(builddir) -- $($@_opts)
	oh-autobuild -B $(builddir)
	touch $@

build: build_ncurses build_ncursesw build_ncurses_legacy build_ncursesw_legacy

install: build
	(cd obj_ncurses_legacy && make install.libs)
	(cd obj_ncursesw_legacy && make install.libs)
	(cd obj_ncurses && make install)
	(cd obj_ncursesw && make install.libs)
	rm dest*/usr/lib/$(OPK_HOST_ARCH)/*.a
	mv dest-ncurses/usr/bin/clear dest-ncurses/usr/bin/clear.ncurses
	mv dest-ncurses/usr/bin/reset dest-ncurses/usr/bin/reset.ncurses
	@# Rename wide-char libtinfo to libtinfow.
	set -e; pc=usr/lib/$(OPK_HOST_ARCH)/pkgconfig/ncursesw.pc; \
	for d in dest-ncursesw dest-ncursesw-legacy; do \
		(cd $${d}/usr/lib/$(OPK_HOST_ARCH); \
		for f in libtinfo*; do \
			mv "$${f}" "libtinfow$${f#libtinfo}"; \
		done); \
		mv $${d}/$${pc} $${d}/$${pc}.orig; \
		sed 's/-ltinfo/-ltinfow/' $${d}/$${pc}.orig 1>$${d}/$${pc}; \
	done
	rm dest*/usr/bin/ncurses*-config
	rm dest-ncurses/usr/share/man/man1/ncurses*-config.1
	@# Extract a few individual terminal type definitions.  This would be
	@# hard to do with oh-installfiles.
	@# terminfo-linux
	mkdir -p terminfo-linux.data/usr/lib/
	ln -sf ../share/terminfo terminfo-linux.data/usr/lib/terminfo
	mkdir -p terminfo-linux.data/usr/share/terminfo/l/
	mv dest-ncurses/usr/share/terminfo/l/linux \
		terminfo-linux.data/usr/share/terminfo/l/linux
	oh-fixperms
	oh-strip -k
	OPK_PACKAGES="\
		$$(printf '%s\n' $${OPK_PACKAGES} | \
			grep -Ev "lib.*w[.]$(abi_ver)(-dev)?") | \
			grep -Ev "lib.*[.]$(legacy_abi_ver)(-dev)?") \
		" oh-installfiles -d dest-ncurses
	OPK_PACKAGES="\
		$$(printf '%s\n' $${OPK_PACKAGES} | \
			grep -E "lib.*w[.]$(abi_ver)(-dev)?") \
		" oh-installfiles -d dest-ncursesw
	OPK_PACKAGES="\
		$$(printf '%s\n' $${OPK_PACKAGES} | \
			grep -E "lib.*[.]$(legacy_abi_ver)(-dev)?") \
		" oh-installfiles -d dest-ncurses-legacy
	OPK_PACKAGES="\
		$$(printf '%s\n' $${OPK_PACKAGES} | \
			grep -E "lib.*w[.]$(legacy_abi_ver)(-dev)?") \
		" oh-installfiles -d dest-ncursesw-legacy
	oh-shlibdeps
	# Remove self-dependencies.
	set -e; for f in *.substvars; do p="$${f%.substvars}"; \
		mv "$${f}" "$${f}.orig"; \
		sed "s/ $${p},//" "$${f}.orig" >"$${f}"; \
	done