nconf-cfg.sh 1.4 KB

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