|
fukasawa |
e60969 |
#! /bin/sh
|
|
fukasawa |
e60969 |
# Wrapper for compilers which do not understand '-c -o'.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
scriptversion=2012-10-14.11; # UTC
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
|
|
fukasawa |
e60969 |
# Written by Tom Tromey <tromey@cygnus.com>.</tromey@cygnus.com>
|
|
fukasawa |
e60969 |
#
|
|
fukasawa |
e60969 |
# This program is free software; you can redistribute it and/or modify
|
|
fukasawa |
e60969 |
# it under the terms of the GNU General Public License as published by
|
|
fukasawa |
e60969 |
# the Free Software Foundation; either version 2, or (at your option)
|
|
fukasawa |
e60969 |
# any later version.
|
|
fukasawa |
e60969 |
#
|
|
fukasawa |
e60969 |
# This program is distributed in the hope that it will be useful,
|
|
fukasawa |
e60969 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
fukasawa |
e60969 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
fukasawa |
e60969 |
# GNU General Public License for more details.
|
|
fukasawa |
e60969 |
#
|
|
fukasawa |
e60969 |
# You should have received a copy of the GNU General Public License
|
|
fukasawa |
e60969 |
# along with this program. If not, see <http: licenses="" www.gnu.org="">.</http:>
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
# As a special exception to the GNU General Public License, if you
|
|
fukasawa |
e60969 |
# distribute this file as part of a program that contains a
|
|
fukasawa |
e60969 |
# configuration script generated by Autoconf, you may include it under
|
|
fukasawa |
e60969 |
# the same distribution terms that you use for the rest of that program.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
# This file is maintained in Automake, please report
|
|
fukasawa |
e60969 |
# bugs to <bug-automake@gnu.org> or send patches to</bug-automake@gnu.org>
|
|
fukasawa |
e60969 |
# <automake-patches@gnu.org>.</automake-patches@gnu.org>
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
nl='
|
|
fukasawa |
e60969 |
'
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
# We need space, tab and new line, in precisely that order. Quoting is
|
|
fukasawa |
e60969 |
# there to prevent tools from complaining about whitespace usage.
|
|
fukasawa |
e60969 |
IFS=" "" $nl"
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
file_conv=
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
# func_file_conv build_file lazy
|
|
fukasawa |
e60969 |
# Convert a $build file to $host form and store it in $file
|
|
fukasawa |
e60969 |
# Currently only supports Windows hosts. If the determined conversion
|
|
fukasawa |
e60969 |
# type is listed in (the comma separated) LAZY, no conversion will
|
|
fukasawa |
e60969 |
# take place.
|
|
fukasawa |
e60969 |
func_file_conv ()
|
|
fukasawa |
e60969 |
{
|
|
fukasawa |
e60969 |
file=$1
|
|
fukasawa |
e60969 |
case $file in
|
|
fukasawa |
e60969 |
/ | /[!/]*) # absolute file, and not a UNC file
|
|
fukasawa |
e60969 |
if test -z "$file_conv"; then
|
|
fukasawa |
e60969 |
# lazily determine how to convert abs files
|
|
fukasawa |
e60969 |
case `uname -s` in
|
|
fukasawa |
e60969 |
MINGW*)
|
|
fukasawa |
e60969 |
file_conv=mingw
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
CYGWIN*)
|
|
fukasawa |
e60969 |
file_conv=cygwin
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
*)
|
|
fukasawa |
e60969 |
file_conv=wine
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
esac
|
|
fukasawa |
e60969 |
fi
|
|
fukasawa |
e60969 |
case $file_conv/,$2, in
|
|
fukasawa |
e60969 |
*,$file_conv,*)
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
mingw/*)
|
|
fukasawa |
e60969 |
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
cygwin/*)
|
|
fukasawa |
e60969 |
file=`cygpath -m "$file" || echo "$file"`
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
wine/*)
|
|
fukasawa |
e60969 |
file=`winepath -w "$file" || echo "$file"`
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
esac
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
esac
|
|
fukasawa |
e60969 |
}
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
# func_cl_dashL linkdir
|
|
fukasawa |
e60969 |
# Make cl look for libraries in LINKDIR
|
|
fukasawa |
e60969 |
func_cl_dashL ()
|
|
fukasawa |
e60969 |
{
|
|
fukasawa |
e60969 |
func_file_conv "$1"
|
|
fukasawa |
e60969 |
if test -z "$lib_path"; then
|
|
fukasawa |
e60969 |
lib_path=$file
|
|
fukasawa |
e60969 |
else
|
|
fukasawa |
e60969 |
lib_path="$lib_path;$file"
|
|
fukasawa |
e60969 |
fi
|
|
fukasawa |
e60969 |
linker_opts="$linker_opts -LIBPATH:$file"
|
|
fukasawa |
e60969 |
}
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
# func_cl_dashl library
|
|
fukasawa |
e60969 |
# Do a library search-path lookup for cl
|
|
fukasawa |
e60969 |
func_cl_dashl ()
|
|
fukasawa |
e60969 |
{
|
|
fukasawa |
e60969 |
lib=$1
|
|
fukasawa |
e60969 |
found=no
|
|
fukasawa |
e60969 |
save_IFS=$IFS
|
|
fukasawa |
e60969 |
IFS=';'
|
|
fukasawa |
e60969 |
for dir in $lib_path $LIB
|
|
fukasawa |
e60969 |
do
|
|
fukasawa |
e60969 |
IFS=$save_IFS
|
|
fukasawa |
e60969 |
if $shared && test -f "$dir/$lib.dll.lib"; then
|
|
fukasawa |
e60969 |
found=yes
|
|
fukasawa |
e60969 |
lib=$dir/$lib.dll.lib
|
|
fukasawa |
e60969 |
break
|
|
fukasawa |
e60969 |
fi
|
|
fukasawa |
e60969 |
if test -f "$dir/$lib.lib"; then
|
|
fukasawa |
e60969 |
found=yes
|
|
fukasawa |
e60969 |
lib=$dir/$lib.lib
|
|
fukasawa |
e60969 |
break
|
|
fukasawa |
e60969 |
fi
|
|
fukasawa |
e60969 |
if test -f "$dir/lib$lib.a"; then
|
|
fukasawa |
e60969 |
found=yes
|
|
fukasawa |
e60969 |
lib=$dir/lib$lib.a
|
|
fukasawa |
e60969 |
break
|
|
fukasawa |
e60969 |
fi
|
|
fukasawa |
e60969 |
done
|
|
fukasawa |
e60969 |
IFS=$save_IFS
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
if test "$found" != yes; then
|
|
fukasawa |
e60969 |
lib=$lib.lib
|
|
fukasawa |
e60969 |
fi
|
|
fukasawa |
e60969 |
}
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
# func_cl_wrapper cl arg...
|
|
fukasawa |
e60969 |
# Adjust compile command to suit cl
|
|
fukasawa |
e60969 |
func_cl_wrapper ()
|
|
fukasawa |
e60969 |
{
|
|
fukasawa |
e60969 |
# Assume a capable shell
|
|
fukasawa |
e60969 |
lib_path=
|
|
fukasawa |
e60969 |
shared=:
|
|
fukasawa |
e60969 |
linker_opts=
|
|
fukasawa |
e60969 |
for arg
|
|
fukasawa |
e60969 |
do
|
|
fukasawa |
e60969 |
if test -n "$eat"; then
|
|
fukasawa |
e60969 |
eat=
|
|
fukasawa |
e60969 |
else
|
|
fukasawa |
e60969 |
case $1 in
|
|
fukasawa |
e60969 |
-o)
|
|
fukasawa |
e60969 |
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
|
fukasawa |
e60969 |
eat=1
|
|
fukasawa |
e60969 |
case $2 in
|
|
fukasawa |
e60969 |
*.o | *.[oO][bB][jJ])
|
|
fukasawa |
e60969 |
func_file_conv "$2"
|
|
fukasawa |
e60969 |
set x "$@" -Fo"$file"
|
|
fukasawa |
e60969 |
shift
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
*)
|
|
fukasawa |
e60969 |
func_file_conv "$2"
|
|
fukasawa |
e60969 |
set x "$@" -Fe"$file"
|
|
fukasawa |
e60969 |
shift
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
esac
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
-I)
|
|
fukasawa |
e60969 |
eat=1
|
|
fukasawa |
e60969 |
func_file_conv "$2" mingw
|
|
fukasawa |
e60969 |
set x "$@" -I"$file"
|
|
fukasawa |
e60969 |
shift
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
-I*)
|
|
fukasawa |
e60969 |
func_file_conv "${1#-I}" mingw
|
|
fukasawa |
e60969 |
set x "$@" -I"$file"
|
|
fukasawa |
e60969 |
shift
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
-l)
|
|
fukasawa |
e60969 |
eat=1
|
|
fukasawa |
e60969 |
func_cl_dashl "$2"
|
|
fukasawa |
e60969 |
set x "$@" "$lib"
|
|
fukasawa |
e60969 |
shift
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
-l*)
|
|
fukasawa |
e60969 |
func_cl_dashl "${1#-l}"
|
|
fukasawa |
e60969 |
set x "$@" "$lib"
|
|
fukasawa |
e60969 |
shift
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
-L)
|
|
fukasawa |
e60969 |
eat=1
|
|
fukasawa |
e60969 |
func_cl_dashL "$2"
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
-L*)
|
|
fukasawa |
e60969 |
func_cl_dashL "${1#-L}"
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
-static)
|
|
fukasawa |
e60969 |
shared=false
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
-Wl,*)
|
|
fukasawa |
e60969 |
arg=${1#-Wl,}
|
|
fukasawa |
e60969 |
save_ifs="$IFS"; IFS=','
|
|
fukasawa |
e60969 |
for flag in $arg; do
|
|
fukasawa |
e60969 |
IFS="$save_ifs"
|
|
fukasawa |
e60969 |
linker_opts="$linker_opts $flag"
|
|
fukasawa |
e60969 |
done
|
|
fukasawa |
e60969 |
IFS="$save_ifs"
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
-Xlinker)
|
|
fukasawa |
e60969 |
eat=1
|
|
fukasawa |
e60969 |
linker_opts="$linker_opts $2"
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
-*)
|
|
fukasawa |
e60969 |
set x "$@" "$1"
|
|
fukasawa |
e60969 |
shift
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
|
fukasawa |
e60969 |
func_file_conv "$1"
|
|
fukasawa |
e60969 |
set x "$@" -Tp"$file"
|
|
fukasawa |
e60969 |
shift
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
|
fukasawa |
e60969 |
func_file_conv "$1" mingw
|
|
fukasawa |
e60969 |
set x "$@" "$file"
|
|
fukasawa |
e60969 |
shift
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
*)
|
|
fukasawa |
e60969 |
set x "$@" "$1"
|
|
fukasawa |
e60969 |
shift
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
esac
|
|
fukasawa |
e60969 |
fi
|
|
fukasawa |
e60969 |
shift
|
|
fukasawa |
e60969 |
done
|
|
fukasawa |
e60969 |
if test -n "$linker_opts"; then
|
|
fukasawa |
e60969 |
linker_opts="-link$linker_opts"
|
|
fukasawa |
e60969 |
fi
|
|
fukasawa |
e60969 |
exec "$@" $linker_opts
|
|
fukasawa |
e60969 |
exit 1
|
|
fukasawa |
e60969 |
}
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
eat=
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
case $1 in
|
|
fukasawa |
e60969 |
'')
|
|
fukasawa |
e60969 |
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
|
fukasawa |
e60969 |
exit 1;
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
-h | --h*)
|
|
fukasawa |
e60969 |
cat <<\EOF
|
|
fukasawa |
e60969 |
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Wrapper for compilers which do not understand '-c -o'.
|
|
fukasawa |
e60969 |
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
|
fukasawa |
e60969 |
arguments, and rename the output as expected.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
If you are trying to build a whole package this is not the
|
|
fukasawa |
e60969 |
right script to run: please start by reading the file 'INSTALL'.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Report bugs to <bug-automake@gnu.org>.</bug-automake@gnu.org>
|
|
fukasawa |
e60969 |
EOF
|
|
fukasawa |
e60969 |
exit $?
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
-v | --v*)
|
|
fukasawa |
e60969 |
echo "compile $scriptversion"
|
|
fukasawa |
e60969 |
exit $?
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
|
|
fukasawa |
e60969 |
func_cl_wrapper "$@" # Doesn't return...
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
esac
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
ofile=
|
|
fukasawa |
e60969 |
cfile=
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
for arg
|
|
fukasawa |
e60969 |
do
|
|
fukasawa |
e60969 |
if test -n "$eat"; then
|
|
fukasawa |
e60969 |
eat=
|
|
fukasawa |
e60969 |
else
|
|
fukasawa |
e60969 |
case $1 in
|
|
fukasawa |
e60969 |
-o)
|
|
fukasawa |
e60969 |
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
|
fukasawa |
e60969 |
# So we strip '-o arg' only if arg is an object.
|
|
fukasawa |
e60969 |
eat=1
|
|
fukasawa |
e60969 |
case $2 in
|
|
fukasawa |
e60969 |
*.o | *.obj)
|
|
fukasawa |
e60969 |
ofile=$2
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
*)
|
|
fukasawa |
e60969 |
set x "$@" -o "$2"
|
|
fukasawa |
e60969 |
shift
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
esac
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
*.c)
|
|
fukasawa |
e60969 |
cfile=$1
|
|
fukasawa |
e60969 |
set x "$@" "$1"
|
|
fukasawa |
e60969 |
shift
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
*)
|
|
fukasawa |
e60969 |
set x "$@" "$1"
|
|
fukasawa |
e60969 |
shift
|
|
fukasawa |
e60969 |
;;
|
|
fukasawa |
e60969 |
esac
|
|
fukasawa |
e60969 |
fi
|
|
fukasawa |
e60969 |
shift
|
|
fukasawa |
e60969 |
done
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
if test -z "$ofile" || test -z "$cfile"; then
|
|
fukasawa |
e60969 |
# If no '-o' option was seen then we might have been invoked from a
|
|
fukasawa |
e60969 |
# pattern rule where we don't need one. That is ok -- this is a
|
|
fukasawa |
e60969 |
# normal compilation that the losing compiler can handle. If no
|
|
fukasawa |
e60969 |
# '.c' file was seen then we are probably linking. That is also
|
|
fukasawa |
e60969 |
# ok.
|
|
fukasawa |
e60969 |
exec "$@"
|
|
fukasawa |
e60969 |
fi
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
# Name of file we expect compiler to create.
|
|
fukasawa |
e60969 |
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
# Create the lock directory.
|
|
fukasawa |
e60969 |
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
|
fukasawa |
e60969 |
# that we are using for the .o file. Also, base the name on the expected
|
|
fukasawa |
e60969 |
# object file name, since that is what matters with a parallel build.
|
|
fukasawa |
e60969 |
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
|
fukasawa |
e60969 |
while true; do
|
|
fukasawa |
e60969 |
if mkdir "$lockdir" >/dev/null 2>&1; then
|
|
fukasawa |
e60969 |
break
|
|
fukasawa |
e60969 |
fi
|
|
fukasawa |
e60969 |
sleep 1
|
|
fukasawa |
e60969 |
done
|
|
fukasawa |
e60969 |
# FIXME: race condition here if user kills between mkdir and trap.
|
|
fukasawa |
e60969 |
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
# Run the compile.
|
|
fukasawa |
e60969 |
"$@"
|
|
fukasawa |
e60969 |
ret=$?
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
if test -f "$cofile"; then
|
|
fukasawa |
e60969 |
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
|
fukasawa |
e60969 |
elif test -f "${cofile}bj"; then
|
|
fukasawa |
e60969 |
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
|
fukasawa |
e60969 |
fi
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
rmdir "$lockdir"
|
|
fukasawa |
e60969 |
exit $ret
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
# Local Variables:
|
|
fukasawa |
e60969 |
# mode: shell-script
|
|
fukasawa |
e60969 |
# sh-indentation: 2
|
|
fukasawa |
e60969 |
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
|
fukasawa |
e60969 |
# time-stamp-start: "scriptversion="
|
|
fukasawa |
e60969 |
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
|
fukasawa |
e60969 |
# time-stamp-time-zone: "UTC"
|
|
fukasawa |
e60969 |
# time-stamp-end: "; # UTC"
|
|
fukasawa |
e60969 |
# End:
|