check-lxdialog.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 -e " #include CURSES_LOC \n main() {}" |
  36. $cc -xc - -o $tmp 2> /dev/null
  37. if [ $? != 0 ]; then
  38. echo " *** Unable to find the ncurses libraries or the" 1>&2
  39. echo " *** required header files." 1>&2
  40. echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
  41. echo " *** " 1>&2
  42. echo " *** Install ncurses (ncurses-devel) and try again." 1>&2
  43. echo " *** " 1>&2
  44. exit 1
  45. fi
  46. }
  47. usage() {
  48. printf "Usage: $0 [-check compiler options|-header|-library]\n"
  49. }
  50. if [ $# -eq 0 ]; then
  51. usage
  52. exit 1
  53. fi
  54. cc=""
  55. case "$1" in
  56. "-check")
  57. shift
  58. cc="$@"
  59. check
  60. ;;
  61. "-ccflags")
  62. ccflags
  63. ;;
  64. "-ldflags")
  65. shift
  66. cc="$@"
  67. ldflags
  68. ;;
  69. "*")
  70. usage
  71. exit 1
  72. ;;
  73. esac