compile revision 1f27ce9a
11f27ce9aSmrg#! /bin/sh 21f27ce9aSmrg# Wrapper for compilers which do not understand `-c -o'. 31f27ce9aSmrg 41f27ce9aSmrgscriptversion=2009-10-06.20; # UTC 51f27ce9aSmrg 61f27ce9aSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software 71f27ce9aSmrg# Foundation, Inc. 81f27ce9aSmrg# Written by Tom Tromey <tromey@cygnus.com>. 91f27ce9aSmrg# 101f27ce9aSmrg# This program is free software; you can redistribute it and/or modify 111f27ce9aSmrg# it under the terms of the GNU General Public License as published by 121f27ce9aSmrg# the Free Software Foundation; either version 2, or (at your option) 131f27ce9aSmrg# any later version. 141f27ce9aSmrg# 151f27ce9aSmrg# This program is distributed in the hope that it will be useful, 161f27ce9aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 171f27ce9aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 181f27ce9aSmrg# GNU General Public License for more details. 191f27ce9aSmrg# 201f27ce9aSmrg# You should have received a copy of the GNU General Public License 211f27ce9aSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 221f27ce9aSmrg 231f27ce9aSmrg# As a special exception to the GNU General Public License, if you 241f27ce9aSmrg# distribute this file as part of a program that contains a 251f27ce9aSmrg# configuration script generated by Autoconf, you may include it under 261f27ce9aSmrg# the same distribution terms that you use for the rest of that program. 271f27ce9aSmrg 281f27ce9aSmrg# This file is maintained in Automake, please report 291f27ce9aSmrg# bugs to <bug-automake@gnu.org> or send patches to 301f27ce9aSmrg# <automake-patches@gnu.org>. 311f27ce9aSmrg 321f27ce9aSmrgcase $1 in 331f27ce9aSmrg '') 341f27ce9aSmrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 351f27ce9aSmrg exit 1; 361f27ce9aSmrg ;; 371f27ce9aSmrg -h | --h*) 381f27ce9aSmrg cat <<\EOF 391f27ce9aSmrgUsage: compile [--help] [--version] PROGRAM [ARGS] 401f27ce9aSmrg 411f27ce9aSmrgWrapper for compilers which do not understand `-c -o'. 421f27ce9aSmrgRemove `-o dest.o' from ARGS, run PROGRAM with the remaining 431f27ce9aSmrgarguments, and rename the output as expected. 441f27ce9aSmrg 451f27ce9aSmrgIf you are trying to build a whole package this is not the 461f27ce9aSmrgright script to run: please start by reading the file `INSTALL'. 471f27ce9aSmrg 481f27ce9aSmrgReport bugs to <bug-automake@gnu.org>. 491f27ce9aSmrgEOF 501f27ce9aSmrg exit $? 511f27ce9aSmrg ;; 521f27ce9aSmrg -v | --v*) 531f27ce9aSmrg echo "compile $scriptversion" 541f27ce9aSmrg exit $? 551f27ce9aSmrg ;; 561f27ce9aSmrgesac 571f27ce9aSmrg 581f27ce9aSmrgofile= 591f27ce9aSmrgcfile= 601f27ce9aSmrgeat= 611f27ce9aSmrg 621f27ce9aSmrgfor arg 631f27ce9aSmrgdo 641f27ce9aSmrg if test -n "$eat"; then 651f27ce9aSmrg eat= 661f27ce9aSmrg else 671f27ce9aSmrg case $1 in 681f27ce9aSmrg -o) 691f27ce9aSmrg # configure might choose to run compile as `compile cc -o foo foo.c'. 701f27ce9aSmrg # So we strip `-o arg' only if arg is an object. 711f27ce9aSmrg eat=1 721f27ce9aSmrg case $2 in 731f27ce9aSmrg *.o | *.obj) 741f27ce9aSmrg ofile=$2 751f27ce9aSmrg ;; 761f27ce9aSmrg *) 771f27ce9aSmrg set x "$@" -o "$2" 781f27ce9aSmrg shift 791f27ce9aSmrg ;; 801f27ce9aSmrg esac 811f27ce9aSmrg ;; 821f27ce9aSmrg *.c) 831f27ce9aSmrg cfile=$1 841f27ce9aSmrg set x "$@" "$1" 851f27ce9aSmrg shift 861f27ce9aSmrg ;; 871f27ce9aSmrg *) 881f27ce9aSmrg set x "$@" "$1" 891f27ce9aSmrg shift 901f27ce9aSmrg ;; 911f27ce9aSmrg esac 921f27ce9aSmrg fi 931f27ce9aSmrg shift 941f27ce9aSmrgdone 951f27ce9aSmrg 961f27ce9aSmrgif test -z "$ofile" || test -z "$cfile"; then 971f27ce9aSmrg # If no `-o' option was seen then we might have been invoked from a 981f27ce9aSmrg # pattern rule where we don't need one. That is ok -- this is a 991f27ce9aSmrg # normal compilation that the losing compiler can handle. If no 1001f27ce9aSmrg # `.c' file was seen then we are probably linking. That is also 1011f27ce9aSmrg # ok. 1021f27ce9aSmrg exec "$@" 1031f27ce9aSmrgfi 1041f27ce9aSmrg 1051f27ce9aSmrg# Name of file we expect compiler to create. 1061f27ce9aSmrgcofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` 1071f27ce9aSmrg 1081f27ce9aSmrg# Create the lock directory. 1091f27ce9aSmrg# Note: use `[/\\:.-]' here to ensure that we don't use the same name 1101f27ce9aSmrg# that we are using for the .o file. Also, base the name on the expected 1111f27ce9aSmrg# object file name, since that is what matters with a parallel build. 1121f27ce9aSmrglockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d 1131f27ce9aSmrgwhile true; do 1141f27ce9aSmrg if mkdir "$lockdir" >/dev/null 2>&1; then 1151f27ce9aSmrg break 1161f27ce9aSmrg fi 1171f27ce9aSmrg sleep 1 1181f27ce9aSmrgdone 1191f27ce9aSmrg# FIXME: race condition here if user kills between mkdir and trap. 1201f27ce9aSmrgtrap "rmdir '$lockdir'; exit 1" 1 2 15 1211f27ce9aSmrg 1221f27ce9aSmrg# Run the compile. 1231f27ce9aSmrg"$@" 1241f27ce9aSmrgret=$? 1251f27ce9aSmrg 1261f27ce9aSmrgif test -f "$cofile"; then 1271f27ce9aSmrg test "$cofile" = "$ofile" || mv "$cofile" "$ofile" 1281f27ce9aSmrgelif test -f "${cofile}bj"; then 1291f27ce9aSmrg test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" 1301f27ce9aSmrgfi 1311f27ce9aSmrg 1321f27ce9aSmrgrmdir "$lockdir" 1331f27ce9aSmrgexit $ret 1341f27ce9aSmrg 1351f27ce9aSmrg# Local Variables: 1361f27ce9aSmrg# mode: shell-script 1371f27ce9aSmrg# sh-indentation: 2 1381f27ce9aSmrg# eval: (add-hook 'write-file-hooks 'time-stamp) 1391f27ce9aSmrg# time-stamp-start: "scriptversion=" 1401f27ce9aSmrg# time-stamp-format: "%:y-%02m-%02d.%02H" 1411f27ce9aSmrg# time-stamp-time-zone: "UTC" 1421f27ce9aSmrg# time-stamp-end: "; # UTC" 1431f27ce9aSmrg# End: 144