xref: /OK3568_Linux_fs/buildroot/package/ncurses/ncurses.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1################################################################################
2#
3# ncurses
4#
5################################################################################
6
7NCURSES_VERSION = 6.1
8NCURSES_SITE = $(BR2_GNU_MIRROR)/ncurses
9NCURSES_INSTALL_STAGING = YES
10NCURSES_DEPENDENCIES = host-ncurses
11NCURSES_LICENSE = MIT with advertising clause
12NCURSES_LICENSE_FILES = COPYING
13NCURSES_CPE_ID_VENDOR = gnu
14# Commit 4b21273d71d09 added upstream (security) patches up to 20200118
15NCURSES_IGNORE_CVES += CVE-2018-10754
16NCURSES_IGNORE_CVES += CVE-2018-19211
17NCURSES_IGNORE_CVES += CVE-2018-19217
18NCURSES_IGNORE_CVES += CVE-2019-17594
19NCURSES_IGNORE_CVES += CVE-2019-17595
20NCURSES_CONFIG_SCRIPTS = ncurses$(NCURSES_LIB_SUFFIX)6-config
21NCURSES_PATCH = \
22	$(addprefix https://invisible-mirror.net/archives/ncurses/$(NCURSES_VERSION)/, \
23		ncurses-6.1-20190609-patch.sh.bz2 \
24		ncurses-6.1-20190615.patch.gz \
25		ncurses-6.1-20190623.patch.gz \
26		ncurses-6.1-20190630.patch.gz \
27		ncurses-6.1-20190706.patch.gz \
28		ncurses-6.1-20190713.patch.gz \
29		ncurses-6.1-20190720.patch.gz \
30		ncurses-6.1-20190727.patch.gz \
31		ncurses-6.1-20190728.patch.gz \
32		ncurses-6.1-20190803.patch.gz \
33		ncurses-6.1-20190810.patch.gz \
34		ncurses-6.1-20190817.patch.gz \
35		ncurses-6.1-20190824.patch.gz \
36		ncurses-6.1-20190831.patch.gz \
37		ncurses-6.1-20190907.patch.gz \
38		ncurses-6.1-20190914.patch.gz \
39		ncurses-6.1-20190921.patch.gz \
40		ncurses-6.1-20190928.patch.gz \
41		ncurses-6.1-20191005.patch.gz \
42		ncurses-6.1-20191012.patch.gz \
43		ncurses-6.1-20191015.patch.gz \
44		ncurses-6.1-20191019.patch.gz \
45		ncurses-6.1-20191026.patch.gz \
46		ncurses-6.1-20191102.patch.gz \
47		ncurses-6.1-20191109.patch.gz \
48		ncurses-6.1-20191116.patch.gz \
49		ncurses-6.1-20191123.patch.gz \
50		ncurses-6.1-20191130.patch.gz \
51		ncurses-6.1-20191207.patch.gz \
52		ncurses-6.1-20191214.patch.gz \
53		ncurses-6.1-20191221.patch.gz \
54		ncurses-6.1-20191228.patch.gz \
55		ncurses-6.1-20200104.patch.gz \
56		ncurses-6.1-20200111.patch.gz \
57		ncurses-6.1-20200118.patch.gz \
58	)
59
60# ncurses-6.1-20191012.patch.gz
61NCURSES_IGNORE_CVES += CVE-2019-17594 CVE-2019-17595
62
63NCURSES_CONF_OPTS = \
64	--without-cxx \
65	--without-cxx-binding \
66	--without-ada \
67	--without-tests \
68	--disable-big-core \
69	--without-profile \
70	--disable-rpath \
71	--disable-rpath-hack \
72	--enable-echo \
73	--enable-const \
74	--enable-overwrite \
75	--enable-pc-files \
76	--disable-stripping \
77	--with-pkg-config-libdir="/usr/lib/pkgconfig" \
78	$(if $(BR2_PACKAGE_NCURSES_TARGET_PROGS),,--without-progs) \
79	--without-manpages
80
81ifneq ($(BR2_STATIC_LIBS)$(BR2_PACKAGE_NCURSES_STATIC),)
82NCURSES_CONF_OPTS += --without-shared --with-normal
83else ifeq ($(BR2_SHARED_LIBS),y)
84NCURSES_CONF_OPTS += --with-shared --without-normal
85else ifeq ($(BR2_SHARED_STATIC_LIBS),y)
86NCURSES_CONF_OPTS += --with-shared --with-normal
87endif
88
89# configure can't find the soname for libgpm when cross compiling
90ifeq ($(BR2_PACKAGE_GPM),y)
91NCURSES_CONF_OPTS += --with-gpm=libgpm.so.2
92NCURSES_DEPENDENCIES += gpm
93else
94NCURSES_CONF_OPTS += --without-gpm
95endif
96
97NCURSES_TERMINFO_FILES = \
98	a/ansi \
99	d/dumb \
100	l/linux \
101	p/putty \
102	p/putty-256color \
103	p/putty-vt100 \
104	s/screen \
105	s/screen-256color \
106	v/vt100 \
107	v/vt100-putty \
108	v/vt102 \
109	v/vt200 \
110	v/vt220 \
111	x/xterm \
112	x/xterm+256color \
113	x/xterm-256color \
114	x/xterm-color \
115	x/xterm-xfree86 \
116	$(call qstrip,$(BR2_PACKAGE_NCURSES_ADDITIONAL_TERMINFO))
117
118ifeq ($(BR2_PACKAGE_NCURSES_WCHAR),y)
119NCURSES_CONF_OPTS += --enable-widec
120NCURSES_LIB_SUFFIX = w
121NCURSES_LIBS = ncurses menu panel form
122
123define NCURSES_LINK_LIBS_STATIC
124	$(foreach lib,$(NCURSES_LIBS:%=lib%), \
125		ln -sf $(lib)$(NCURSES_LIB_SUFFIX).a $(STAGING_DIR)/usr/lib/$(lib).a
126	)
127	ln -sf libncurses$(NCURSES_LIB_SUFFIX).a \
128		$(STAGING_DIR)/usr/lib/libcurses.a
129endef
130
131define NCURSES_LINK_LIBS_SHARED
132	$(foreach lib,$(NCURSES_LIBS:%=lib%), \
133		ln -sf $(lib)$(NCURSES_LIB_SUFFIX).so $(STAGING_DIR)/usr/lib/$(lib).so
134	)
135	ln -sf libncurses$(NCURSES_LIB_SUFFIX).so \
136		$(STAGING_DIR)/usr/lib/libcurses.so
137endef
138
139define NCURSES_LINK_PC
140	$(foreach pc,$(NCURSES_LIBS), \
141		ln -sf $(pc)$(NCURSES_LIB_SUFFIX).pc \
142			$(STAGING_DIR)/usr/lib/pkgconfig/$(pc).pc
143	)
144endef
145
146NCURSES_LINK_STAGING_LIBS = \
147	$(if $(BR2_STATIC_LIBS)$(BR2_SHARED_STATIC_LIBS)$(BR2_PACKAGE_NCURSES_STATIC),$(call NCURSES_LINK_LIBS_STATIC);) \
148	$(if $(BR2_SHARED_LIBS)$(BR2_SHARED_STATIC_LIBS),$(call NCURSES_LINK_LIBS_SHARED))
149
150NCURSES_LINK_STAGING_PC = $(call NCURSES_LINK_PC)
151
152NCURSES_CONF_OPTS += --enable-ext-colors
153
154NCURSES_POST_INSTALL_STAGING_HOOKS += NCURSES_LINK_STAGING_LIBS
155NCURSES_POST_INSTALL_STAGING_HOOKS += NCURSES_LINK_STAGING_PC
156
157endif # BR2_PACKAGE_NCURSES_WCHAR
158
159ifneq ($(BR2_ENABLE_DEBUG),y)
160NCURSES_CONF_OPTS += --without-debug
161endif
162
163# ncurses breaks with parallel build, but takes quite a while to
164# build single threaded. Work around it similar to how Gentoo does
165define NCURSES_BUILD_CMDS
166	$(TARGET_MAKE_ENV) $(MAKE1) -C $(@D) DESTDIR=$(STAGING_DIR) sources
167	rm -rf $(@D)/misc/pc-files
168	$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(STAGING_DIR)
169endef
170
171ifeq ($(BR2_PACKAGE_NCURSES_TARGET_PROGS),y)
172define NCURSES_TARGET_SYMLINK_RESET
173	ln -sf tset $(TARGET_DIR)/usr/bin/reset
174endef
175NCURSES_POST_INSTALL_TARGET_HOOKS += NCURSES_TARGET_SYMLINK_RESET
176endif
177
178define NCURSES_TARGET_CLEANUP_TERMINFO
179	$(RM) -rf $(TARGET_DIR)/usr/share/terminfo $(TARGET_DIR)/usr/share/tabset
180	$(foreach t,$(NCURSES_TERMINFO_FILES), \
181		$(INSTALL) -D -m 0644 $(STAGING_DIR)/usr/share/terminfo/$(t) \
182			$(TARGET_DIR)/usr/share/terminfo/$(t)
183	)
184endef
185NCURSES_POST_INSTALL_TARGET_HOOKS += NCURSES_TARGET_CLEANUP_TERMINFO
186
187#
188# On systems with an older version of tic, the installation of ncurses hangs
189# forever. To resolve the problem, build a static version of tic on host
190# ourselves, and use that during installation.
191#
192define HOST_NCURSES_BUILD_CMDS
193	$(HOST_MAKE_ENV) $(MAKE1) -C $(@D) sources
194	$(HOST_MAKE_ENV) $(MAKE) -C $(@D)/progs tic
195endef
196
197HOST_NCURSES_CONF_ENV = \
198	ac_cv_path_LDCONFIG=""
199
200HOST_NCURSES_CONF_OPTS = \
201	--with-shared \
202	--without-gpm \
203	--without-manpages \
204	--without-cxx \
205	--without-cxx-binding \
206	--without-ada \
207	--with-default-terminfo-dir=/usr/share/terminfo \
208	--disable-db-install \
209	--without-normal
210
211$(eval $(autotools-package))
212$(eval $(host-autotools-package))
213