check-lxdialog.sh 1.6 KB

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