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