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