check-lxdialog.sh 1.6 KB

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