check-lxdialog.sh 1.5 KB

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