check-lxdialog.sh 1.7 KB

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