compile revision 7da8b7e3
17da8b7e3Smrg#! /bin/sh 27da8b7e3Smrg# Wrapper for compilers which do not understand `-c -o'. 37da8b7e3Smrg 47da8b7e3Smrgscriptversion=2005-05-14.22 57da8b7e3Smrg 67da8b7e3Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 77da8b7e3Smrg# Written by Tom Tromey <tromey@cygnus.com>. 87da8b7e3Smrg# 97da8b7e3Smrg# This program is free software; you can redistribute it and/or modify 107da8b7e3Smrg# it under the terms of the GNU General Public License as published by 117da8b7e3Smrg# the Free Software Foundation; either version 2, or (at your option) 127da8b7e3Smrg# any later version. 137da8b7e3Smrg# 147da8b7e3Smrg# This program is distributed in the hope that it will be useful, 157da8b7e3Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 167da8b7e3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 177da8b7e3Smrg# GNU General Public License for more details. 187da8b7e3Smrg# 197da8b7e3Smrg# You should have received a copy of the GNU General Public License 207da8b7e3Smrg# along with this program; if not, write to the Free Software 217da8b7e3Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 227da8b7e3Smrg 237da8b7e3Smrg# As a special exception to the GNU General Public License, if you 247da8b7e3Smrg# distribute this file as part of a program that contains a 257da8b7e3Smrg# configuration script generated by Autoconf, you may include it under 267da8b7e3Smrg# the same distribution terms that you use for the rest of that program. 277da8b7e3Smrg 287da8b7e3Smrg# This file is maintained in Automake, please report 297da8b7e3Smrg# bugs to <bug-automake@gnu.org> or send patches to 307da8b7e3Smrg# <automake-patches@gnu.org>. 317da8b7e3Smrg 327da8b7e3Smrgcase $1 in 337da8b7e3Smrg '') 347da8b7e3Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 357da8b7e3Smrg exit 1; 367da8b7e3Smrg ;; 377da8b7e3Smrg -h | --h*) 387da8b7e3Smrg cat <<\EOF 397da8b7e3SmrgUsage: compile [--help] [--version] PROGRAM [ARGS] 407da8b7e3Smrg 417da8b7e3SmrgWrapper for compilers which do not understand `-c -o'. 427da8b7e3SmrgRemove `-o dest.o' from ARGS, run PROGRAM with the remaining 437da8b7e3Smrgarguments, and rename the output as expected. 447da8b7e3Smrg 457da8b7e3SmrgIf you are trying to build a whole package this is not the 467da8b7e3Smrgright script to run: please start by reading the file `INSTALL'. 477da8b7e3Smrg 487da8b7e3SmrgReport bugs to <bug-automake@gnu.org>. 497da8b7e3SmrgEOF 507da8b7e3Smrg exit $? 517da8b7e3Smrg ;; 527da8b7e3Smrg -v | --v*) 537da8b7e3Smrg echo "compile $scriptversion" 547da8b7e3Smrg exit $? 557da8b7e3Smrg ;; 567da8b7e3Smrgesac 577da8b7e3Smrg 587da8b7e3Smrgofile= 597da8b7e3Smrgcfile= 607da8b7e3Smrgeat= 617da8b7e3Smrg 627da8b7e3Smrgfor arg 637da8b7e3Smrgdo 647da8b7e3Smrg if test -n "$eat"; then 657da8b7e3Smrg eat= 667da8b7e3Smrg else 677da8b7e3Smrg case $1 in 687da8b7e3Smrg -o) 697da8b7e3Smrg # configure might choose to run compile as `compile cc -o foo foo.c'. 707da8b7e3Smrg # So we strip `-o arg' only if arg is an object. 717da8b7e3Smrg eat=1 727da8b7e3Smrg case $2 in 737da8b7e3Smrg *.o | *.obj) 747da8b7e3Smrg ofile=$2 757da8b7e3Smrg ;; 767da8b7e3Smrg *) 777da8b7e3Smrg set x "$@" -o "$2" 787da8b7e3Smrg shift 797da8b7e3Smrg ;; 807da8b7e3Smrg esac 817da8b7e3Smrg ;; 827da8b7e3Smrg *.c) 837da8b7e3Smrg cfile=$1 847da8b7e3Smrg set x "$@" "$1" 857da8b7e3Smrg shift 867da8b7e3Smrg ;; 877da8b7e3Smrg *) 887da8b7e3Smrg set x "$@" "$1" 897da8b7e3Smrg shift 907da8b7e3Smrg ;; 917da8b7e3Smrg esac 927da8b7e3Smrg fi 937da8b7e3Smrg shift 947da8b7e3Smrgdone 957da8b7e3Smrg 967da8b7e3Smrgif test -z "$ofile" || test -z "$cfile"; then 977da8b7e3Smrg # If no `-o' option was seen then we might have been invoked from a 987da8b7e3Smrg # pattern rule where we don't need one. That is ok -- this is a 997da8b7e3Smrg # normal compilation that the losing compiler can handle. If no 1007da8b7e3Smrg # `.c' file was seen then we are probably linking. That is also 1017da8b7e3Smrg # ok. 1027da8b7e3Smrg exec "$@" 1037da8b7e3Smrgfi 1047da8b7e3Smrg 1057da8b7e3Smrg# Name of file we expect compiler to create. 1067da8b7e3Smrgcofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` 1077da8b7e3Smrg 1087da8b7e3Smrg# Create the lock directory. 1097da8b7e3Smrg# Note: use `[/.-]' here to ensure that we don't use the same name 1107da8b7e3Smrg# that we are using for the .o file. Also, base the name on the expected 1117da8b7e3Smrg# object file name, since that is what matters with a parallel build. 1127da8b7e3Smrglockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d 1137da8b7e3Smrgwhile true; do 1147da8b7e3Smrg if mkdir "$lockdir" >/dev/null 2>&1; then 1157da8b7e3Smrg break 1167da8b7e3Smrg fi 1177da8b7e3Smrg sleep 1 1187da8b7e3Smrgdone 1197da8b7e3Smrg# FIXME: race condition here if user kills between mkdir and trap. 1207da8b7e3Smrgtrap "rmdir '$lockdir'; exit 1" 1 2 15 1217da8b7e3Smrg 1227da8b7e3Smrg# Run the compile. 1237da8b7e3Smrg"$@" 1247da8b7e3Smrgret=$? 1257da8b7e3Smrg 1267da8b7e3Smrgif test -f "$cofile"; then 1277da8b7e3Smrg mv "$cofile" "$ofile" 1287da8b7e3Smrgelif test -f "${cofile}bj"; then 1297da8b7e3Smrg mv "${cofile}bj" "$ofile" 1307da8b7e3Smrgfi 1317da8b7e3Smrg 1327da8b7e3Smrgrmdir "$lockdir" 1337da8b7e3Smrgexit $ret 1347da8b7e3Smrg 1357da8b7e3Smrg# Local Variables: 1367da8b7e3Smrg# mode: shell-script 1377da8b7e3Smrg# sh-indentation: 2 1387da8b7e3Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 1397da8b7e3Smrg# time-stamp-start: "scriptversion=" 1407da8b7e3Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 1417da8b7e3Smrg# time-stamp-end: "$" 1427da8b7e3Smrg# End: 143