11.1Spooka#! /bin/sh 21.1Spooka# Wrapper for compilers which do not understand '-c -o'. 31.1Spooka 41.1Spookascriptversion=2012-10-14.11; # UTC 51.1Spooka 61.1Spooka# Copyright (C) 1999-2013 Free Software Foundation, Inc. 71.1Spooka# Written by Tom Tromey <tromey@cygnus.com>. 81.1Spooka# 91.1Spooka# This program is free software; you can redistribute it and/or modify 101.1Spooka# it under the terms of the GNU General Public License as published by 111.1Spooka# the Free Software Foundation; either version 2, or (at your option) 121.1Spooka# any later version. 131.1Spooka# 141.1Spooka# This program is distributed in the hope that it will be useful, 151.1Spooka# but WITHOUT ANY WARRANTY; without even the implied warranty of 161.1Spooka# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 171.1Spooka# GNU General Public License for more details. 181.1Spooka# 191.1Spooka# You should have received a copy of the GNU General Public License 201.1Spooka# along with this program. If not, see <http://www.gnu.org/licenses/>. 211.1Spooka 221.1Spooka# As a special exception to the GNU General Public License, if you 231.1Spooka# distribute this file as part of a program that contains a 241.1Spooka# configuration script generated by Autoconf, you may include it under 251.1Spooka# the same distribution terms that you use for the rest of that program. 261.1Spooka 271.1Spooka# This file is maintained in Automake, please report 281.1Spooka# bugs to <bug-automake@gnu.org> or send patches to 291.1Spooka# <automake-patches@gnu.org>. 301.1Spooka 311.1Spookanl=' 321.1Spooka' 331.1Spooka 341.1Spooka# We need space, tab and new line, in precisely that order. Quoting is 351.1Spooka# there to prevent tools from complaining about whitespace usage. 361.1SpookaIFS=" "" $nl" 371.1Spooka 381.1Spookafile_conv= 391.1Spooka 401.1Spooka# func_file_conv build_file lazy 411.1Spooka# Convert a $build file to $host form and store it in $file 421.1Spooka# Currently only supports Windows hosts. If the determined conversion 431.1Spooka# type is listed in (the comma separated) LAZY, no conversion will 441.1Spooka# take place. 451.1Spookafunc_file_conv () 461.1Spooka{ 471.1Spooka file=$1 481.1Spooka case $file in 491.1Spooka / | /[!/]*) # absolute file, and not a UNC file 501.1Spooka if test -z "$file_conv"; then 511.1Spooka # lazily determine how to convert abs files 521.1Spooka case `uname -s` in 531.1Spooka MINGW*) 541.1Spooka file_conv=mingw 551.1Spooka ;; 561.1Spooka CYGWIN*) 571.1Spooka file_conv=cygwin 581.1Spooka ;; 591.1Spooka *) 601.1Spooka file_conv=wine 611.1Spooka ;; 621.1Spooka esac 631.1Spooka fi 641.1Spooka case $file_conv/,$2, in 651.1Spooka *,$file_conv,*) 661.1Spooka ;; 671.1Spooka mingw/*) 681.1Spooka file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` 691.1Spooka ;; 701.1Spooka cygwin/*) 711.1Spooka file=`cygpath -m "$file" || echo "$file"` 721.1Spooka ;; 731.1Spooka wine/*) 741.1Spooka file=`winepath -w "$file" || echo "$file"` 751.1Spooka ;; 761.1Spooka esac 771.1Spooka ;; 781.1Spooka esac 791.1Spooka} 801.1Spooka 811.1Spooka# func_cl_dashL linkdir 821.1Spooka# Make cl look for libraries in LINKDIR 831.1Spookafunc_cl_dashL () 841.1Spooka{ 851.1Spooka func_file_conv "$1" 861.1Spooka if test -z "$lib_path"; then 871.1Spooka lib_path=$file 881.1Spooka else 891.1Spooka lib_path="$lib_path;$file" 901.1Spooka fi 911.1Spooka linker_opts="$linker_opts -LIBPATH:$file" 921.1Spooka} 931.1Spooka 941.1Spooka# func_cl_dashl library 951.1Spooka# Do a library search-path lookup for cl 961.1Spookafunc_cl_dashl () 971.1Spooka{ 981.1Spooka lib=$1 991.1Spooka found=no 1001.1Spooka save_IFS=$IFS 1011.1Spooka IFS=';' 1021.1Spooka for dir in $lib_path $LIB 1031.1Spooka do 1041.1Spooka IFS=$save_IFS 1051.1Spooka if $shared && test -f "$dir/$lib.dll.lib"; then 1061.1Spooka found=yes 1071.1Spooka lib=$dir/$lib.dll.lib 1081.1Spooka break 1091.1Spooka fi 1101.1Spooka if test -f "$dir/$lib.lib"; then 1111.1Spooka found=yes 1121.1Spooka lib=$dir/$lib.lib 1131.1Spooka break 1141.1Spooka fi 1151.1Spooka if test -f "$dir/lib$lib.a"; then 1161.1Spooka found=yes 1171.1Spooka lib=$dir/lib$lib.a 1181.1Spooka break 1191.1Spooka fi 1201.1Spooka done 1211.1Spooka IFS=$save_IFS 1221.1Spooka 1231.1Spooka if test "$found" != yes; then 1241.1Spooka lib=$lib.lib 1251.1Spooka fi 1261.1Spooka} 1271.1Spooka 1281.1Spooka# func_cl_wrapper cl arg... 1291.1Spooka# Adjust compile command to suit cl 1301.1Spookafunc_cl_wrapper () 1311.1Spooka{ 1321.1Spooka # Assume a capable shell 1331.1Spooka lib_path= 1341.1Spooka shared=: 1351.1Spooka linker_opts= 1361.1Spooka for arg 1371.1Spooka do 1381.1Spooka if test -n "$eat"; then 1391.1Spooka eat= 1401.1Spooka else 1411.1Spooka case $1 in 1421.1Spooka -o) 1431.1Spooka # configure might choose to run compile as 'compile cc -o foo foo.c'. 1441.1Spooka eat=1 1451.1Spooka case $2 in 1461.1Spooka *.o | *.[oO][bB][jJ]) 1471.1Spooka func_file_conv "$2" 1481.1Spooka set x "$@" -Fo"$file" 1491.1Spooka shift 1501.1Spooka ;; 1511.1Spooka *) 1521.1Spooka func_file_conv "$2" 1531.1Spooka set x "$@" -Fe"$file" 1541.1Spooka shift 1551.1Spooka ;; 1561.1Spooka esac 1571.1Spooka ;; 1581.1Spooka -I) 1591.1Spooka eat=1 1601.1Spooka func_file_conv "$2" mingw 1611.1Spooka set x "$@" -I"$file" 1621.1Spooka shift 1631.1Spooka ;; 1641.1Spooka -I*) 1651.1Spooka func_file_conv "${1#-I}" mingw 1661.1Spooka set x "$@" -I"$file" 1671.1Spooka shift 1681.1Spooka ;; 1691.1Spooka -l) 1701.1Spooka eat=1 1711.1Spooka func_cl_dashl "$2" 1721.1Spooka set x "$@" "$lib" 1731.1Spooka shift 1741.1Spooka ;; 1751.1Spooka -l*) 1761.1Spooka func_cl_dashl "${1#-l}" 1771.1Spooka set x "$@" "$lib" 1781.1Spooka shift 1791.1Spooka ;; 1801.1Spooka -L) 1811.1Spooka eat=1 1821.1Spooka func_cl_dashL "$2" 1831.1Spooka ;; 1841.1Spooka -L*) 1851.1Spooka func_cl_dashL "${1#-L}" 1861.1Spooka ;; 1871.1Spooka -static) 1881.1Spooka shared=false 1891.1Spooka ;; 1901.1Spooka -Wl,*) 1911.1Spooka arg=${1#-Wl,} 1921.1Spooka save_ifs="$IFS"; IFS=',' 1931.1Spooka for flag in $arg; do 1941.1Spooka IFS="$save_ifs" 1951.1Spooka linker_opts="$linker_opts $flag" 1961.1Spooka done 1971.1Spooka IFS="$save_ifs" 1981.1Spooka ;; 1991.1Spooka -Xlinker) 2001.1Spooka eat=1 2011.1Spooka linker_opts="$linker_opts $2" 2021.1Spooka ;; 2031.1Spooka -*) 2041.1Spooka set x "$@" "$1" 2051.1Spooka shift 2061.1Spooka ;; 2071.1Spooka *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) 2081.1Spooka func_file_conv "$1" 2091.1Spooka set x "$@" -Tp"$file" 2101.1Spooka shift 2111.1Spooka ;; 2121.1Spooka *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) 2131.1Spooka func_file_conv "$1" mingw 2141.1Spooka set x "$@" "$file" 2151.1Spooka shift 2161.1Spooka ;; 2171.1Spooka *) 2181.1Spooka set x "$@" "$1" 2191.1Spooka shift 2201.1Spooka ;; 2211.1Spooka esac 2221.1Spooka fi 2231.1Spooka shift 2241.1Spooka done 2251.1Spooka if test -n "$linker_opts"; then 2261.1Spooka linker_opts="-link$linker_opts" 2271.1Spooka fi 2281.1Spooka exec "$@" $linker_opts 2291.1Spooka exit 1 2301.1Spooka} 2311.1Spooka 2321.1Spookaeat= 2331.1Spooka 2341.1Spookacase $1 in 2351.1Spooka '') 2361.1Spooka echo "$0: No command. Try '$0 --help' for more information." 1>&2 2371.1Spooka exit 1; 2381.1Spooka ;; 2391.1Spooka -h | --h*) 2401.1Spooka cat <<\EOF 2411.1SpookaUsage: compile [--help] [--version] PROGRAM [ARGS] 2421.1Spooka 2431.1SpookaWrapper for compilers which do not understand '-c -o'. 2441.1SpookaRemove '-o dest.o' from ARGS, run PROGRAM with the remaining 2451.1Spookaarguments, and rename the output as expected. 2461.1Spooka 2471.1SpookaIf you are trying to build a whole package this is not the 2481.1Spookaright script to run: please start by reading the file 'INSTALL'. 2491.1Spooka 2501.1SpookaReport bugs to <bug-automake@gnu.org>. 2511.1SpookaEOF 2521.1Spooka exit $? 2531.1Spooka ;; 2541.1Spooka -v | --v*) 2551.1Spooka echo "compile $scriptversion" 2561.1Spooka exit $? 2571.1Spooka ;; 2581.1Spooka cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) 2591.1Spooka func_cl_wrapper "$@" # Doesn't return... 2601.1Spooka ;; 2611.1Spookaesac 2621.1Spooka 2631.1Spookaofile= 2641.1Spookacfile= 2651.1Spooka 2661.1Spookafor arg 2671.1Spookado 2681.1Spooka if test -n "$eat"; then 2691.1Spooka eat= 2701.1Spooka else 2711.1Spooka case $1 in 2721.1Spooka -o) 2731.1Spooka # configure might choose to run compile as 'compile cc -o foo foo.c'. 2741.1Spooka # So we strip '-o arg' only if arg is an object. 2751.1Spooka eat=1 2761.1Spooka case $2 in 2771.1Spooka *.o | *.obj) 2781.1Spooka ofile=$2 2791.1Spooka ;; 2801.1Spooka *) 2811.1Spooka set x "$@" -o "$2" 2821.1Spooka shift 2831.1Spooka ;; 2841.1Spooka esac 2851.1Spooka ;; 2861.1Spooka *.c) 2871.1Spooka cfile=$1 2881.1Spooka set x "$@" "$1" 2891.1Spooka shift 2901.1Spooka ;; 2911.1Spooka *) 2921.1Spooka set x "$@" "$1" 2931.1Spooka shift 2941.1Spooka ;; 2951.1Spooka esac 2961.1Spooka fi 2971.1Spooka shift 2981.1Spookadone 2991.1Spooka 3001.1Spookaif test -z "$ofile" || test -z "$cfile"; then 3011.1Spooka # If no '-o' option was seen then we might have been invoked from a 3021.1Spooka # pattern rule where we don't need one. That is ok -- this is a 3031.1Spooka # normal compilation that the losing compiler can handle. If no 3041.1Spooka # '.c' file was seen then we are probably linking. That is also 3051.1Spooka # ok. 3061.1Spooka exec "$@" 3071.1Spookafi 3081.1Spooka 3091.1Spooka# Name of file we expect compiler to create. 3101.1Spookacofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` 3111.1Spooka 3121.1Spooka# Create the lock directory. 3131.1Spooka# Note: use '[/\\:.-]' here to ensure that we don't use the same name 3141.1Spooka# that we are using for the .o file. Also, base the name on the expected 3151.1Spooka# object file name, since that is what matters with a parallel build. 3161.1Spookalockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d 3171.1Spookawhile true; do 3181.1Spooka if mkdir "$lockdir" >/dev/null 2>&1; then 3191.1Spooka break 3201.1Spooka fi 3211.1Spooka sleep 1 3221.1Spookadone 3231.1Spooka# FIXME: race condition here if user kills between mkdir and trap. 3241.1Spookatrap "rmdir '$lockdir'; exit 1" 1 2 15 3251.1Spooka 3261.1Spooka# Run the compile. 3271.1Spooka"$@" 3281.1Spookaret=$? 3291.1Spooka 3301.1Spookaif test -f "$cofile"; then 3311.1Spooka test "$cofile" = "$ofile" || mv "$cofile" "$ofile" 3321.1Spookaelif test -f "${cofile}bj"; then 3331.1Spooka test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" 3341.1Spookafi 3351.1Spooka 3361.1Spookarmdir "$lockdir" 3371.1Spookaexit $ret 3381.1Spooka 3391.1Spooka# Local Variables: 3401.1Spooka# mode: shell-script 3411.1Spooka# sh-indentation: 2 3421.1Spooka# eval: (add-hook 'write-file-hooks 'time-stamp) 3431.1Spooka# time-stamp-start: "scriptversion=" 3441.1Spooka# time-stamp-format: "%:y-%02m-%02d.%02H" 3451.1Spooka# time-stamp-time-zone: "UTC" 3461.1Spooka# time-stamp-end: "; # UTC" 3471.1Spooka# End: 348