xref: /linux/scripts/kconfig/nconf-cfg.sh (revision af0bc3ac9a9e830cb52b718ecb237c4e76a466be)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3
4set -eu
5
6cflags=$1
7libs=$2
8
9# Keep library order for static linking (HOSTCC='cc -static')
10PKG="menuw panelw ncursesw"
11PKG2="menu panel ncurses"
12
13if [ -n "$(command -v ${HOSTPKG_CONFIG})" ]; then
14	if ${HOSTPKG_CONFIG} --exists $PKG; then
15		${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags}
16		${HOSTPKG_CONFIG} --libs ${PKG} > ${libs}
17		exit 0
18	fi
19
20	if ${HOSTPKG_CONFIG} --exists $PKG2; then
21		${HOSTPKG_CONFIG} --cflags ${PKG2} > ${cflags}
22		${HOSTPKG_CONFIG} --libs ${PKG2} > ${libs}
23		exit 0
24	fi
25fi
26
27# Check the default paths in case pkg-config is not installed.
28# (Even if it is installed, some distributions such as openSUSE cannot
29# find ncurses by pkg-config.)
30if [ -f /usr/include/ncursesw/ncurses.h ]; then
31	echo -D_GNU_SOURCE -I/usr/include/ncursesw > ${cflags}
32	echo -lmenuw -lpanelw -lncursesw > ${libs}
33	exit 0
34fi
35
36if [ -f /usr/include/ncurses/ncurses.h ]; then
37	echo -D_GNU_SOURCE -I/usr/include/ncurses > ${cflags}
38	echo -lmenu -lpanel -lncurses > ${libs}
39	exit 0
40fi
41
42if [ -f /usr/include/ncurses.h ]; then
43	echo -D_GNU_SOURCE > ${cflags}
44	echo -lmenu -lpanel -lncurses > ${libs}
45	exit 0
46fi
47
48echo >&2 "*"
49echo >&2 "* Unable to find the ncurses package."
50echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"
51echo >&2 "* depending on your distribution)."
52echo >&2 "*"
53echo >&2 "* You may also need to install ${HOSTPKG_CONFIG} to find the"
54echo >&2 "* ncurses installed in a non-default location."
55echo >&2 "*"
56exit 1
57