resetting manifest requested domain to floor
[platform/upstream/autoconf213.git] / autoconf.sh
1 #! @SHELL@
2 # autoconf -- create `configure' using m4 macros
3 # Copyright (C) 1992, 1993, 1994, 1996 Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 # 02111-1307, USA.
19
20 # If given no args, create `configure' from template file `configure.in'.
21 # With one arg, create a configure script on standard output from
22 # the given template file.
23
24 usage="\
25 Usage: autoconf [-h] [--help] [-m dir] [--macrodir=dir]
26        [-l dir] [--localdir=dir] [--version] [template-file]"
27
28 # NLS nuisances.
29 # Only set these to C if already set.  These must not be set unconditionally
30 # because not all systems understand e.g. LANG=C (notably SCO).
31 # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
32 # Non-C LC_CTYPE values break the ctype check.
33 if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
34 if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
35 if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
36 if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
37
38 : ${AC_MACRODIR=@datadir@}
39 : ${M4=@M4@}
40 : ${AWK=@AWK@}
41 case "${M4}" in
42 /*) # Handle the case that m4 has moved since we were configured.
43     # It may have been found originally in a build directory.
44     test -f "${M4}" || M4=m4 ;;
45 esac
46
47 : ${TMPDIR=/tmp}
48 tmpout=`/bin/mktemp ${TMPDIR}/acout.XXXXXX`
49 localdir=
50 show_version=no
51
52 while test $# -gt 0 ; do
53    case "${1}" in
54       -h | --help | --h* )
55          echo "${usage}" 1>&2; rm -f $tmpout ; exit 0 ;;
56       --localdir=* | --l*=* )
57          localdir="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
58          shift ;;
59       -l | --localdir | --l*)
60          shift
61          test $# -eq 0 && { echo "${usage}" 1>&2; rm -f $tmpout; exit 1; }
62          localdir="${1}"
63          shift ;;
64       --macrodir=* | --m*=* )
65          AC_MACRODIR="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
66          shift ;;
67       -m | --macrodir | --m* )
68          shift
69          test $# -eq 0 && { echo "${usage}" 1>&2; rm -f $tmpout; exit 1; }
70          AC_MACRODIR="${1}"
71          shift ;;
72       --version | --v* )
73          show_version=yes; shift ;;
74       -- )     # Stop option processing
75         shift; break ;;
76       - )       # Use stdin as input.
77         break ;;
78       -* )
79         echo "${usage}" 1>&2; rm -f $tmpout; exit 1 ;;
80       * )
81         break ;;
82    esac
83 done
84
85 if test $show_version = yes; then
86   version=`sed -n 's/define.AC_ACVERSION.[      ]*\([0-9.]*\).*/\1/p' \
87     $AC_MACRODIR/acgeneral.m4`
88   echo "Autoconf version $version"
89   rm -f $tmpout
90   exit 0
91 fi
92
93 case $# in
94   0) infile=configure.in ;;
95   1) infile="$1" ;;
96   *) echo "$usage" >&2; rm -f $tmpout; exit 1 ;;
97 esac
98
99 trap 'rm -f $tmpin $tmpout; exit 1' 1 2 15
100
101 tmpin=`/bin/mktemp ${TMPDIR}/acin.XXXXXX`
102 # Always set this, to avoid bogus errors from some rm's.
103 if test z$infile = z-; then
104   infile=$tmpin
105 elif test ! -r "$infile"; then
106   echo "autoconf: ${infile}: No such file or directory" >&2
107   rm -f $tmpin $tmpout
108   exit 1
109 fi
110
111 if test -n "$localdir"; then
112   use_localdir="-I$localdir -DAC_LOCALDIR=$localdir"
113 else
114   use_localdir=
115 fi
116 # Make sure we don't leave those around - they are annoying
117 trap 'rm -f $tmpin $tmpout' 0
118
119 # Use the frozen version of Autoconf if available.
120 r= f=
121 # Some non-GNU m4's don't reject the --help option, so give them /dev/null.
122 case `$M4 --help < /dev/null 2>&1` in
123 *reload-state*) test -r $AC_MACRODIR/autoconf.m4f && { r=--reload f=f; } ;;
124 *traditional*) ;;
125 *) echo Autoconf requires GNU m4 1.1 or later >&2; rm -f $tmpin $tmpout; exit 1 ;;
126 esac
127
128 $M4 -I$AC_MACRODIR $use_localdir $r autoconf.m4$f $infile > $tmpout ||
129   { rm -f $tmpin $tmpout; exit 2; }
130
131 # You could add your own prefixes to pattern if you wanted to check for
132 # them too, e.g. pattern='\(AC_\|ILT_\)', except that UNIX sed doesn't do
133 # alternation.
134 pattern="AC_"
135
136 status=0
137 if grep "^[^#]*${pattern}" $tmpout > /dev/null 2>&1; then
138   echo "autoconf: Undefined macros:" >&2
139   sed -n "s/^[^#]*\\(${pattern}[_A-Za-z0-9]*\\).*/\\1/p" $tmpout |
140     while read macro; do
141       grep -n "^[^#]*$macro" $infile /dev/null
142       test $? -eq 1 && echo >&2 "***BUG in Autoconf--please report*** $macro"
143     done | sort -u >&2
144   status=1
145 fi
146
147 if test $# -eq 0; then
148   exec 4> configure; chmod +x configure
149 else
150   exec 4>&1
151 fi
152
153 # Put the real line numbers into configure to make config.log more helpful.
154 $AWK '
155 /__oline__/ { printf "%d:", NR + 1 }
156            { print }
157 ' $tmpout | sed '
158 /__oline__/s/^\([0-9][0-9]*\):\(.*\)__oline__/\2\1/
159 ' >&4
160
161 rm -f $tmpout $tmpin
162
163 exit $status