check-lxdialog.sh 1.8 KB

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