compile revision 6f03b1f6
16f03b1f6Smrg#! /bin/sh 26f03b1f6Smrg# Wrapper for compilers which do not understand `-c -o'. 36f03b1f6Smrg 46f03b1f6Smrgscriptversion=2005-05-14.22 56f03b1f6Smrg 66f03b1f6Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 76f03b1f6Smrg# Written by Tom Tromey <tromey@cygnus.com>. 86f03b1f6Smrg# 96f03b1f6Smrg# This program is free software; you can redistribute it and/or modify 106f03b1f6Smrg# it under the terms of the GNU General Public License as published by 116f03b1f6Smrg# the Free Software Foundation; either version 2, or (at your option) 126f03b1f6Smrg# any later version. 136f03b1f6Smrg# 146f03b1f6Smrg# This program is distributed in the hope that it will be useful, 156f03b1f6Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 166f03b1f6Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 176f03b1f6Smrg# GNU General Public License for more details. 186f03b1f6Smrg# 196f03b1f6Smrg# You should have received a copy of the GNU General Public License 206f03b1f6Smrg# along with this program; if not, write to the Free Software 216f03b1f6Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 226f03b1f6Smrg 236f03b1f6Smrg# As a special exception to the GNU General Public License, if you 246f03b1f6Smrg# distribute this file as part of a program that contains a 256f03b1f6Smrg# configuration script generated by Autoconf, you may include it under 266f03b1f6Smrg# the same distribution terms that you use for the rest of that program. 276f03b1f6Smrg 286f03b1f6Smrg# This file is maintained in Automake, please report 296f03b1f6Smrg# bugs to <bug-automake@gnu.org> or send patches to 306f03b1f6Smrg# <automake-patches@gnu.org>. 316f03b1f6Smrg 326f03b1f6Smrgcase $1 in 336f03b1f6Smrg '') 346f03b1f6Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 356f03b1f6Smrg exit 1; 366f03b1f6Smrg ;; 376f03b1f6Smrg -h | --h*) 386f03b1f6Smrg cat <<\EOF 396f03b1f6SmrgUsage: compile [--help] [--version] PROGRAM [ARGS] 406f03b1f6Smrg 416f03b1f6SmrgWrapper for compilers which do not understand `-c -o'. 426f03b1f6SmrgRemove `-o dest.o' from ARGS, run PROGRAM with the remaining 436f03b1f6Smrgarguments, and rename the output as expected. 446f03b1f6Smrg 456f03b1f6SmrgIf you are trying to build a whole package this is not the 466f03b1f6Smrgright script to run: please start by reading the file `INSTALL'. 476f03b1f6Smrg 486f03b1f6SmrgReport bugs to <bug-automake@gnu.org>. 496f03b1f6SmrgEOF 506f03b1f6Smrg exit $? 516f03b1f6Smrg ;; 526f03b1f6Smrg -v | --v*) 536f03b1f6Smrg echo "compile $scriptversion" 546f03b1f6Smrg exit $? 556f03b1f6Smrg ;; 566f03b1f6Smrgesac 576f03b1f6Smrg 586f03b1f6Smrgofile= 596f03b1f6Smrgcfile= 606f03b1f6Smrgeat= 616f03b1f6Smrg 626f03b1f6Smrgfor arg 636f03b1f6Smrgdo 646f03b1f6Smrg if test -n "$eat"; then 656f03b1f6Smrg eat= 666f03b1f6Smrg else 676f03b1f6Smrg case $1 in 686f03b1f6Smrg -o) 696f03b1f6Smrg # configure might choose to run compile as `compile cc -o foo foo.c'. 706f03b1f6Smrg # So we strip `-o arg' only if arg is an object. 716f03b1f6Smrg eat=1 726f03b1f6Smrg case $2 in 736f03b1f6Smrg *.o | *.obj) 746f03b1f6Smrg ofile=$2 756f03b1f6Smrg ;; 766f03b1f6Smrg *) 776f03b1f6Smrg set x "$@" -o "$2" 786f03b1f6Smrg shift 796f03b1f6Smrg ;; 806f03b1f6Smrg esac 816f03b1f6Smrg ;; 826f03b1f6Smrg *.c) 836f03b1f6Smrg cfile=$1 846f03b1f6Smrg set x "$@" "$1" 856f03b1f6Smrg shift 866f03b1f6Smrg ;; 876f03b1f6Smrg *) 886f03b1f6Smrg set x "$@" "$1" 896f03b1f6Smrg shift 906f03b1f6Smrg ;; 916f03b1f6Smrg esac 926f03b1f6Smrg fi 936f03b1f6Smrg shift 946f03b1f6Smrgdone 956f03b1f6Smrg 966f03b1f6Smrgif test -z "$ofile" || test -z "$cfile"; then 976f03b1f6Smrg # If no `-o' option was seen then we might have been invoked from a 986f03b1f6Smrg # pattern rule where we don't need one. That is ok -- this is a 996f03b1f6Smrg # normal compilation that the losing compiler can handle. If no 1006f03b1f6Smrg # `.c' file was seen then we are probably linking. That is also 1016f03b1f6Smrg # ok. 1026f03b1f6Smrg exec "$@" 1036f03b1f6Smrgfi 1046f03b1f6Smrg 1056f03b1f6Smrg# Name of file we expect compiler to create. 1066f03b1f6Smrgcofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` 1076f03b1f6Smrg 1086f03b1f6Smrg# Create the lock directory. 1096f03b1f6Smrg# Note: use `[/.-]' here to ensure that we don't use the same name 1106f03b1f6Smrg# that we are using for the .o file. Also, base the name on the expected 1116f03b1f6Smrg# object file name, since that is what matters with a parallel build. 1126f03b1f6Smrglockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d 1136f03b1f6Smrgwhile true; do 1146f03b1f6Smrg if mkdir "$lockdir" >/dev/null 2>&1; then 1156f03b1f6Smrg break 1166f03b1f6Smrg fi 1176f03b1f6Smrg sleep 1 1186f03b1f6Smrgdone 1196f03b1f6Smrg# FIXME: race condition here if user kills between mkdir and trap. 1206f03b1f6Smrgtrap "rmdir '$lockdir'; exit 1" 1 2 15 1216f03b1f6Smrg 1226f03b1f6Smrg# Run the compile. 1236f03b1f6Smrg"$@" 1246f03b1f6Smrgret=$? 1256f03b1f6Smrg 1266f03b1f6Smrgif test -f "$cofile"; then 1276f03b1f6Smrg mv "$cofile" "$ofile" 1286f03b1f6Smrgelif test -f "${cofile}bj"; then 1296f03b1f6Smrg mv "${cofile}bj" "$ofile" 1306f03b1f6Smrgfi 1316f03b1f6Smrg 1326f03b1f6Smrgrmdir "$lockdir" 1336f03b1f6Smrgexit $ret 1346f03b1f6Smrg 1356f03b1f6Smrg# Local Variables: 1366f03b1f6Smrg# mode: shell-script 1376f03b1f6Smrg# sh-indentation: 2 1386f03b1f6Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 1396f03b1f6Smrg# time-stamp-start: "scriptversion=" 1406f03b1f6Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 1416f03b1f6Smrg# time-stamp-end: "$" 1426f03b1f6Smrg# End: 143