check-lxdialog.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. 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. # Temp file, try to clean up after us
  37. tmp=.lxdialog.tmp
  38. trap "rm -f $tmp" 0 1 2 3 15
  39. # Check if we can link to ncurses
  40. check() {
  41. echo "main() {}" | $cc -xc - -o $tmp 2> /dev/null
  42. if [ $? != 0 ]; then
  43. echo " *** Unable to find the ncurses libraries." 1>&2
  44. echo " *** make menuconfig require 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|-header|-library]\n"
  53. }
  54. if [ $# == 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