annotate src/libsndfile-1.0.25/Cfg/compile @ 0:c7265573341e

Import initial set of sources
author Chris Cannam
date Mon, 18 Mar 2013 14:12:14 +0000
parents
children
rev   line source
Chris@0 1 #! /bin/sh
Chris@0 2 # Wrapper for compilers which do not understand `-c -o'.
Chris@0 3
Chris@0 4 scriptversion=2009-04-28.21; # UTC
Chris@0 5
Chris@0 6 # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software
Chris@0 7 # Foundation, Inc.
Chris@0 8 # Written by Tom Tromey <tromey@cygnus.com>.
Chris@0 9 #
Chris@0 10 # This program is free software; you can redistribute it and/or modify
Chris@0 11 # it under the terms of the GNU General Public License as published by
Chris@0 12 # the Free Software Foundation; either version 2, or (at your option)
Chris@0 13 # any later version.
Chris@0 14 #
Chris@0 15 # This program is distributed in the hope that it will be useful,
Chris@0 16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 18 # GNU General Public License for more details.
Chris@0 19 #
Chris@0 20 # You should have received a copy of the GNU General Public License
Chris@0 21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@0 22
Chris@0 23 # As a special exception to the GNU General Public License, if you
Chris@0 24 # distribute this file as part of a program that contains a
Chris@0 25 # configuration script generated by Autoconf, you may include it under
Chris@0 26 # the same distribution terms that you use for the rest of that program.
Chris@0 27
Chris@0 28 # This file is maintained in Automake, please report
Chris@0 29 # bugs to <bug-automake@gnu.org> or send patches to
Chris@0 30 # <automake-patches@gnu.org>.
Chris@0 31
Chris@0 32 case $1 in
Chris@0 33 '')
Chris@0 34 echo "$0: No command. Try \`$0 --help' for more information." 1>&2
Chris@0 35 exit 1;
Chris@0 36 ;;
Chris@0 37 -h | --h*)
Chris@0 38 cat <<\EOF
Chris@0 39 Usage: compile [--help] [--version] PROGRAM [ARGS]
Chris@0 40
Chris@0 41 Wrapper for compilers which do not understand `-c -o'.
Chris@0 42 Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
Chris@0 43 arguments, and rename the output as expected.
Chris@0 44
Chris@0 45 If you are trying to build a whole package this is not the
Chris@0 46 right script to run: please start by reading the file `INSTALL'.
Chris@0 47
Chris@0 48 Report bugs to <bug-automake@gnu.org>.
Chris@0 49 EOF
Chris@0 50 exit $?
Chris@0 51 ;;
Chris@0 52 -v | --v*)
Chris@0 53 echo "compile $scriptversion"
Chris@0 54 exit $?
Chris@0 55 ;;
Chris@0 56 esac
Chris@0 57
Chris@0 58 ofile=
Chris@0 59 cfile=
Chris@0 60 eat=
Chris@0 61
Chris@0 62 for arg
Chris@0 63 do
Chris@0 64 if test -n "$eat"; then
Chris@0 65 eat=
Chris@0 66 else
Chris@0 67 case $1 in
Chris@0 68 -o)
Chris@0 69 # configure might choose to run compile as `compile cc -o foo foo.c'.
Chris@0 70 # So we strip `-o arg' only if arg is an object.
Chris@0 71 eat=1
Chris@0 72 case $2 in
Chris@0 73 *.o | *.obj)
Chris@0 74 ofile=$2
Chris@0 75 ;;
Chris@0 76 *)
Chris@0 77 set x "$@" -o "$2"
Chris@0 78 shift
Chris@0 79 ;;
Chris@0 80 esac
Chris@0 81 ;;
Chris@0 82 *.c)
Chris@0 83 cfile=$1
Chris@0 84 set x "$@" "$1"
Chris@0 85 shift
Chris@0 86 ;;
Chris@0 87 *)
Chris@0 88 set x "$@" "$1"
Chris@0 89 shift
Chris@0 90 ;;
Chris@0 91 esac
Chris@0 92 fi
Chris@0 93 shift
Chris@0 94 done
Chris@0 95
Chris@0 96 if test -z "$ofile" || test -z "$cfile"; then
Chris@0 97 # If no `-o' option was seen then we might have been invoked from a
Chris@0 98 # pattern rule where we don't need one. That is ok -- this is a
Chris@0 99 # normal compilation that the losing compiler can handle. If no
Chris@0 100 # `.c' file was seen then we are probably linking. That is also
Chris@0 101 # ok.
Chris@0 102 exec "$@"
Chris@0 103 fi
Chris@0 104
Chris@0 105 # Name of file we expect compiler to create.
Chris@0 106 cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
Chris@0 107
Chris@0 108 # Create the lock directory.
Chris@0 109 # Note: use `[/\\:.-]' here to ensure that we don't use the same name
Chris@0 110 # that we are using for the .o file. Also, base the name on the expected
Chris@0 111 # object file name, since that is what matters with a parallel build.
Chris@0 112 lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
Chris@0 113 while true; do
Chris@0 114 if mkdir "$lockdir" >/dev/null 2>&1; then
Chris@0 115 break
Chris@0 116 fi
Chris@0 117 sleep 1
Chris@0 118 done
Chris@0 119 # FIXME: race condition here if user kills between mkdir and trap.
Chris@0 120 trap "rmdir '$lockdir'; exit 1" 1 2 15
Chris@0 121
Chris@0 122 # Run the compile.
Chris@0 123 "$@"
Chris@0 124 ret=$?
Chris@0 125
Chris@0 126 if test -f "$cofile"; then
Chris@0 127 mv "$cofile" "$ofile"
Chris@0 128 elif test -f "${cofile}bj"; then
Chris@0 129 mv "${cofile}bj" "$ofile"
Chris@0 130 fi
Chris@0 131
Chris@0 132 rmdir "$lockdir"
Chris@0 133 exit $ret
Chris@0 134
Chris@0 135 # Local Variables:
Chris@0 136 # mode: shell-script
Chris@0 137 # sh-indentation: 2
Chris@0 138 # eval: (add-hook 'write-file-hooks 'time-stamp)
Chris@0 139 # time-stamp-start: "scriptversion="
Chris@0 140 # time-stamp-format: "%:y-%02m-%02d.%02H"
Chris@0 141 # time-stamp-time-zone: "UTC"
Chris@0 142 # time-stamp-end: "; # UTC"
Chris@0 143 # End: