check-lxdialog.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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/ncursesw/ncurses.h ]; then
  21. echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncurses.h>"'
  22. elif [ -f /usr/include/ncursesw/curses.h ]; then
  23. echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
  24. elif [ -f /usr/include/ncurses/ncurses.h ]; then
  25. echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
  26. elif [ -f /usr/include/ncurses/curses.h ]; then
  27. echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
  28. elif [ -f /usr/include/ncurses.h ]; then
  29. echo '-DCURSES_LOC="<ncurses.h>"'
  30. else
  31. echo '-DCURSES_LOC="<curses.h>"'
  32. fi
  33. }
  34. # Temp file, try to clean up after us
  35. tmp=.lxdialog.tmp
  36. trap "rm -f $tmp" 0 1 2 3 15
  37. # Check if we can link to ncurses
  38. check() {
  39. $cc -xc - -o $tmp 2>/dev/null <<'EOF'
  40. #include CURSES_LOC
  41. main() {}
  42. EOF
  43. if [ $? != 0 ]; then
  44. echo " *** Unable to find the ncurses libraries or the" 1>&2
  45. echo " *** required header files." 1>&2
  46. echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
  47. echo " *** " 1>&2
  48. echo " *** Install ncurses (ncurses-devel) and try again." 1>&2
  49. echo " *** " 1>&2
  50. exit 1
  51. fi
  52. }
  53. usage() {
  54. printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
  55. }
  56. if [ $# -eq 0 ]; then
  57. usage
  58. exit 1
  59. fi
  60. cc=""
  61. case "$1" in
  62. "-check")
  63. shift
  64. cc="$@"
  65. check
  66. ;;
  67. "-ccflags")
  68. ccflags
  69. ;;
  70. "-ldflags")
  71. shift
  72. cc="$@"
  73. ldflags
  74. ;;
  75. "*")
  76. usage
  77. exit 1
  78. ;;
  79. esac