a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# Wrapper for compilers which do not understand '-c -o'.
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews# Copyright (C) 1999-2017 Free Software Foundation, Inc.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# Written by Tom Tromey <tromey@cygnus.com>.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# This program is free software; you can redistribute it and/or modify
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# it under the terms of the GNU General Public License as published by
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# the Free Software Foundation; either version 2, or (at your option)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# any later version.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# This program is distributed in the hope that it will be useful,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# but WITHOUT ANY WARRANTY; without even the implied warranty of
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# GNU General Public License for more details.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# You should have received a copy of the GNU General Public License
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# along with this program. If not, see <http://www.gnu.org/licenses/>.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# As a special exception to the GNU General Public License, if you
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# distribute this file as part of a program that contains a
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# configuration script generated by Autoconf, you may include it under
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# the same distribution terms that you use for the rest of that program.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# This file is maintained in Automake, please report
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# bugs to <bug-automake@gnu.org> or send patches to
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# <automake-patches@gnu.org>.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# We need space, tab and new line, in precisely that order. Quoting is
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# there to prevent tools from complaining about whitespace usage.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# func_file_conv build_file lazy
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# Convert a $build file to $host form and store it in $file
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# Currently only supports Windows hosts. If the determined conversion
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# type is listed in (the comma separated) LAZY, no conversion will
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# take place.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# func_cl_dashL linkdir
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# Make cl look for libraries in LINKDIR
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# func_cl_dashl library
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# Do a library search-path lookup for cl
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# func_cl_wrapper cl arg...
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# Adjust compile command to suit cl
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # configure might choose to run compile as 'compile cc -o foo foo.c'.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt *.o | *.[oO][bB][jJ])
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt echo "$0: No command. Try '$0 --help' for more information." 1>&2
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan HuntWrapper for compilers which do not understand '-c -o'.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan HuntRemove '-o dest.o' from ARGS, run PROGRAM with the remaining
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntIf you are trying to build a whole package this is not the
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Huntright script to run: please start by reading the file 'INSTALL'.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt echo "compile $scriptversion"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt if test -n "$eat"; then
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # configure might choose to run compile as 'compile cc -o foo foo.c'.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # So we strip '-o arg' only if arg is an object.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt set x "$@" "$1"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt set x "$@" "$1"
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # If no '-o' option was seen then we might have been invoked from a
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # pattern rule where we don't need one. That is ok -- this is a
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt # normal compilation that the losing compiler can handle. If no
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt # '.c' file was seen then we are probably linking. That is also
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# Name of file we expect compiler to create.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntcofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# Create the lock directory.
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt# Note: use '[/\\:.-]' here to ensure that we don't use the same name
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# that we are using for the .o file. Also, base the name on the expected
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# object file name, since that is what matters with a parallel build.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntlockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntwhile true; do
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# FIXME: race condition here if user kills between mkdir and trap.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# Run the compile.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntif test -f "$cofile"; then
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntelif test -f "${cofile}bj"; then
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# Local Variables:
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# mode: shell-script
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# sh-indentation: 2
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# eval: (add-hook 'write-file-hooks 'time-stamp)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# time-stamp-start: "scriptversion="
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# time-stamp-format: "%:y-%02m-%02d.%02H"
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrews# time-stamp-time-zone: "UTC0"
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt# time-stamp-end: "; # UTC"