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