check-lxdialog.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/sh
  2. # Check ncurses compatibility
  3. # What library to link
  4. ldflags()
  5. {
  6. pkg-config --libs ncursesw 2>/dev/null && exit
  7. pkg-config --libs ncurses 2>/dev/null && exit
  8. for ext in so a dll.a dylib ; do
  9. for lib in ncursesw ncurses curses ; do
  10. $cc -print-file-name=lib${lib}.${ext} | grep -q /
  11. if [ $? -eq 0 ]; then
  12. echo "-l${lib}"
  13. exit
  14. fi
  15. done
  16. done
  17. exit 1
  18. }
  19. # Where is ncurses.h?
  20. ccflags()
  21. {
  22. if [ -f /usr/include/ncursesw/curses.h ]; then
  23. echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"'
  24. echo ' -DNCURSES_WIDECHAR=1'
  25. elif [ -f /usr/include/ncurses/ncurses.h ]; then
  26. echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
  27. elif [ -f /usr/include/ncurses/curses.h ]; then
  28. echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
  29. elif [ -f /usr/include/ncurses.h ]; then
  30. echo '-DCURSES_LOC="<ncurses.h>"'
  31. else
  32. echo '-DCURSES_LOC="<curses.h>"'
  33. fi
  34. }
  35. # Temp file, try to clean up after us
  36. tmp=.lxdialog.tmp
  37. trap "rm -f $tmp" 0 1 2 3 15
  38. # Check if we can link to ncurses
  39. check() {
  40. $cc -x c - -o $tmp 2>/dev/null <<'EOF'
  41. #include CURSES_LOC
  42. int main() {}
  43. EOF
  44. if [ $? != 0 ]; then
  45. echo " *** Unable to find the ncurses libraries or the" 1>&2
  46. echo " *** required header files." 1>&2
  47. echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
  48. echo " *** " 1>&2
  49. echo " *** Install ncurses (ncurses-devel) and try again." 1>&2
  50. echo " *** " 1>&2
  51. exit 1
  52. fi
  53. }
  54. usage() {
  55. printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
  56. }
  57. if [ $# -eq 0 ]; then
  58. usage
  59. exit 1
  60. fi
  61. cc=""
  62. case "$1" in
  63. "-check")
  64. shift
  65. cc="$@"
  66. check
  67. ;;
  68. "-ccflags")
  69. ccflags
  70. ;;
  71. "-ldflags")
  72. shift
  73. cc="$@"
  74. ldflags
  75. ;;
  76. "*")
  77. usage
  78. exit 1
  79. ;;
  80. esac