File: autoheader

package info (click to toggle)
dirb 2.22%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,244 kB
  • sloc: ansic: 1,704; sh: 1,132; makefile: 51; perl: 23
file content (364 lines) | stat: -rw-r--r-- 9,911 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
#! /bin/bash
AUTO_STABLE=${AUTO_STABLE:-/usr/autotool/stable}
AUTO_DEVEL=${AUTO_DEVEL:-/usr/autotool/devel}

me=`echo "$0" | sed -e 's,.*[\\/],,'`

help="\
Try \`$me --help' for more information."

exit_missing_arg="\
echo \"$me: option \\\`\$1' requires an argument\" >&2
echo \"\$help\" >&2
exit 1"

# Set up variables
unset autosense_input
unset opt_version
unset opt_help
unset opt_debug
unset opt_verbose
unset opt_force
unset opt_localdir
unset opt_autoconf_dir
unset opt_macrodir
unset opt_include
unset includes
unset opt_prepend_include
unset prepend_includes
unset opt_warnings
unset warnings
unset opt_stop
# Parse command line.  We have to do this in case the user
# specifies the input file or uses stdin.  If so, then
# we must accommodate...but we can only do that if we
# parse ALL possible options.  This gets ugly if the
# two versions of autoconf accept different options.
while test $# -gt 0 ; do
  optarg=`expr "x$1" : 'x--[^=]*=\(.*\)' \| \
               "x$1" : 'x-.\(.*\)'`
  case $1 in

    --version | -V ) 
       opt_version="--version"
       shift ;;


    --help | -h )
       opt_help="--help"
       shift ;;


    --debug | -d )
       opt_debug="--debug"
       shift ;;


    --verbose | -v )
       opt_verbose="--verbose"
       shift ;;


    --force | -f )
       opt_force="--force"
       shift ;;


    --localdir=* | -l?* )
       opt_localdir="--localdir=$optarg"
       shift ;;
    --localdir | -l )
       test $# = 1 && eval "$exit_missing_arg"
       shift
       opt_localdir="--localdir=$1"
       shift ;;


    --autoconf-dir=* | -A?* )
       opt_autoconf_dir="--autoconf-dir=$optarg"
       shift ;;
    --autoconf-dir | -A )
       test $# = 1 && eval "$exit_missing_arg"
       shift
       opt_autoconf_dir="--autoconf-dir=$1"
       shift ;;


    --macrodir=* | -m?* )
       opt_macrodir="--macrodir=$optarg"
       shift ;;
    --macrodir | -m )
       test $# = 1 && eval "$exit_missing_arg"
       shift
       opt_macrodir="--macrodir=$1"
       shift ;;


    --include=* | -I?* )
       includes="$includes --include=$optarg"
       shift ;;
    --include | -I )
       test $# = 1 && eval "$exit_missing_arg"
       shift
       includes="$includes --include=$1"
       shift ;;


    --prepend-include=* | -B?* )
       prepend_includes="$prepend_includes --prepend-include=$optarg"
       shift ;;
    --prepend-include | -B )
       test $# = 1 && eval "$exit_missing_arg"
       shift
       prepend_includes="$prepend_includes --prepend-include=$1"
       shift ;;


    --warnings=* | -W?* )
       warnings=$warnings,$optarg
       shift ;;
    --warnings | -W )
       test $# = 1 && eval "$exit_missing_arg"
       shift
       warnings=$warnings,$1
       shift ;;


    -- )     # Stop option processing
       shift
       opt_stop="--"
       break ;;


    - )      # Use stdin as input.
       break ;;


    -* )
       exec >&2
       echo "$me: invalid option $1"
       echo "$help"
       exit 1 ;;


    * )
       break ;;
  esac
done

# Special handling for the options that can be called 
# multiple times.
if [ "x$includes" != "x" ] ; then
  opt_include="$includes"
fi
if [ "x$prepend_includes" != "x" ] ; then
  opt_prepend_include="$prepend_includes"
fi
if [ "x$warnings" != "x" ] ; then
  opt_warnings="--warnings=$warnings"
fi

# Trap on 0 to stop playing with `rm'.
$debug ||
{
  trap 'status=$?; rm -rf $tmp && exit $status' 0
  trap '(exit 1); exit 1' 1 2 13 15
}


unset VER
unset SHORTCUT_DEVEL
unset SHORTCUT_STABLE
if [ -n "${WANT_AUTOCONF_VER}" ] ; then
  VER=${WANT_AUTOCONF_VER}

  # some duplicated code (from setpath.frag), but oh well
  VER_MAJ=`echo $VER | awk -F. '{print $1}'`
  VER_MIN=`echo $VER | awk -F. '{print $2}'`

  if [ "x${VER_MIN}" != "x" ] ; then
    if (( ${VER_MIN} <= 13 )) ; then
      SHORTCUT_STABLE="yes"
    else
      SHORTCUT_DEVEL="yes"
    fi
  fi
fi


# Find the input file.
case $# in
  0)
    case `ls configure.ac configure.in 2>/dev/null` in
      *ac*in )
        echo "$me: warning: both \`configure.ac' and \`configure.in' are present." >&2
        echo "$me: warning: proceeding with \`configure.ac'." >&2
        infile=configure.ac;;
      *ac ) infile=configure.ac;;
      *in ) infile=configure.in;;
      * )
      # if --version is supplied but no file is found, generate generic
      # version message.  First, call DEVEL --version, echo divider,
      # then call STABLE --version, another divider, and finally
      # an explanatory message.  That way, programs that try to
      # parse the output of --version won't be confused: they will
      # see DEVEL's version information and will discard everything else
      # (since they already discard all the license gobbledygook)
      #
      # On the other hand, if VER is already established (e.g. 
      # WANT_AUTOCONF_VER is set), then only print the "right" one.
      if [ -n "$SHORTCUT_DEVEL" ] ; then
        if [ -n "$opt_version" ] ; then
          ${AUTO_DEVEL}/bin/autoheader --version
	  exit 0
	elif [ -n "$opt_help" ] ; then
          ${AUTO_DEVEL}/bin/autoheader --help
	  exit 0
        else
          echo "$me: no input file" >&2
          exit 1
        fi
      elif [ -n "$SHORTCUT_STABLE" ] ; then
        if [ -n "$opt_version" ] ; then
          ${AUTO_STABLE}/bin/autoheader --version
	  exit 0
	elif [ -n "$opt_help" ] ; then
          ${AUTO_STABLE}/bin/autoheader --help
	  exit 0
        else
          echo "$me: no input file" >&2
          exit 1
        fi
      else
        if [ -n "$opt_version" ]; then
          ${AUTO_DEVEL}/bin/autoheader --version
          echo "--------------------------------------------------------"
          ${AUTO_STABLE}/bin/autoheader --version
          echo "--------------------------------------------------------"
          echo "This is autoheader-wrapper, which will hand off execution"
          echo "to one of the two real versions listed above, depending"
          echo "on the contents of configure.in/configure.ac.  Since the"
          echo "wrapper was called from within a directory in which those"
          echo "files are not found, this generic 'version' message is"
          echo "displayed."
          exit 0
        elif [ -n "$opt_help" ]; then
          ${AUTO_DEVEL}/bin/autoheader --help
          echo ""
          echo "--------------------------------------------------------"
          echo "------ Above: 'devel' help.  Below: 'stable' help ------"
          echo "--------------------------------------------------------"
          echo ""
          ${AUTO_STABLE}/bin/autoheader --help
          echo ""
          echo "--------------------------------------------------------"
          echo "------ Above: 'stable' help.  Below: 'wrapper' help ----"
          echo "--------------------------------------------------------"
          echo ""
          echo "This is autoheader-wrapper, which will hand off execution"
          echo "to one of the two real versions listed above, depending"
          echo "on the contents of configure.in/configure.ac.  Since the"
          echo "wrapper was called from within a directory in which those"
          echo "files are not found, this generic 'help' message is"
          echo "displayed."
          exit 0
        else
          echo "$me: no input file" >&2
          exit 1
        fi
      fi
      ;;
    esac
    autosense_input=true ;;
  1) infile=$1 ;;
  *) exec >&2
     echo "$me: invalid number of arguments."
     echo "$help"
     (exit 1); exit 1 ;;
esac


# Create a (secure) tmp directory for tmp files.
: ${TMPDIR=/tmp}
{
  tmp=`(umask 077 && mktemp -d -q "$TMPDIR/acXXXXXX") 2>/dev/null` &&
  test -n "$tmp" && test -d "$tmp"
} ||
{
  tmp=$TMPDIR/ac$$
  (umask 077 && mkdir $tmp)
} ||
{
   echo "$me: cannot create a temporary directory in $TMPDIR" >&2
   (exit 1); exit 1;
}


# We need an actual file.
if test z$infile = z-; then
  infile=$tmp/stdin
  cat >$infile
elif test ! -r "$infile"; then
  echo "$me: $infile: No such file or directory" >&2
  (exit 1); exit 1
fi


# Find the version
if [ -z "${VER}" ] ; then
  VER=`sed -n -e '/AC_PREREQ/s/[^(]*([[]*\([[:digit:]\.]*\)[]]*).*$/\1/p' < $infile`
fi

VER_MAJ=`echo $VER | awk -F. '{print $1}'`
VER_MIN=`echo $VER | awk -F. '{print $2}'`

# Set the PATH appropriately
if [ "x${VER_MIN}" != "x" ] ; then
  if (( ${VER_MIN} <= 13 )) ; then
    if [ ! -x ${AUTO_STABLE}/bin/autoheader ] ; then
      echo "Can't find ${AUTO_STABLE}/bin/autoheader" 2>&1
      exit 1
    fi
    export PATH=${AUTO_STABLE}/bin:${PATH} 
    export M4PATH=${AUTO_STABLE}/share/autoconf:${M4PATH}
  else
    if [ ! -x ${AUTO_DEVEL}/bin/autoheader ] ; then
      echo "Can't find ${AUTO_DEVEL}/bin/autoheader" 2>&1
      exit 1
    fi
    export PATH=${AUTO_DEVEL}/bin:${PATH}
    export M4PATH=${AUTO_DEVEL}/share/autoconf:${M4PATH}
  fi
else
  if [ ! -x ${AUTO_DEVEL}/bin/autoheader ] ; then
    echo "Can't find ${AUTO_DEVEL}/bin/autoheader" 2>&1
    exit 1
  fi
  export PATH=${AUTO_DEVEL}/bin:${PATH}
  export M4PATH=${AUTO_DEVEL}/share/autoconf:${M4PATH}
fi


# exec the "real" autoheader
if [ "z$infile" == "z$tmp/stdin" ] ; then
  autoheader $opt_version $opt_help \
       $opt_debug $opt_verbose $opt_localdir \
       $opt_include $opt_prepend_include $opt_autoconf_dir $opt_macrodir 
       $opt_warnings $opt_force \
       $opt_stop - < $infile
  rm -rf $tmp
elif [ "z$autosense_input" == "ztrue" ] ; then
  rm -rf $tmp 
  exec autoheader $opt_version $opt_help \
       $opt_debug $opt_verbose $opt_localdir \
       $opt_include $opt_prepend_include $opt_autoconf_dir $opt_macrodir \
       $opt_warnings $opt_force \
       $opt_stop 
else
  rm -rf $tmp 
  exec autoheader $opt_version $opt_help \
       $opt_debug $opt_verbose $opt_localdir \
       $opt_include $opt_prepend_include $opt_autoconf_dir $opt_macrodir 
       $opt_warnings $opt_force \
       $opt_stop $infile
fi