163 lines
4.3 KiB

  1. #! /bin/sh
  2. # bootstrap: generic bootstrap/autogen.sh script for autotools projects
  3. #
  4. # Copyright (c) 2002-2010 Sam Hocevar <sam@hocevar.net>
  5. #
  6. # This program is free software. It comes without any warranty, to
  7. # the extent permitted by applicable law. You can redistribute it
  8. # and/or modify it under the terms of the Do What The Fuck You Want
  9. # To Public License, Version 2, as published by Sam Hocevar. See
  10. # http://www.wtfpl.net/ for more details.
  11. #
  12. # The latest version of this script can be found at the following place:
  13. # http://caca.zoy.org/wiki/build
  14. # Die if an error occurs
  15. set -e
  16. # LolEngine specific:
  17. sed -ne '/AC_CONFIG_FILES/,$p' configure.ac \
  18. | sed -ne 's@[^a-z]*\(.*/.*\)[^a-z]*@\1@p' | while read p; do
  19. case "$p" in
  20. *Makefile)
  21. required="${p}.am"
  22. ;;
  23. *)
  24. required="${p}.in"
  25. ;;
  26. esac
  27. if [ ! -f "${required}" ]; then
  28. echo "bootstrap: ${required} does not exist -- creating stub"
  29. case "$p" in
  30. */*)
  31. mkdir -p "${p%/*}"
  32. ;;
  33. esac
  34. echo '# Stub created by bootstrap' > "${required}"
  35. echo 'include $(top_srcdir)/build/autotools/common.am' >> "${required}"
  36. fi
  37. done
  38. # Guess whether we are using configure.ac or configure.in
  39. if test -f configure.ac; then
  40. conffile="configure.ac"
  41. elif test -f configure.in; then
  42. conffile="configure.in"
  43. else
  44. echo "$0: could not find configure.ac or configure.in"
  45. exit 1
  46. fi
  47. # Check for needed features
  48. auxdir="`sed -ne 's/^[ \t]*A._CONFIG_AUX_DIR *([[ ]*\([^] )]*\).*/\1/p' $conffile`"
  49. pkgconfig="`grep '^[ \t]*PKG_PROG_PKG_CONFIG' $conffile >/dev/null 2>&1 && echo yes || echo no`"
  50. libtool="`grep '^[ \t]*A._PROG_LIBTOOL' $conffile >/dev/null 2>&1 && echo yes || echo no`"
  51. header="`grep '^[ \t]*A._CONFIG_HEADER' $conffile >/dev/null 2>&1 && echo yes || echo no`"
  52. makefile="`[ -f Makefile.am ] && echo yes || echo no`"
  53. aclocalflags="`sed -ne 's/^[ \t]*ACLOCAL_AMFLAGS[ \t]*=//p' Makefile.am 2>/dev/null || :`"
  54. # Check for automake
  55. amvers="no"
  56. for v in "" "-1.15" "-1.14" "-1.13" "-1.12" "-1.11"; do
  57. if automake${v} --version > /dev/null 2>&1; then
  58. amvers=${v}
  59. break
  60. fi
  61. done
  62. if test "$amvers" = "no"; then
  63. echo "$0: automake not found"
  64. exit 1
  65. fi
  66. # Check for autoconf
  67. acvers="no"
  68. for v in "" "259" "253"; do
  69. if autoconf${v} --version >/dev/null 2>&1; then
  70. acvers="${v}"
  71. break
  72. fi
  73. done
  74. if test "$acvers" = "no"; then
  75. echo "$0: autoconf not found"
  76. exit 1
  77. fi
  78. # Check for libtool
  79. if test "$libtool" = "yes"; then
  80. libtoolize="no"
  81. if glibtoolize --version >/dev/null 2>&1; then
  82. libtoolize="glibtoolize"
  83. else
  84. for v in "16" "15" "" "14"; do
  85. if libtoolize${v} --version >/dev/null 2>&1; then
  86. libtoolize="libtoolize${v}"
  87. break
  88. fi
  89. done
  90. fi
  91. if test "$libtoolize" = "no"; then
  92. echo "$0: libtool not found"
  93. exit 1
  94. fi
  95. fi
  96. # Check for pkg-config
  97. if test "$pkgconfig" = "yes"; then
  98. if ! pkg-config --version >/dev/null 2>&1; then
  99. echo "$0: pkg-config not found"
  100. exit 1
  101. fi
  102. fi
  103. # Remove old cruft
  104. for x in aclocal.m4 configure config.guess config.log config.sub config.cache config.h.in config.h compile libtool.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 ltmain.sh libtool ltconfig missing mkinstalldirs depcomp install-sh; do rm -f $x autotools/$x; if test -n "$auxdir"; then rm -f "$auxdir/$x"; fi; done
  105. rm -Rf autom4te.cache
  106. if test -n "$auxdir"; then
  107. if test ! -d "$auxdir"; then
  108. mkdir "$auxdir"
  109. fi
  110. aclocalflags="-I $auxdir -I . ${aclocalflags}"
  111. fi
  112. # Honour M4PATH because sometimes M4 doesn't
  113. save_IFS=$IFS
  114. IFS=:
  115. tmp="$M4PATH"
  116. for x in $tmp; do
  117. if test -n "$x"; then
  118. aclocalflags="-I $x ${aclocalflags}"
  119. fi
  120. done
  121. IFS=$save_IFS
  122. # Explain what we are doing from now
  123. set -x
  124. # Bootstrap package
  125. if test "$libtool" = "yes"; then
  126. ${libtoolize} --copy --force
  127. if test -n "$auxdir" -a ! "$auxdir" = "." -a -f "ltmain.sh"; then
  128. echo "$0: working around a minor libtool issue"
  129. mv ltmain.sh "$auxdir/"
  130. fi
  131. fi
  132. aclocal${amvers} ${aclocalflags}
  133. autoconf${acvers}
  134. if test "$header" = "yes"; then
  135. autoheader${acvers}
  136. fi
  137. if test "$makefile" = "yes"; then
  138. #add --include-deps if you want to bootstrap with any other compiler than gcc
  139. #automake${amvers} --add-missing --copy --include-deps
  140. automake${amvers} --foreign --add-missing --copy
  141. fi
  142. # Remove cruft that we no longer want
  143. rm -Rf autom4te.cache