112303
+ 鐃緒申 1 #! /bin/sh
+ 鐃緒申 2 # Wrapper for compilers which do not understand `-c -o'.
+ 鐃緒申 3
+ 鐃緒申 4 scriptversion=2009-10-06.20; # UTC
+ 鐃緒申 5
+ 鐃緒申 6 # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software
+ 鐃緒申 7 # Foundation, Inc.
+ 鐃緒申 8 # Written by Tom Tromey <tromey@cygnus.com>.
+ 鐃緒申 9 #
+ 鐃緒申 10 # This program is free software; you can redistribute it and/or modify
+ 鐃緒申 11 # it under the terms of the GNU General Public License as published by
+ 鐃緒申 12 # the Free Software Foundation; either version 2, or (at your option)
+ 鐃緒申 13 # any later version.
+ 鐃緒申 14 #
+ 鐃緒申 15 # This program is distributed in the hope that it will be useful,
+ 鐃緒申 16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 鐃緒申 17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 鐃緒申 18 # GNU General Public License for more details.
+ 鐃緒申 19 #
+ 鐃緒申 20 # You should have received a copy of the GNU General Public License
+ 鐃緒申 21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
+ 鐃緒申 22
+ 鐃緒申 23 # As a special exception to the GNU General Public License, if you
+ 鐃緒申 24 # distribute this file as part of a program that contains a
+ 鐃緒申 25 # configuration script generated by Autoconf, you may include it under
+ 鐃緒申 26 # the same distribution terms that you use for the rest of that program.
+ 鐃緒申 27
+ 鐃緒申 28 # This file is maintained in Automake, please report
+ 鐃緒申 29 # bugs to <bug-automake@gnu.org> or send patches to
+ 鐃緒申 30 # <automake-patches@gnu.org>.
+ 鐃緒申 31
+ 鐃緒申 32 case $1 in
+ 鐃緒申 33 '')
+ 鐃緒申 34 echo "$0: No command. Try \`$0 --help' for more information." 1>&2
+ 鐃緒申 35 exit 1;
+ 鐃緒申 36 ;;
+ 鐃緒申 37 -h | --h*)
+ 鐃緒申 38 cat <<\EOF
+ 鐃緒申 39 Usage: compile [--help] [--version] PROGRAM [ARGS]
+ 鐃緒申 40
+ 鐃緒申 41 Wrapper for compilers which do not understand `-c -o'.
+ 鐃緒申 42 Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
+ 鐃緒申 43 arguments, and rename the output as expected.
+ 鐃緒申 44
+ 鐃緒申 45 If you are trying to build a whole package this is not the
+ 鐃緒申 46 right script to run: please start by reading the file `INSTALL'.
+ 鐃緒申 47
+ 鐃緒申 48 Report bugs to <bug-automake@gnu.org>.
+ 鐃緒申 49 EOF
+ 鐃緒申 50 exit $?
+ 鐃緒申 51 ;;
+ 鐃緒申 52 -v | --v*)
+ 鐃緒申 53 echo "compile $scriptversion"
+ 鐃緒申 54 exit $?
+ 鐃緒申 55 ;;
+ 鐃緒申 56 esac
+ 鐃緒申 57
+ 鐃緒申 58 ofile=
+ 鐃緒申 59 cfile=
+ 鐃緒申 60 eat=
+ 鐃緒申 61
+ 鐃緒申 62 for arg
+ 鐃緒申 63 do
+ 鐃緒申 64 if test -n "$eat"; then
+ 鐃緒申 65 eat=
+ 鐃緒申 66 else
+ 鐃緒申 67 case $1 in
+ 鐃緒申 68 -o)
+ 鐃緒申 69 # configure might choose to run compile as `compile cc -o foo foo.c'.
+ 鐃緒申 70 # So we strip `-o arg' only if arg is an object.
+ 鐃緒申 71 eat=1
+ 鐃緒申 72 case $2 in
+ 鐃緒申 73 *.o | *.obj)
+ 鐃緒申 74 ofile=$2
+ 鐃緒申 75 ;;
+ 鐃緒申 76 *)
+ 鐃緒申 77 set x "$@" -o "$2"
+ 鐃緒申 78 shift
+ 鐃緒申 79 ;;
+ 鐃緒申 80 esac
+ 鐃緒申 81 ;;
+ 鐃緒申 82 *.c)
+ 鐃緒申 83 cfile=$1
+ 鐃緒申 84 set x "$@" "$1"
+ 鐃緒申 85 shift
+ 鐃緒申 86 ;;
+ 鐃緒申 87 *)
+ 鐃緒申 88 set x "$@" "$1"
+ 鐃緒申 89 shift
+ 鐃緒申 90 ;;
+ 鐃緒申 91 esac
+ 鐃緒申 92 fi
+ 鐃緒申 93 shift
+ 鐃緒申 94 done
+ 鐃緒申 95
+ 鐃緒申 96 if test -z "$ofile" || test -z "$cfile"; then
+ 鐃緒申 97 # If no `-o' option was seen then we might have been invoked from a
+ 鐃緒申 98 # pattern rule where we don't need one. That is ok -- this is a
+ 鐃緒申 99 # normal compilation that the losing compiler can handle. If no
+ 鐃緒申 100 # `.c' file was seen then we are probably linking. That is also
+ 鐃緒申 101 # ok.
+ 鐃緒申 102 exec "$@"
+ 鐃緒申 103 fi
+ 鐃緒申 104
+ 鐃緒申 105 # Name of file we expect compiler to create.
+ 鐃緒申 106 cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
+ 鐃緒申 107
+ 鐃緒申 108 # Create the lock directory.
+ 鐃緒申 109 # Note: use `[/\\:.-]' here to ensure that we don't use the same name
+ 鐃緒申 110 # that we are using for the .o file. Also, base the name on the expected
+ 鐃緒申 111 # object file name, since that is what matters with a parallel build.
+ 鐃緒申 112 lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
+ 鐃緒申 113 while true; do
+ 鐃緒申 114 if mkdir "$lockdir" >/dev/null 2>&1; then
+ 鐃緒申 115 break
+ 鐃緒申 116 fi
+ 鐃緒申 117 sleep 1
+ 鐃緒申 118 done
+ 鐃緒申 119 # FIXME: race condition here if user kills between mkdir and trap.
+ 鐃緒申 120 trap "rmdir '$lockdir'; exit 1" 1 2 15
+ 鐃緒申 121
+ 鐃緒申 122 # Run the compile.
+ 鐃緒申 123 "$@"
+ 鐃緒申 124 ret=$?
+ 鐃緒申 125
+ 鐃緒申 126 if test -f "$cofile"; then
+ 鐃緒申 127 test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
+ 鐃緒申 128 elif test -f "${cofile}bj"; then
+ 鐃緒申 129 test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
+ 鐃緒申 130 fi
+ 鐃緒申 131
+ 鐃緒申 132 rmdir "$lockdir"
+ 鐃緒申 133 exit $ret
+ 鐃緒申 134
+ 鐃緒申 135 # Local Variables:
+ 鐃緒申 136 # mode: shell-script
+ 鐃緒申 137 # sh-indentation: 2
+ 鐃緒申 138 # eval: (add-hook 'write-file-hooks 'time-stamp)
+ 鐃緒申 139 # time-stamp-start: "scriptversion="
+ 鐃緒申 140 # time-stamp-format: "%:y-%02m-%02d.%02H"
+ 鐃緒申 141 # time-stamp-time-zone: "UTC"
+ 鐃緒申 142 # time-stamp-end: "; # UTC"
+ 鐃緒申 143 # End: