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