|
Packit Service |
9def5d |
#! /bin/sh
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
# Wrapper for compilers which do not understand `-c -o'.
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
# Copyright 1999, 2000 Free Software Foundation, Inc.
|
|
Packit Service |
9def5d |
# Written by Tom Tromey <tromey@cygnus.com>.
|
|
Packit Service |
9def5d |
#
|
|
Packit Service |
9def5d |
# This program is free software; you can redistribute it and/or modify
|
|
Packit Service |
9def5d |
# it under the terms of the GNU General Public License as published by
|
|
Packit Service |
9def5d |
# the Free Software Foundation; either version 2, or (at your option)
|
|
Packit Service |
9def5d |
# any later version.
|
|
Packit Service |
9def5d |
#
|
|
Packit Service |
9def5d |
# This program is distributed in the hope that it will be useful,
|
|
Packit Service |
9def5d |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
9def5d |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
9def5d |
# GNU General Public License for more details.
|
|
Packit Service |
9def5d |
#
|
|
Packit Service |
9def5d |
# You should have received a copy of the GNU General Public License
|
|
Packit Service |
9def5d |
# along with this program; if not, write to the Free Software
|
|
Packit Service |
9def5d |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
# As a special exception to the GNU General Public License, if you
|
|
Packit Service |
9def5d |
# distribute this file as part of a program that contains a
|
|
Packit Service |
9def5d |
# configuration script generated by Autoconf, you may include it under
|
|
Packit Service |
9def5d |
# the same distribution terms that you use for the rest of that program.
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
# Usage:
|
|
Packit Service |
9def5d |
# compile PROGRAM [ARGS]...
|
|
Packit Service |
9def5d |
# `-o FOO.o' is removed from the args passed to the actual compile.
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
prog=$1
|
|
Packit Service |
9def5d |
shift
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
ofile=
|
|
Packit Service |
9def5d |
cfile=
|
|
Packit Service |
9def5d |
args=
|
|
Packit Service |
9def5d |
while test $# -gt 0; do
|
|
Packit Service |
9def5d |
case "$1" in
|
|
Packit Service |
9def5d |
-o)
|
|
Packit Service |
9def5d |
# configure might choose to run compile as `compile cc -o foo foo.c'.
|
|
Packit Service |
9def5d |
# So we do something ugly here.
|
|
Packit Service |
9def5d |
ofile=$2
|
|
Packit Service |
9def5d |
shift
|
|
Packit Service |
9def5d |
case "$ofile" in
|
|
Packit Service |
9def5d |
*.o | *.obj)
|
|
Packit Service |
9def5d |
;;
|
|
Packit Service |
9def5d |
*)
|
|
Packit Service |
9def5d |
args="$args -o $ofile"
|
|
Packit Service |
9def5d |
ofile=
|
|
Packit Service |
9def5d |
;;
|
|
Packit Service |
9def5d |
esac
|
|
Packit Service |
9def5d |
;;
|
|
Packit Service |
9def5d |
*.c)
|
|
Packit Service |
9def5d |
cfile=$1
|
|
Packit Service |
9def5d |
args="$args $1"
|
|
Packit Service |
9def5d |
;;
|
|
Packit Service |
9def5d |
*)
|
|
Packit Service |
9def5d |
args="$args $1"
|
|
Packit Service |
9def5d |
;;
|
|
Packit Service |
9def5d |
esac
|
|
Packit Service |
9def5d |
shift
|
|
Packit Service |
9def5d |
done
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
if test -z "$ofile" || test -z "$cfile"; then
|
|
Packit Service |
9def5d |
# If no `-o' option was seen then we might have been invoked from a
|
|
Packit Service |
9def5d |
# pattern rule where we don't need one. That is ok -- this is a
|
|
Packit Service |
9def5d |
# normal compilation that the losing compiler can handle. If no
|
|
Packit Service |
9def5d |
# `.c' file was seen then we are probably linking. That is also
|
|
Packit Service |
9def5d |
# ok.
|
|
Packit Service |
9def5d |
exec "$prog" $args
|
|
Packit Service |
9def5d |
fi
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
# Name of file we expect compiler to create.
|
|
Packit Service |
9def5d |
cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
# Create the lock directory.
|
|
Packit Service |
9def5d |
# Note: use `[/.-]' here to ensure that we don't use the same name
|
|
Packit Service |
9def5d |
# that we are using for the .o file. Also, base the name on the expected
|
|
Packit Service |
9def5d |
# object file name, since that is what matters with a parallel build.
|
|
Packit Service |
9def5d |
lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d
|
|
Packit Service |
9def5d |
while true; do
|
|
Packit Service |
9def5d |
if mkdir $lockdir > /dev/null 2>&1; then
|
|
Packit Service |
9def5d |
break
|
|
Packit Service |
9def5d |
fi
|
|
Packit Service |
9def5d |
sleep 1
|
|
Packit Service |
9def5d |
done
|
|
Packit Service |
9def5d |
# FIXME: race condition here if user kills between mkdir and trap.
|
|
Packit Service |
9def5d |
trap "rmdir $lockdir; exit 1" 1 2 15
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
# Run the compile.
|
|
Packit Service |
9def5d |
"$prog" $args
|
|
Packit Service |
9def5d |
status=$?
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
if test -f "$cofile"; then
|
|
Packit Service |
9def5d |
mv "$cofile" "$ofile"
|
|
Packit Service |
9def5d |
fi
|
|
Packit Service |
9def5d |
|
|
Packit Service |
9def5d |
rmdir $lockdir
|
|
Packit Service |
9def5d |
exit $status
|