annotate src/libsamplerate-0.1.9/Cfg/compile @ 41:481f5f8c5634

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