autogen.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #!/bin/sh
  2. # Licensed under the Apache License, Version 2.0 (the "License");
  3. # you may not use this file except in compliance with the License.
  4. # You may obtain a copy of the License at
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. # Unless required by applicable law or agreed to in writing, software
  7. # distributed under the License is distributed on an "AS IS" BASIS,
  8. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. # See the License for the specific language governing permissions and
  10. # limitations under the License.
  11. # This is a simple script which is meant to help developers
  12. # better deal with the GNU autotools, specifically:
  13. #
  14. # aclocal
  15. # libtoolize
  16. # autoconf
  17. # autoheader
  18. # automake
  19. #
  20. # The whole thing is quite complex...
  21. #
  22. # The idea is to run this collection of tools on a single platform,
  23. # typically the main development platform, running a recent version of
  24. # autoconf. In theory, if we had these tools on each platform where we
  25. # ever expected to port the software, we would never need to checkin
  26. # more than a few autotools configuration files. However, the whole
  27. # idea is to generate a configure script and associated files in a way
  28. # that is portable across platforms, so we *have* to check in a whole
  29. # bunch of files generated by all these tools.
  30. # The real source files are:
  31. #
  32. # acinclude.m4 (used by aclocal)
  33. # configure.ac (main autoconf file)
  34. # Makefile.am, */Makefile.am (automake config files)
  35. #
  36. # All the rest is auto-generated.
  37. if [ "$1" = "clean" ]; then
  38. echo "Cleaning..."
  39. rm configure aclocal.m4
  40. rm m4/l*
  41. rm config/*
  42. rmdir config
  43. find . -iname "Makefile.in" -type f -exec rm '{}' +
  44. fi
  45. # Prevent any errors that might result from failing to properly invoke
  46. # `libtoolize` or `glibtoolize,` whichever is present on your system,
  47. # from occurring by testing for its existence and capturing the absolute path to
  48. # its location for caching purposes prior to using it later on in 'Step 2:'
  49. if command -v libtoolize >/dev/null 2>&1; then
  50. LIBTOOLIZE="$(command -v libtoolize)"
  51. elif command -v glibtoolize >/dev/null 2>&1; then
  52. LIBTOOLIZE="$(command -v glibtoolize)"
  53. else
  54. echo "Unable to find a valid copy of libtoolize or glibtoolize in your PATH!"
  55. bail_out
  56. fi
  57. bail_out()
  58. {
  59. echo
  60. echo " Something went wrong, bailing out!"
  61. echo
  62. exit 1
  63. }
  64. # --- Step 1: Generate aclocal.m4 from:
  65. # . acinclude.m4
  66. # . config/*.m4 (these files are referenced in acinclude.m4)
  67. mkdir -p config
  68. echo "Running aclocal"
  69. aclocal -I config || bail_out
  70. # --- Step 2:
  71. echo "Running $LIBTOOLIZE"
  72. $LIBTOOLIZE -f -c || bail_out
  73. $LIBTOOLIZE --automake || bail_out
  74. # --- Step 3: Generate configure and include/miaconfig.h from:
  75. # . configure.ac
  76. #
  77. echo "Running autoconf"
  78. autoconf || bail_out
  79. if grep -q PKG_CHECK_MODULES configure; then
  80. # The generated configure is invalid because pkg-config is unavailable.
  81. rm configure
  82. echo "Missing pkg-config. Check the build requirements."
  83. bail_out
  84. fi
  85. # --- Step 4: Generate config.h.in from:
  86. # . configure.ac (look for AM_CONFIG_HEADER tag or AC_CONFIG_HEADER tag)
  87. echo "Running autoheader"
  88. autoheader -f || bail_out
  89. # --- Step 5: Generate Makefile.in, src/Makefile.in, and a whole bunch of
  90. # files in config (config.guess, config.sub, depcomp,
  91. # install-sh, missing, mkinstalldirs) plus COPYING and
  92. # INSTALL from:
  93. # . Makefile.am
  94. # . src/Makefile.am
  95. #
  96. # Using --add-missing --copy makes sure that, if these files are missing,
  97. # they are copied from the system so they can be used in a distribution.
  98. echo "Running automake --add-missing --copy"
  99. automake --add-missing --copy --warnings=all || bail_out
  100. echo ""
  101. echo "All done."
  102. echo "To build the software now, do something like:"
  103. echo ""
  104. echo "$ ./configure [--enable-debug] [...other options]"
Tip!

Press p or to see the previous file or, n or to see the next file