Chris@41: #! /bin/sh Chris@41: # Wrapper for compilers which do not understand `-c -o'. Chris@41: Chris@41: scriptversion=2009-04-28.21; # UTC Chris@41: Chris@41: # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software Chris@41: # Foundation, Inc. Chris@41: # Written by Tom Tromey . Chris@41: # Chris@41: # This program is free software; you can redistribute it and/or modify Chris@41: # it under the terms of the GNU General Public License as published by Chris@41: # the Free Software Foundation; either version 2, or (at your option) Chris@41: # any later version. Chris@41: # Chris@41: # This program is distributed in the hope that it will be useful, Chris@41: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@41: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@41: # GNU General Public License for more details. Chris@41: # Chris@41: # You should have received a copy of the GNU General Public License Chris@41: # along with this program. If not, see . Chris@41: Chris@41: # As a special exception to the GNU General Public License, if you Chris@41: # distribute this file as part of a program that contains a Chris@41: # configuration script generated by Autoconf, you may include it under Chris@41: # the same distribution terms that you use for the rest of that program. Chris@41: Chris@41: # This file is maintained in Automake, please report Chris@41: # bugs to or send patches to Chris@41: # . Chris@41: Chris@41: case $1 in Chris@41: '') Chris@41: echo "$0: No command. Try \`$0 --help' for more information." 1>&2 Chris@41: exit 1; Chris@41: ;; Chris@41: -h | --h*) Chris@41: cat <<\EOF Chris@41: Usage: compile [--help] [--version] PROGRAM [ARGS] Chris@41: Chris@41: Wrapper for compilers which do not understand `-c -o'. Chris@41: Remove `-o dest.o' from ARGS, run PROGRAM with the remaining Chris@41: arguments, and rename the output as expected. Chris@41: Chris@41: If you are trying to build a whole package this is not the Chris@41: right script to run: please start by reading the file `INSTALL'. Chris@41: Chris@41: Report bugs to . Chris@41: EOF Chris@41: exit $? Chris@41: ;; Chris@41: -v | --v*) Chris@41: echo "compile $scriptversion" Chris@41: exit $? Chris@41: ;; Chris@41: esac Chris@41: Chris@41: ofile= Chris@41: cfile= Chris@41: eat= Chris@41: Chris@41: for arg Chris@41: do Chris@41: if test -n "$eat"; then Chris@41: eat= Chris@41: else Chris@41: case $1 in Chris@41: -o) Chris@41: # configure might choose to run compile as `compile cc -o foo foo.c'. Chris@41: # So we strip `-o arg' only if arg is an object. Chris@41: eat=1 Chris@41: case $2 in Chris@41: *.o | *.obj) Chris@41: ofile=$2 Chris@41: ;; Chris@41: *) Chris@41: set x "$@" -o "$2" Chris@41: shift Chris@41: ;; Chris@41: esac Chris@41: ;; Chris@41: *.c) Chris@41: cfile=$1 Chris@41: set x "$@" "$1" Chris@41: shift Chris@41: ;; Chris@41: *) Chris@41: set x "$@" "$1" Chris@41: shift Chris@41: ;; Chris@41: esac Chris@41: fi Chris@41: shift Chris@41: done Chris@41: Chris@41: if test -z "$ofile" || test -z "$cfile"; then Chris@41: # If no `-o' option was seen then we might have been invoked from a Chris@41: # pattern rule where we don't need one. That is ok -- this is a Chris@41: # normal compilation that the losing compiler can handle. If no Chris@41: # `.c' file was seen then we are probably linking. That is also Chris@41: # ok. Chris@41: exec "$@" Chris@41: fi Chris@41: Chris@41: # Name of file we expect compiler to create. Chris@41: cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` Chris@41: Chris@41: # Create the lock directory. Chris@41: # Note: use `[/\\:.-]' here to ensure that we don't use the same name Chris@41: # that we are using for the .o file. Also, base the name on the expected Chris@41: # object file name, since that is what matters with a parallel build. Chris@41: lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d Chris@41: while true; do Chris@41: if mkdir "$lockdir" >/dev/null 2>&1; then Chris@41: break Chris@41: fi Chris@41: sleep 1 Chris@41: done Chris@41: # FIXME: race condition here if user kills between mkdir and trap. Chris@41: trap "rmdir '$lockdir'; exit 1" 1 2 15 Chris@41: Chris@41: # Run the compile. Chris@41: "$@" Chris@41: ret=$? Chris@41: Chris@41: if test -f "$cofile"; then Chris@41: mv "$cofile" "$ofile" Chris@41: elif test -f "${cofile}bj"; then Chris@41: mv "${cofile}bj" "$ofile" Chris@41: fi Chris@41: Chris@41: rmdir "$lockdir" Chris@41: exit $ret Chris@41: Chris@41: # Local Variables: Chris@41: # mode: shell-script Chris@41: # sh-indentation: 2 Chris@41: # eval: (add-hook 'write-file-hooks 'time-stamp) Chris@41: # time-stamp-start: "scriptversion=" Chris@41: # time-stamp-format: "%:y-%02m-%02d.%02H" Chris@41: # time-stamp-time-zone: "UTC" Chris@41: # time-stamp-end: "; # UTC" Chris@41: # End: