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