OLD | NEW |
(Empty) | |
| 1 #! /bin/sh |
| 2 # |
| 3 # Run 'autoreconf' to build 'configure', 'Makefile.in' and other configure |
| 4 # control files. |
| 5 # |
| 6 # The first time this is run on a GIT checkout the only files that exist are |
| 7 # configure.ac and Makefile.am; all of the autotools support scripts are |
| 8 # missing. They are instantiated with autoreconf --force --install. |
| 9 # |
| 10 # For regular ("tarball") distributions all the files should exist. We do not |
| 11 # want them to be updated *under any circumstances*. It should never be |
| 12 # necessary to run autogen.sh because ./configure --enable-maintainer-mode says |
| 13 # what to do if Makefile.am or configure.ac are changed. |
| 14 # |
| 15 # It is *probably* OK to update the files on a GIT checkout, because they have |
| 16 # come from the local tools, but leave that to the user who is assumed to know |
| 17 # whether it is ok or required. |
| 18 # |
| 19 # This script is intended to work without arguments, there are, however, hidden |
| 20 # arguments (a) for use while testing the script and (b) to fix up systems that |
| 21 # have been broken. If (b) is required the script prompts for the correct |
| 22 # options. For this reason the options are *NOT* documented in the help; this |
| 23 # is deliberate; UTSL. |
| 24 # |
| 25 clean= |
| 26 maintainer= |
| 27 while test $# -gt 0 |
| 28 do |
| 29 case "$1" in |
| 30 --maintainer) |
| 31 maintainer=1;; |
| 32 |
| 33 --clean) |
| 34 clean=1;; |
| 35 |
| 36 *) |
| 37 exec >&2 |
| 38 echo "$0: usage: ./autogen.sh" |
| 39 if test -d .git |
| 40 then |
| 41 echo " ./autogen.sh generates the configure script and" |
| 42 echo " Makefile.in, or refreshes them after changes to Makefile.am" |
| 43 echo " or configure.ac. You may prefer to just run autoreconf." |
| 44 elif test -z "$maintainer" |
| 45 then |
| 46 echo " DO NOT RUN THIS SCRIPT." |
| 47 echo " If you need to change Makefile.am or configure.ac then you" |
| 48 echo " also need to run ./configure --enable-maintainer-mode and" |
| 49 echo " use the appropriate autotools, *NOT* this script, to update" |
| 50 echo " everything, please check the documentation of autoreconf." |
| 51 echo " WARNING: libpng is intentionally generated with a known," |
| 52 echo " fixed, set of autotools. It is known *NOT* to work with" |
| 53 echo " the collection of autotools distributed on highly reputable" |
| 54 echo " operating systems." |
| 55 echo " Remember: autotools is GNU software, you are expected to" |
| 56 echo " pay for support." |
| 57 else |
| 58 echo " You have run autogen.sh with --maintainer enabled and you" |
| 59 echo " are not using a GIT distribution, then you have given an" |
| 60 echo " unrecognized argument. This is not good. --maintainer" |
| 61 echo " switches off any assumptions that you might not know what" |
| 62 echo " you are doing." |
| 63 fi |
| 64 exit 1;; |
| 65 esac |
| 66 |
| 67 shift |
| 68 done |
| 69 # |
| 70 # First check for a set of the autotools files; if absent then this is assumed |
| 71 # to be a GIT version and the local autotools must be used. If present this |
| 72 # is a tarball distribution and the script should not be used. If partially |
| 73 # present bad things are happening. |
| 74 # |
| 75 # The autotools generated files: |
| 76 libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in |
| 77 config.sub configure depcomp install-sh ltmain.sh missing\ |
| 78 test-driver" |
| 79 # |
| 80 # Files generated by versions of configue >2.68 or automake >1.13 (i.e. later |
| 81 # versions than those required by configure.ac): |
| 82 libpng_autotools_extra="compile config.h.in~" |
| 83 # |
| 84 # These are separate because 'maintainer-clean' does not remove them. |
| 85 libpng_libtool_files="scripts/libtool.m4 scripts/ltoptions.m4\ |
| 86 scripts/ltsugar.m4 scripts/ltversion.m4 scripts/lt~obsolete.m4" |
| 87 |
| 88 libpng_autotools_dirs="autom4te.cache" # not required |
| 89 # |
| 90 # The configure generated files: |
| 91 libpng_configure_files="Makefile config.h config.log config.status\ |
| 92 libpng-config libpng.pc libtool stamp-h1" |
| 93 |
| 94 libpng_configure_dirs=".deps" |
| 95 # |
| 96 # We must remove the configure generated files as well as the autotools |
| 97 # generated files if autotools are regenerated because otherwise if configure |
| 98 # has been run without "--enable-maintainer-mode" make can do a partial update |
| 99 # of Makefile. These functions do the two bits of cleaning. |
| 100 clean_autotools(){ |
| 101 rm -rf $libpng_autotools_files $libpng_libtool_files $libpng_autotools_dirs |
| 102 rm -rf $libpng_autotools_extra |
| 103 } |
| 104 |
| 105 clean_configure(){ |
| 106 rm -rf $libpng_configure_files $libpng_configure_dirs |
| 107 } |
| 108 # |
| 109 # Clean: remove everything (this is to help with testing) |
| 110 if test -n "$clean" |
| 111 then |
| 112 clean_configure |
| 113 if test -n "$maintainer" |
| 114 then |
| 115 clean_autotools |
| 116 fi |
| 117 |
| 118 exit 0 |
| 119 fi |
| 120 # |
| 121 # Validate the distribution. |
| 122 libpng_autotools_file_found= |
| 123 libpng_autotools_file_missing= |
| 124 for file in $libpng_autotools_files |
| 125 do |
| 126 if test -f "$file" |
| 127 then |
| 128 libpng_autotools_file_found=1 |
| 129 else |
| 130 libpng_autotools_file_missing=1 |
| 131 fi |
| 132 done |
| 133 # |
| 134 # Presence of one of these does not *invalidate* missing, but absence |
| 135 # invalidates found. |
| 136 for file in $libpng_libtool_files |
| 137 do |
| 138 if test ! -f "$file" |
| 139 then |
| 140 libpng_autotools_file_missing=1 |
| 141 fi |
| 142 done |
| 143 # |
| 144 # The cache directory doesn't matter - it will be regenerated and does not exist |
| 145 # anyway in a tarball. |
| 146 # |
| 147 # Either everything is missing or everything is there, the --maintainer option |
| 148 # just changes this so that the mode is set to generate all the files. |
| 149 mode= |
| 150 if test -z "$libpng_autotools_file_found" -o -n "$maintainer" |
| 151 then |
| 152 mode="autoreconf" |
| 153 else |
| 154 if test -n "$libpng_autotools_file_missing" |
| 155 then |
| 156 mode="broken" |
| 157 else |
| 158 mode="configure" |
| 159 fi |
| 160 fi |
| 161 # |
| 162 # So: |
| 163 case "$mode" in |
| 164 autoreconf) |
| 165 # Clean in case configure files exist |
| 166 clean_configure |
| 167 clean_autotools |
| 168 # Everything must be initialized, so use --force |
| 169 if autoreconf --warnings=all --force --install |
| 170 then |
| 171 missing= |
| 172 for file in $libpng_autotools_files |
| 173 do |
| 174 test -f "$file" || missing=1 |
| 175 done |
| 176 # ignore the cache directory |
| 177 test -z "$missing" || { |
| 178 exec >&2 |
| 179 echo "autoreconf was run, but did not produce all the expected" |
| 180 echo "files. It is likely that your autotools installation is" |
| 181 echo "not compatible with that expected by libpng." |
| 182 exit 1 |
| 183 } |
| 184 else |
| 185 exec >&2 |
| 186 echo "autoreconf failed: your version of autotools is incompatible" |
| 187 echo "with this libpng version. Please use a distributed archive" |
| 188 echo "(which includes the autotools generated files) and run configure" |
| 189 echo "instead." |
| 190 exit 1 |
| 191 fi;; |
| 192 |
| 193 configure) |
| 194 if test -d .git |
| 195 then |
| 196 exec >&2 |
| 197 echo "ERROR: running autoreconf on an initialized sytem" |
| 198 echo " This is not necessary; it is only necessary to remake the" |
| 199 echo " autotools generated files if Makefile.am or configure.ac" |
| 200 echo " change and make does the right thing with:" |
| 201 echo |
| 202 echo " ./configure --enable-maintainer-mode." |
| 203 echo |
| 204 echo " You can run autoreconf yourself if you don't like maintainer" |
| 205 echo " mode and you can also just run autoreconf -f -i to initialize" |
| 206 echo " everything in the first place; this script is only for" |
| 207 echo " compatibility with prior releases." |
| 208 exit 1 |
| 209 else |
| 210 exec >&2 |
| 211 echo "autogen.sh is intended only to generate 'configure' on systems" |
| 212 echo "that do not have it. You have a complete 'configure', if you" |
| 213 echo "need to change Makefile.am or configure.ac you also need to" |
| 214 echo "run configure with the --enable-maintainer-mode option." |
| 215 exit 1 |
| 216 fi;; |
| 217 |
| 218 broken) |
| 219 exec >&2 |
| 220 echo "Your system has a partial set of autotools generated files." |
| 221 echo "autogen.sh is unable to proceed. The full set of files is" |
| 222 echo "contained in the libpng 'tar' distribution archive and you do" |
| 223 echo "not need to run autogen.sh if you use it." |
| 224 exit 1;; |
| 225 esac |
OLD | NEW |