kconfig/lxdialog: get ncurses CFLAGS with pkg-config
PATCH 1/1 kconfig/lxdialog: get ncurses CFLAGS with pkg-config
check-lxdialog.sh has functions for finding ncurses linker and compiler flags; ldflags() and ccflags().
ldflags() tries to get linker flags from pkg-config and has a fallback if pkg-config fails. But ccflags() currently doesn't use pkg-config at all, instead it does manual checks like this:
if [ -f /usr/include/ncursesw/curses.h ]; then
echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"' echo ' -DNCURSES_WIDECHAR=1'
elif [ -f /usr/include/ncurses/ncurses.h ]; then
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
[...]
This patch changes ccflags() so that it also tries pkg-config first, and only if pkg-config fails does it go back to the fallback/manual checks.
This makes ldflags()/ccflags() symmetric (both try to use pkg-config before falling back to manual checks) and has the nice side-effect of making "make menuconfig" work on systems where ncurses is not installed in a standard location (such as on NixOS).
--- scripts/kconfig/lxdialog/check-lxdialog.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
scripts/kconfig/lxdialog/check-lxdialog.sh +5 -1
@@ -21,7 +21,11 @@ ldflags() # Where is ncurses.h? ccflags() { - if [ -f /usr/include/ncursesw/curses.h ]; then + if pkg-config --cflags ncursesw 2>/dev/null; then + echo '-DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1' + elif pkg-config --cflags ncurses 2>/dev/null; then + echo '-DCURSES_LOC="<ncurses.h>"' + elif [ -f /usr/include/ncursesw/curses.h ]; then echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"' echo ' -DNCURSES_WIDECHAR=1' elif [ -f /usr/include/ncurses/ncurses.h ]; then
Signature · 1 line
1.8.5.2
Quoted 45 lines · Bjørn Forsman
check-lxdialog.shhas functions for finding ncurses linker and compiler flags;ldflags()andccflags().
ldflags()tries to get linker flags from pkg-config and has a fallback if pkg-config fails. Butccflags()currently doesn't use pkg-config at all, instead it does manual checks like this:if [ -f
/usr/include/ncursesw/curses.h]; then
echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"' echo ' -DNCURSES_WIDECHAR=1'
elif [ -f/usr/include/ncurses/ncurses.h]; then
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
[...]This patch changes
ccflags()so that it also tries pkg-config first, and only if pkg-config fails does it go back to the fallback/manual checks.This makes ldflags()/ccflags() symmetric (both try to use pkg-config before falling back to manual checks) and has the nice side-effect of making "make menuconfig" work on systems where ncurses is not installed in a standard location (such as on NixOS).
Signed-off-by Bjørn Forsman <[email protected]>--- scripts/kconfig/lxdialog/check-lxdialog.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)scripts/kconfig/lxdialog/check-lxdialog.sh +5
-2@@ -21,7 +21,11 @@ ldflags() # Where is ncurses.h? ccflags() { - if [ -f /usr/include/ncursesw/curses.h ]; then + if pkg-config --cflags ncursesw 2>/dev/null; then + echo '-DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1' + elif pkg-config --cflags ncurses 2>/dev/null; then + echo '-DCURSES_LOC="<ncurses.h>"' + elif [ -f /usr/include/ncursesw/curses.h ]; then echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"' echo ' -DNCURSES_WIDECHAR=1' elif [ -f /usr/include/ncurses/ncurses.h ]; then --
Quoted 1 line
1.8.5.2
Ping. No comments?
Best regards,
Bjørn Forsman