annotate src/opus-1.3/compile @ 83:ae30d91d2ffe

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