configure 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #! /bin/sh
  2. # waf configure wrapper
  3. # Fancy colors used to beautify the output a bit.
  4. #
  5. if [ "$NOCOLOR" ] ; then
  6. NORMAL=""
  7. BOLD=""
  8. RED=""
  9. YELLOW=""
  10. GREEN=""
  11. else
  12. NORMAL='\033[0m'
  13. BOLD='\033[01;1m'
  14. RED='\033[01;91m'
  15. YELLOW='\033[00;33m'
  16. GREEN='\033[01;92m'
  17. fi
  18. EXIT_SUCCESS=0
  19. EXIT_FAILURE=1
  20. EXIT_ERROR=2
  21. EXIT_BUG=10
  22. CUR_DIR=$PWD
  23. #possible relative path
  24. WORKINGDIR=`dirname $0`
  25. cd $WORKINGDIR
  26. #abs path
  27. WORKINGDIR=`pwd`
  28. cd $CUR_DIR
  29. # Checks for WAF. Honours $WAF if set. Stores path to 'waf' in $WAF.
  30. # Requires that $PYTHON is set.
  31. #
  32. checkWAF()
  33. {
  34. printf "Checking for WAF\t\t\t: "
  35. #installed miniwaf in sourcedir
  36. if [ -z "$WAF" ] ; then
  37. if [ -f "${WORKINGDIR}/waf" ] ; then
  38. WAF="${WORKINGDIR}/waf"
  39. if [ ! -x "$WAF" ] ; then
  40. chmod +x $WAF
  41. fi
  42. fi
  43. fi
  44. if [ -z "$WAF" ] ; then
  45. if [ -f "${WORKINGDIR}/waf-light" ] ; then
  46. ${WORKINGDIR}/waf-light --make-waf
  47. WAF="${WORKINGDIR}/waf"
  48. fi
  49. fi
  50. #global installed waf with waf->waf.py link
  51. if [ -z "$WAF" ] ; then
  52. WAF=`which waf 2>/dev/null`
  53. fi
  54. # neither waf nor miniwaf could be found
  55. if [ ! -x "$WAF" ] ; then
  56. printf "$RED""not found""$NORMAL""\n"
  57. echo "Go to https://waf.io/"
  58. echo "and download a waf version"
  59. exit $EXIT_FAILURE
  60. else
  61. printf "$GREEN""$WAF""$NORMAL""\n"
  62. fi
  63. }
  64. # Generates a Makefile. Requires that $WAF is set.
  65. #
  66. generateMakefile()
  67. {
  68. cat > Makefile << EOF
  69. #!/usr/bin/make -f
  70. # Waf Makefile wrapper
  71. WAF_HOME=$CUR_DIR
  72. all:
  73. #@$WAF build
  74. all-debug:
  75. @$WAF -v build
  76. all-progress:
  77. @$WAF -p build
  78. install:
  79. $WAF install --yes;
  80. uninstall:
  81. $WAF uninstall
  82. clean:
  83. @$WAF clean
  84. distclean:
  85. @$WAF distclean
  86. @-rm -rf build
  87. @-rm -f Makefile
  88. check:
  89. @$WAF check
  90. dist:
  91. @$WAF dist
  92. .PHONY: clean dist distclean check uninstall install all
  93. EOF
  94. }
  95. checkWAF
  96. generateMakefile
  97. "${WAF}" configure $*
  98. exit $?