annotate src/libsndfile-1.0.27/Cfg/compile @ 125:cd6cdf86811e

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