mconf-cfg.sh 1.5 KB

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