1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/gst-gpac/compile Thu Feb 28 08:10:55 2008 +0000
1.3 @@ -0,0 +1,142 @@
1.4 +#! /bin/sh
1.5 +# Wrapper for compilers which do not understand `-c -o'.
1.6 +
1.7 +scriptversion=2005-05-14.22
1.8 +
1.9 +# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
1.10 +# Written by Tom Tromey <tromey@cygnus.com>.
1.11 +#
1.12 +# This program is free software; you can redistribute it and/or modify
1.13 +# it under the terms of the GNU General Public License as published by
1.14 +# the Free Software Foundation; either version 2, or (at your option)
1.15 +# any later version.
1.16 +#
1.17 +# This program is distributed in the hope that it will be useful,
1.18 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1.19 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.20 +# GNU General Public License for more details.
1.21 +#
1.22 +# You should have received a copy of the GNU General Public License
1.23 +# along with this program; if not, write to the Free Software
1.24 +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1.25 +
1.26 +# As a special exception to the GNU General Public License, if you
1.27 +# distribute this file as part of a program that contains a
1.28 +# configuration script generated by Autoconf, you may include it under
1.29 +# the same distribution terms that you use for the rest of that program.
1.30 +
1.31 +# This file is maintained in Automake, please report
1.32 +# bugs to <bug-automake@gnu.org> or send patches to
1.33 +# <automake-patches@gnu.org>.
1.34 +
1.35 +case $1 in
1.36 + '')
1.37 + echo "$0: No command. Try \`$0 --help' for more information." 1>&2
1.38 + exit 1;
1.39 + ;;
1.40 + -h | --h*)
1.41 + cat <<\EOF
1.42 +Usage: compile [--help] [--version] PROGRAM [ARGS]
1.43 +
1.44 +Wrapper for compilers which do not understand `-c -o'.
1.45 +Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
1.46 +arguments, and rename the output as expected.
1.47 +
1.48 +If you are trying to build a whole package this is not the
1.49 +right script to run: please start by reading the file `INSTALL'.
1.50 +
1.51 +Report bugs to <bug-automake@gnu.org>.
1.52 +EOF
1.53 + exit $?
1.54 + ;;
1.55 + -v | --v*)
1.56 + echo "compile $scriptversion"
1.57 + exit $?
1.58 + ;;
1.59 +esac
1.60 +
1.61 +ofile=
1.62 +cfile=
1.63 +eat=
1.64 +
1.65 +for arg
1.66 +do
1.67 + if test -n "$eat"; then
1.68 + eat=
1.69 + else
1.70 + case $1 in
1.71 + -o)
1.72 + # configure might choose to run compile as `compile cc -o foo foo.c'.
1.73 + # So we strip `-o arg' only if arg is an object.
1.74 + eat=1
1.75 + case $2 in
1.76 + *.o | *.obj)
1.77 + ofile=$2
1.78 + ;;
1.79 + *)
1.80 + set x "$@" -o "$2"
1.81 + shift
1.82 + ;;
1.83 + esac
1.84 + ;;
1.85 + *.c)
1.86 + cfile=$1
1.87 + set x "$@" "$1"
1.88 + shift
1.89 + ;;
1.90 + *)
1.91 + set x "$@" "$1"
1.92 + shift
1.93 + ;;
1.94 + esac
1.95 + fi
1.96 + shift
1.97 +done
1.98 +
1.99 +if test -z "$ofile" || test -z "$cfile"; then
1.100 + # If no `-o' option was seen then we might have been invoked from a
1.101 + # pattern rule where we don't need one. That is ok -- this is a
1.102 + # normal compilation that the losing compiler can handle. If no
1.103 + # `.c' file was seen then we are probably linking. That is also
1.104 + # ok.
1.105 + exec "$@"
1.106 +fi
1.107 +
1.108 +# Name of file we expect compiler to create.
1.109 +cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
1.110 +
1.111 +# Create the lock directory.
1.112 +# Note: use `[/.-]' here to ensure that we don't use the same name
1.113 +# that we are using for the .o file. Also, base the name on the expected
1.114 +# object file name, since that is what matters with a parallel build.
1.115 +lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
1.116 +while true; do
1.117 + if mkdir "$lockdir" >/dev/null 2>&1; then
1.118 + break
1.119 + fi
1.120 + sleep 1
1.121 +done
1.122 +# FIXME: race condition here if user kills between mkdir and trap.
1.123 +trap "rmdir '$lockdir'; exit 1" 1 2 15
1.124 +
1.125 +# Run the compile.
1.126 +"$@"
1.127 +ret=$?
1.128 +
1.129 +if test -f "$cofile"; then
1.130 + mv "$cofile" "$ofile"
1.131 +elif test -f "${cofile}bj"; then
1.132 + mv "${cofile}bj" "$ofile"
1.133 +fi
1.134 +
1.135 +rmdir "$lockdir"
1.136 +exit $ret
1.137 +
1.138 +# Local Variables:
1.139 +# mode: shell-script
1.140 +# sh-indentation: 2
1.141 +# eval: (add-hook 'write-file-hooks 'time-stamp)
1.142 +# time-stamp-start: "scriptversion="
1.143 +# time-stamp-format: "%:y-%02m-%02d.%02H"
1.144 +# time-stamp-end: "$"
1.145 +# End: