nconf-cfg.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0
  3. set -eu
  4. cflags=$1
  5. libs=$2
  6. # Keep library order for static linking (HOSTCC='cc -static')
  7. PKG="menuw panelw ncursesw"
  8. PKG2="menu panel ncurses"
  9. if [ -n "$(command -v ${HOSTPKG_CONFIG})" ]; then
  10. if ${HOSTPKG_CONFIG} --exists $PKG; then
  11. ${HOSTPKG_CONFIG} --cflags ${PKG} > ${cflags}
  12. ${HOSTPKG_CONFIG} --libs ${PKG} > ${libs}
  13. exit 0
  14. fi
  15. if ${HOSTPKG_CONFIG} --exists $PKG2; then
  16. ${HOSTPKG_CONFIG} --cflags ${PKG2} > ${cflags}
  17. ${HOSTPKG_CONFIG} --libs ${PKG2} > ${libs}
  18. exit 0
  19. fi
  20. fi
  21. # Check the default paths in case pkg-config is not installed.
  22. # (Even if it is installed, some distributions such as openSUSE cannot
  23. # find ncurses by pkg-config.)
  24. if [ -f /usr/include/ncursesw/ncurses.h ]; then
  25. echo -D_GNU_SOURCE -I/usr/include/ncursesw > ${cflags}
  26. echo -lmenuw -lpanelw -lncursesw > ${libs}
  27. exit 0
  28. fi
  29. if [ -f /usr/include/ncurses/ncurses.h ]; then
  30. echo -D_GNU_SOURCE -I/usr/include/ncurses > ${cflags}
  31. echo -lmenu -lpanel -lncurses > ${libs}
  32. exit 0
  33. fi
  34. if [ -f /usr/include/ncurses.h ]; then
  35. echo -D_GNU_SOURCE > ${cflags}
  36. echo -lmenu -lpanel -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