mconf-cfg.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0-only
  3. PKG="ncursesw"
  4. PKG2="ncurses"
  5. if [ -n "$(command -v pkg-config)" ]; then
  6. if pkg-config --exists $PKG; then
  7. echo cflags=\"$(pkg-config --cflags $PKG)\"
  8. echo libs=\"$(pkg-config --libs $PKG)\"
  9. exit 0
  10. fi
  11. if pkg-config --exists $PKG2; then
  12. echo cflags=\"$(pkg-config --cflags $PKG2)\"
  13. echo libs=\"$(pkg-config --libs $PKG2)\"
  14. exit 0
  15. fi
  16. fi
  17. # Check the default paths in case pkg-config is not installed.
  18. # (Even if it is installed, some distributions such as openSUSE cannot
  19. # find ncurses by pkg-config.)
  20. if [ -f /usr/include/ncursesw/ncurses.h ]; then
  21. echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\"
  22. echo libs=\"-lncursesw\"
  23. exit 0
  24. fi
  25. if [ -f /usr/include/ncurses/ncurses.h ]; then
  26. echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncurses\"
  27. echo libs=\"-lncurses\"
  28. exit 0
  29. fi
  30. # As a final fallback before giving up, check if $HOSTCC knows of a default
  31. # ncurses installation (e.g. from a vendor-specific sysroot).
  32. if echo '#include <ncurses.h>' | ${HOSTCC} -E - >/dev/null 2>&1; then
  33. echo cflags=\"-D_GNU_SOURCE\"
  34. echo libs=\"-lncurses\"
  35. exit 0
  36. fi
  37. echo >&2 "*"
  38. echo >&2 "* Unable to find the ncurses package."
  39. echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev"
  40. echo >&2 "* depending on your distribution)."
  41. echo >&2 "*"
  42. echo >&2 "* You may also need to install pkg-config to find the"
  43. echo >&2 "* ncurses installed in a non-default location."
  44. echo >&2 "*"
  45. exit 1