2
0

check-lxdialog.sh 2.0 KB

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