annotate src/libsndfile-1.0.27/Cfg/compile @ 40:1df64224f5ac

Current libsndfile source
author Chris Cannam
date Tue, 18 Oct 2016 13:22:47 +0100
parents
children
rev   line source
Chris@40 1 #! /bin/sh
Chris@40 2 # Wrapper for compilers which do not understand '-c -o'.
Chris@40 3
Chris@40 4 scriptversion=2012-10-14.11; # UTC
Chris@40 5
Chris@40 6 # Copyright (C) 1999-2014 Free Software Foundation, Inc.
Chris@40 7 # Written by Tom Tromey <tromey@cygnus.com>.
Chris@40 8 #
Chris@40 9 # This program is free software; you can redistribute it and/or modify
Chris@40 10 # it under the terms of the GNU General Public License as published by
Chris@40 11 # the Free Software Foundation; either version 2, or (at your option)
Chris@40 12 # any later version.
Chris@40 13 #
Chris@40 14 # This program is distributed in the hope that it will be useful,
Chris@40 15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@40 16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@40 17 # GNU General Public License for more details.
Chris@40 18 #
Chris@40 19 # You should have received a copy of the GNU General Public License
Chris@40 20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@40 21
Chris@40 22 # As a special exception to the GNU General Public License, if you
Chris@40 23 # distribute this file as part of a program that contains a
Chris@40 24 # configuration script generated by Autoconf, you may include it under
Chris@40 25 # the same distribution terms that you use for the rest of that program.
Chris@40 26
Chris@40 27 # This file is maintained in Automake, please report
Chris@40 28 # bugs to <bug-automake@gnu.org> or send patches to
Chris@40 29 # <automake-patches@gnu.org>.
Chris@40 30
Chris@40 31 nl='
Chris@40 32 '
Chris@40 33
Chris@40 34 # We need space, tab and new line, in precisely that order. Quoting is
Chris@40 35 # there to prevent tools from complaining about whitespace usage.
Chris@40 36 IFS=" "" $nl"
Chris@40 37
Chris@40 38 file_conv=
Chris@40 39
Chris@40 40 # func_file_conv build_file lazy
Chris@40 41 # Convert a $build file to $host form and store it in $file
Chris@40 42 # Currently only supports Windows hosts. If the determined conversion
Chris@40 43 # type is listed in (the comma separated) LAZY, no conversion will
Chris@40 44 # take place.
Chris@40 45 func_file_conv ()
Chris@40 46 {
Chris@40 47 file=$1
Chris@40 48 case $file in
Chris@40 49 / | /[!/]*) # absolute file, and not a UNC file
Chris@40 50 if test -z "$file_conv"; then
Chris@40 51 # lazily determine how to convert abs files
Chris@40 52 case `uname -s` in
Chris@40 53 MINGW*)
Chris@40 54 file_conv=mingw
Chris@40 55 ;;
Chris@40 56 CYGWIN*)
Chris@40 57 file_conv=cygwin
Chris@40 58 ;;
Chris@40 59 *)
Chris@40 60 file_conv=wine
Chris@40 61 ;;
Chris@40 62 esac
Chris@40 63 fi
Chris@40 64 case $file_conv/,$2, in
Chris@40 65 *,$file_conv,*)
Chris@40 66 ;;
Chris@40 67 mingw/*)
Chris@40 68 file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
Chris@40 69 ;;
Chris@40 70 cygwin/*)
Chris@40 71 file=`cygpath -m "$file" || echo "$file"`
Chris@40 72 ;;
Chris@40 73 wine/*)
Chris@40 74 file=`winepath -w "$file" || echo "$file"`
Chris@40 75 ;;
Chris@40 76 esac
Chris@40 77 ;;
Chris@40 78 esac
Chris@40 79 }
Chris@40 80
Chris@40 81 # func_cl_dashL linkdir
Chris@40 82 # Make cl look for libraries in LINKDIR
Chris@40 83 func_cl_dashL ()
Chris@40 84 {
Chris@40 85 func_file_conv "$1"
Chris@40 86 if test -z "$lib_path"; then
Chris@40 87 lib_path=$file
Chris@40 88 else
Chris@40 89 lib_path="$lib_path;$file"
Chris@40 90 fi
Chris@40 91 linker_opts="$linker_opts -LIBPATH:$file"
Chris@40 92 }
Chris@40 93
Chris@40 94 # func_cl_dashl library
Chris@40 95 # Do a library search-path lookup for cl
Chris@40 96 func_cl_dashl ()
Chris@40 97 {
Chris@40 98 lib=$1
Chris@40 99 found=no
Chris@40 100 save_IFS=$IFS
Chris@40 101 IFS=';'
Chris@40 102 for dir in $lib_path $LIB
Chris@40 103 do
Chris@40 104 IFS=$save_IFS
Chris@40 105 if $shared && test -f "$dir/$lib.dll.lib"; then
Chris@40 106 found=yes
Chris@40 107 lib=$dir/$lib.dll.lib
Chris@40 108 break
Chris@40 109 fi
Chris@40 110 if test -f "$dir/$lib.lib"; then
Chris@40 111 found=yes
Chris@40 112 lib=$dir/$lib.lib
Chris@40 113 break
Chris@40 114 fi
Chris@40 115 if test -f "$dir/lib$lib.a"; then
Chris@40 116 found=yes
Chris@40 117 lib=$dir/lib$lib.a
Chris@40 118 break
Chris@40 119 fi
Chris@40 120 done
Chris@40 121 IFS=$save_IFS
Chris@40 122
Chris@40 123 if test "$found" != yes; then
Chris@40 124 lib=$lib.lib
Chris@40 125 fi
Chris@40 126 }
Chris@40 127
Chris@40 128 # func_cl_wrapper cl arg...
Chris@40 129 # Adjust compile command to suit cl
Chris@40 130 func_cl_wrapper ()
Chris@40 131 {
Chris@40 132 # Assume a capable shell
Chris@40 133 lib_path=
Chris@40 134 shared=:
Chris@40 135 linker_opts=
Chris@40 136 for arg
Chris@40 137 do
Chris@40 138 if test -n "$eat"; then
Chris@40 139 eat=
Chris@40 140 else
Chris@40 141 case $1 in
Chris@40 142 -o)
Chris@40 143 # configure might choose to run compile as 'compile cc -o foo foo.c'.
Chris@40 144 eat=1
Chris@40 145 case $2 in
Chris@40 146 *.o | *.[oO][bB][jJ])
Chris@40 147 func_file_conv "$2"
Chris@40 148 set x "$@" -Fo"$file"
Chris@40 149 shift
Chris@40 150 ;;
Chris@40 151 *)
Chris@40 152 func_file_conv "$2"
Chris@40 153 set x "$@" -Fe"$file"
Chris@40 154 shift
Chris@40 155 ;;
Chris@40 156 esac
Chris@40 157 ;;
Chris@40 158 -I)
Chris@40 159 eat=1
Chris@40 160 func_file_conv "$2" mingw
Chris@40 161 set x "$@" -I"$file"
Chris@40 162 shift
Chris@40 163 ;;
Chris@40 164 -I*)
Chris@40 165 func_file_conv "${1#-I}" mingw
Chris@40 166 set x "$@" -I"$file"
Chris@40 167 shift
Chris@40 168 ;;
Chris@40 169 -l)
Chris@40 170 eat=1
Chris@40 171 func_cl_dashl "$2"
Chris@40 172 set x "$@" "$lib"
Chris@40 173 shift
Chris@40 174 ;;
Chris@40 175 -l*)
Chris@40 176 func_cl_dashl "${1#-l}"
Chris@40 177 set x "$@" "$lib"
Chris@40 178 shift
Chris@40 179 ;;
Chris@40 180 -L)
Chris@40 181 eat=1
Chris@40 182 func_cl_dashL "$2"
Chris@40 183 ;;
Chris@40 184 -L*)
Chris@40 185 func_cl_dashL "${1#-L}"
Chris@40 186 ;;
Chris@40 187 -static)
Chris@40 188 shared=false
Chris@40 189 ;;
Chris@40 190 -Wl,*)
Chris@40 191 arg=${1#-Wl,}
Chris@40 192 save_ifs="$IFS"; IFS=','
Chris@40 193 for flag in $arg; do
Chris@40 194 IFS="$save_ifs"
Chris@40 195 linker_opts="$linker_opts $flag"
Chris@40 196 done
Chris@40 197 IFS="$save_ifs"
Chris@40 198 ;;
Chris@40 199 -Xlinker)
Chris@40 200 eat=1
Chris@40 201 linker_opts="$linker_opts $2"
Chris@40 202 ;;
Chris@40 203 -*)
Chris@40 204 set x "$@" "$1"
Chris@40 205 shift
Chris@40 206 ;;
Chris@40 207 *.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
Chris@40 208 func_file_conv "$1"
Chris@40 209 set x "$@" -Tp"$file"
Chris@40 210 shift
Chris@40 211 ;;
Chris@40 212 *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
Chris@40 213 func_file_conv "$1" mingw
Chris@40 214 set x "$@" "$file"
Chris@40 215 shift
Chris@40 216 ;;
Chris@40 217 *)
Chris@40 218 set x "$@" "$1"
Chris@40 219 shift
Chris@40 220 ;;
Chris@40 221 esac
Chris@40 222 fi
Chris@40 223 shift
Chris@40 224 done
Chris@40 225 if test -n "$linker_opts"; then
Chris@40 226 linker_opts="-link$linker_opts"
Chris@40 227 fi
Chris@40 228 exec "$@" $linker_opts
Chris@40 229 exit 1
Chris@40 230 }
Chris@40 231
Chris@40 232 eat=
Chris@40 233
Chris@40 234 case $1 in
Chris@40 235 '')
Chris@40 236 echo "$0: No command. Try '$0 --help' for more information." 1>&2
Chris@40 237 exit 1;
Chris@40 238 ;;
Chris@40 239 -h | --h*)
Chris@40 240 cat <<\EOF
Chris@40 241 Usage: compile [--help] [--version] PROGRAM [ARGS]
Chris@40 242
Chris@40 243 Wrapper for compilers which do not understand '-c -o'.
Chris@40 244 Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
Chris@40 245 arguments, and rename the output as expected.
Chris@40 246
Chris@40 247 If you are trying to build a whole package this is not the
Chris@40 248 right script to run: please start by reading the file 'INSTALL'.
Chris@40 249
Chris@40 250 Report bugs to <bug-automake@gnu.org>.
Chris@40 251 EOF
Chris@40 252 exit $?
Chris@40 253 ;;
Chris@40 254 -v | --v*)
Chris@40 255 echo "compile $scriptversion"
Chris@40 256 exit $?
Chris@40 257 ;;
Chris@40 258 cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
Chris@40 259 func_cl_wrapper "$@" # Doesn't return...
Chris@40 260 ;;
Chris@40 261 esac
Chris@40 262
Chris@40 263 ofile=
Chris@40 264 cfile=
Chris@40 265
Chris@40 266 for arg
Chris@40 267 do
Chris@40 268 if test -n "$eat"; then
Chris@40 269 eat=
Chris@40 270 else
Chris@40 271 case $1 in
Chris@40 272 -o)
Chris@40 273 # configure might choose to run compile as 'compile cc -o foo foo.c'.
Chris@40 274 # So we strip '-o arg' only if arg is an object.
Chris@40 275 eat=1
Chris@40 276 case $2 in
Chris@40 277 *.o | *.obj)
Chris@40 278 ofile=$2
Chris@40 279 ;;
Chris@40 280 *)
Chris@40 281 set x "$@" -o "$2"
Chris@40 282 shift
Chris@40 283 ;;
Chris@40 284 esac
Chris@40 285 ;;
Chris@40 286 *.c)
Chris@40 287 cfile=$1
Chris@40 288 set x "$@" "$1"
Chris@40 289 shift
Chris@40 290 ;;
Chris@40 291 *)
Chris@40 292 set x "$@" "$1"
Chris@40 293 shift
Chris@40 294 ;;
Chris@40 295 esac
Chris@40 296 fi
Chris@40 297 shift
Chris@40 298 done
Chris@40 299
Chris@40 300 if test -z "$ofile" || test -z "$cfile"; then
Chris@40 301 # If no '-o' option was seen then we might have been invoked from a
Chris@40 302 # pattern rule where we don't need one. That is ok -- this is a
Chris@40 303 # normal compilation that the losing compiler can handle. If no
Chris@40 304 # '.c' file was seen then we are probably linking. That is also
Chris@40 305 # ok.
Chris@40 306 exec "$@"
Chris@40 307 fi
Chris@40 308
Chris@40 309 # Name of file we expect compiler to create.
Chris@40 310 cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
Chris@40 311
Chris@40 312 # Create the lock directory.
Chris@40 313 # Note: use '[/\\:.-]' here to ensure that we don't use the same name
Chris@40 314 # that we are using for the .o file. Also, base the name on the expected
Chris@40 315 # object file name, since that is what matters with a parallel build.
Chris@40 316 lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
Chris@40 317 while true; do
Chris@40 318 if mkdir "$lockdir" >/dev/null 2>&1; then
Chris@40 319 break
Chris@40 320 fi
Chris@40 321 sleep 1
Chris@40 322 done
Chris@40 323 # FIXME: race condition here if user kills between mkdir and trap.
Chris@40 324 trap "rmdir '$lockdir'; exit 1" 1 2 15
Chris@40 325
Chris@40 326 # Run the compile.
Chris@40 327 "$@"
Chris@40 328 ret=$?
Chris@40 329
Chris@40 330 if test -f "$cofile"; then
Chris@40 331 test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
Chris@40 332 elif test -f "${cofile}bj"; then
Chris@40 333 test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
Chris@40 334 fi
Chris@40 335
Chris@40 336 rmdir "$lockdir"
Chris@40 337 exit $ret
Chris@40 338
Chris@40 339 # Local Variables:
Chris@40 340 # mode: shell-script
Chris@40 341 # sh-indentation: 2
Chris@40 342 # eval: (add-hook 'write-file-hooks 'time-stamp)
Chris@40 343 # time-stamp-start: "scriptversion="
Chris@40 344 # time-stamp-format: "%:y-%02m-%02d.%02H"
Chris@40 345 # time-stamp-time-zone: "UTC"
Chris@40 346 # time-stamp-end: "; # UTC"
Chris@40 347 # End: