annotate src/fftw-3.3.5/compile @ 42:2cd0e3b3e1fd

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