check-lxdialog.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/sh
  2. # Check ncurses compatibility
  3. # What library to link
  4. ldflags()
  5. {
  6. echo "main() {}" | $cc -lncursesw -xc - -o /dev/null 2> /dev/null
  7. if [ $? -eq 0 ]; then
  8. echo '-lncursesw'
  9. exit
  10. fi
  11. echo "main() {}" | $cc -lncurses -xc - -o /dev/null 2> /dev/null
  12. if [ $? -eq 0 ]; then
  13. echo '-lncurses'
  14. exit
  15. fi
  16. echo "main() {}" | $cc -lcurses -xc - -o /dev/null 2> /dev/null
  17. if [ $? -eq 0 ]; then
  18. echo '-lcurses'
  19. exit
  20. fi
  21. exit 1
  22. }
  23. # Where is ncurses.h?
  24. ccflags()
  25. {
  26. if [ -f /usr/include/ncurses/ncurses.h ]; then
  27. echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
  28. elif [ -f /usr/include/ncurses/curses.h ]; then
  29. echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
  30. elif [ -f /usr/include/ncurses.h ]; then
  31. echo '-DCURSES_LOC="<ncurses.h>"'
  32. else
  33. echo '-DCURSES_LOC="<curses.h>"'
  34. fi
  35. }
  36. compiler=""
  37. # Check if we can link to ncurses
  38. check() {
  39. echo "main() {}" | $cc -xc - -o /dev/null 2> /dev/null
  40. if [ $? != 0 ]; then
  41. echo " *** Unable to find the ncurses libraries." 1>&2
  42. echo " *** make menuconfig require 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 [ $# == 0 ]; then
  53. usage
  54. exit 1
  55. fi
  56. case "$1" in
  57. "-check")
  58. shift
  59. cc="$@"
  60. check
  61. ;;
  62. "-ccflags")
  63. ccflags
  64. ;;
  65. "-ldflags")
  66. shift
  67. cc="$@"
  68. ldflags
  69. ;;
  70. "*")
  71. usage
  72. exit 1
  73. ;;
  74. esac