1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/crashreporter/google-breakpad/autotools/compile Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,343 @@ 1.4 +#! /bin/sh 1.5 +# Wrapper for compilers which do not understand '-c -o'. 1.6 + 1.7 +scriptversion=2012-03-05.13; # UTC 1.8 + 1.9 +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free 1.10 +# Software Foundation, Inc. 1.11 +# Written by Tom Tromey <tromey@cygnus.com>. 1.12 +# 1.13 +# This program is free software; you can redistribute it and/or modify 1.14 +# it under the terms of the GNU General Public License as published by 1.15 +# the Free Software Foundation; either version 2, or (at your option) 1.16 +# any later version. 1.17 +# 1.18 +# This program is distributed in the hope that it will be useful, 1.19 +# but WITHOUT ANY WARRANTY; without even the implied warranty of 1.20 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1.21 +# GNU General Public License for more details. 1.22 +# 1.23 +# You should have received a copy of the GNU General Public License 1.24 +# along with this program. If not, see <http://www.gnu.org/licenses/>. 1.25 + 1.26 +# As a special exception to the GNU General Public License, if you 1.27 +# distribute this file as part of a program that contains a 1.28 +# configuration script generated by Autoconf, you may include it under 1.29 +# the same distribution terms that you use for the rest of that program. 1.30 + 1.31 +# This file is maintained in Automake, please report 1.32 +# bugs to <bug-automake@gnu.org> or send patches to 1.33 +# <automake-patches@gnu.org>. 1.34 + 1.35 +nl=' 1.36 +' 1.37 + 1.38 +# We need space, tab and new line, in precisely that order. Quoting is 1.39 +# there to prevent tools from complaining about whitespace usage. 1.40 +IFS=" "" $nl" 1.41 + 1.42 +file_conv= 1.43 + 1.44 +# func_file_conv build_file lazy 1.45 +# Convert a $build file to $host form and store it in $file 1.46 +# Currently only supports Windows hosts. If the determined conversion 1.47 +# type is listed in (the comma separated) LAZY, no conversion will 1.48 +# take place. 1.49 +func_file_conv () 1.50 +{ 1.51 + file=$1 1.52 + case $file in 1.53 + / | /[!/]*) # absolute file, and not a UNC file 1.54 + if test -z "$file_conv"; then 1.55 + # lazily determine how to convert abs files 1.56 + case `uname -s` in 1.57 + MINGW*) 1.58 + file_conv=mingw 1.59 + ;; 1.60 + CYGWIN*) 1.61 + file_conv=cygwin 1.62 + ;; 1.63 + *) 1.64 + file_conv=wine 1.65 + ;; 1.66 + esac 1.67 + fi 1.68 + case $file_conv/,$2, in 1.69 + *,$file_conv,*) 1.70 + ;; 1.71 + mingw/*) 1.72 + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` 1.73 + ;; 1.74 + cygwin/*) 1.75 + file=`cygpath -m "$file" || echo "$file"` 1.76 + ;; 1.77 + wine/*) 1.78 + file=`winepath -w "$file" || echo "$file"` 1.79 + ;; 1.80 + esac 1.81 + ;; 1.82 + esac 1.83 +} 1.84 + 1.85 +# func_cl_dashL linkdir 1.86 +# Make cl look for libraries in LINKDIR 1.87 +func_cl_dashL () 1.88 +{ 1.89 + func_file_conv "$1" 1.90 + if test -z "$lib_path"; then 1.91 + lib_path=$file 1.92 + else 1.93 + lib_path="$lib_path;$file" 1.94 + fi 1.95 + linker_opts="$linker_opts -LIBPATH:$file" 1.96 +} 1.97 + 1.98 +# func_cl_dashl library 1.99 +# Do a library search-path lookup for cl 1.100 +func_cl_dashl () 1.101 +{ 1.102 + lib=$1 1.103 + found=no 1.104 + save_IFS=$IFS 1.105 + IFS=';' 1.106 + for dir in $lib_path $LIB 1.107 + do 1.108 + IFS=$save_IFS 1.109 + if $shared && test -f "$dir/$lib.dll.lib"; then 1.110 + found=yes 1.111 + lib=$dir/$lib.dll.lib 1.112 + break 1.113 + fi 1.114 + if test -f "$dir/$lib.lib"; then 1.115 + found=yes 1.116 + lib=$dir/$lib.lib 1.117 + break 1.118 + fi 1.119 + done 1.120 + IFS=$save_IFS 1.121 + 1.122 + if test "$found" != yes; then 1.123 + lib=$lib.lib 1.124 + fi 1.125 +} 1.126 + 1.127 +# func_cl_wrapper cl arg... 1.128 +# Adjust compile command to suit cl 1.129 +func_cl_wrapper () 1.130 +{ 1.131 + # Assume a capable shell 1.132 + lib_path= 1.133 + shared=: 1.134 + linker_opts= 1.135 + for arg 1.136 + do 1.137 + if test -n "$eat"; then 1.138 + eat= 1.139 + else 1.140 + case $1 in 1.141 + -o) 1.142 + # configure might choose to run compile as 'compile cc -o foo foo.c'. 1.143 + eat=1 1.144 + case $2 in 1.145 + *.o | *.[oO][bB][jJ]) 1.146 + func_file_conv "$2" 1.147 + set x "$@" -Fo"$file" 1.148 + shift 1.149 + ;; 1.150 + *) 1.151 + func_file_conv "$2" 1.152 + set x "$@" -Fe"$file" 1.153 + shift 1.154 + ;; 1.155 + esac 1.156 + ;; 1.157 + -I) 1.158 + eat=1 1.159 + func_file_conv "$2" mingw 1.160 + set x "$@" -I"$file" 1.161 + shift 1.162 + ;; 1.163 + -I*) 1.164 + func_file_conv "${1#-I}" mingw 1.165 + set x "$@" -I"$file" 1.166 + shift 1.167 + ;; 1.168 + -l) 1.169 + eat=1 1.170 + func_cl_dashl "$2" 1.171 + set x "$@" "$lib" 1.172 + shift 1.173 + ;; 1.174 + -l*) 1.175 + func_cl_dashl "${1#-l}" 1.176 + set x "$@" "$lib" 1.177 + shift 1.178 + ;; 1.179 + -L) 1.180 + eat=1 1.181 + func_cl_dashL "$2" 1.182 + ;; 1.183 + -L*) 1.184 + func_cl_dashL "${1#-L}" 1.185 + ;; 1.186 + -static) 1.187 + shared=false 1.188 + ;; 1.189 + -Wl,*) 1.190 + arg=${1#-Wl,} 1.191 + save_ifs="$IFS"; IFS=',' 1.192 + for flag in $arg; do 1.193 + IFS="$save_ifs" 1.194 + linker_opts="$linker_opts $flag" 1.195 + done 1.196 + IFS="$save_ifs" 1.197 + ;; 1.198 + -Xlinker) 1.199 + eat=1 1.200 + linker_opts="$linker_opts $2" 1.201 + ;; 1.202 + -*) 1.203 + set x "$@" "$1" 1.204 + shift 1.205 + ;; 1.206 + *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) 1.207 + func_file_conv "$1" 1.208 + set x "$@" -Tp"$file" 1.209 + shift 1.210 + ;; 1.211 + *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) 1.212 + func_file_conv "$1" mingw 1.213 + set x "$@" "$file" 1.214 + shift 1.215 + ;; 1.216 + *) 1.217 + set x "$@" "$1" 1.218 + shift 1.219 + ;; 1.220 + esac 1.221 + fi 1.222 + shift 1.223 + done 1.224 + if test -n "$linker_opts"; then 1.225 + linker_opts="-link$linker_opts" 1.226 + fi 1.227 + exec "$@" $linker_opts 1.228 + exit 1 1.229 +} 1.230 + 1.231 +eat= 1.232 + 1.233 +case $1 in 1.234 + '') 1.235 + echo "$0: No command. Try '$0 --help' for more information." 1>&2 1.236 + exit 1; 1.237 + ;; 1.238 + -h | --h*) 1.239 + cat <<\EOF 1.240 +Usage: compile [--help] [--version] PROGRAM [ARGS] 1.241 + 1.242 +Wrapper for compilers which do not understand '-c -o'. 1.243 +Remove '-o dest.o' from ARGS, run PROGRAM with the remaining 1.244 +arguments, and rename the output as expected. 1.245 + 1.246 +If you are trying to build a whole package this is not the 1.247 +right script to run: please start by reading the file 'INSTALL'. 1.248 + 1.249 +Report bugs to <bug-automake@gnu.org>. 1.250 +EOF 1.251 + exit $? 1.252 + ;; 1.253 + -v | --v*) 1.254 + echo "compile $scriptversion" 1.255 + exit $? 1.256 + ;; 1.257 + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) 1.258 + func_cl_wrapper "$@" # Doesn't return... 1.259 + ;; 1.260 +esac 1.261 + 1.262 +ofile= 1.263 +cfile= 1.264 + 1.265 +for arg 1.266 +do 1.267 + if test -n "$eat"; then 1.268 + eat= 1.269 + else 1.270 + case $1 in 1.271 + -o) 1.272 + # configure might choose to run compile as 'compile cc -o foo foo.c'. 1.273 + # So we strip '-o arg' only if arg is an object. 1.274 + eat=1 1.275 + case $2 in 1.276 + *.o | *.obj) 1.277 + ofile=$2 1.278 + ;; 1.279 + *) 1.280 + set x "$@" -o "$2" 1.281 + shift 1.282 + ;; 1.283 + esac 1.284 + ;; 1.285 + *.c) 1.286 + cfile=$1 1.287 + set x "$@" "$1" 1.288 + shift 1.289 + ;; 1.290 + *) 1.291 + set x "$@" "$1" 1.292 + shift 1.293 + ;; 1.294 + esac 1.295 + fi 1.296 + shift 1.297 +done 1.298 + 1.299 +if test -z "$ofile" || test -z "$cfile"; then 1.300 + # If no '-o' option was seen then we might have been invoked from a 1.301 + # pattern rule where we don't need one. That is ok -- this is a 1.302 + # normal compilation that the losing compiler can handle. If no 1.303 + # '.c' file was seen then we are probably linking. That is also 1.304 + # ok. 1.305 + exec "$@" 1.306 +fi 1.307 + 1.308 +# Name of file we expect compiler to create. 1.309 +cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` 1.310 + 1.311 +# Create the lock directory. 1.312 +# Note: use '[/\\:.-]' here to ensure that we don't use the same name 1.313 +# that we are using for the .o file. Also, base the name on the expected 1.314 +# object file name, since that is what matters with a parallel build. 1.315 +lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d 1.316 +while true; do 1.317 + if mkdir "$lockdir" >/dev/null 2>&1; then 1.318 + break 1.319 + fi 1.320 + sleep 1 1.321 +done 1.322 +# FIXME: race condition here if user kills between mkdir and trap. 1.323 +trap "rmdir '$lockdir'; exit 1" 1 2 15 1.324 + 1.325 +# Run the compile. 1.326 +"$@" 1.327 +ret=$? 1.328 + 1.329 +if test -f "$cofile"; then 1.330 + test "$cofile" = "$ofile" || mv "$cofile" "$ofile" 1.331 +elif test -f "${cofile}bj"; then 1.332 + test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" 1.333 +fi 1.334 + 1.335 +rmdir "$lockdir" 1.336 +exit $ret 1.337 + 1.338 +# Local Variables: 1.339 +# mode: shell-script 1.340 +# sh-indentation: 2 1.341 +# eval: (add-hook 'write-file-hooks 'time-stamp) 1.342 +# time-stamp-start: "scriptversion=" 1.343 +# time-stamp-format: "%:y-%02m-%02d.%02H" 1.344 +# time-stamp-time-zone: "UTC" 1.345 +# time-stamp-end: "; # UTC" 1.346 +# End: