1fa225cbcSrjs#! /bin/sh 2fa225cbcSrjs# Wrapper for compilers which do not understand `-c -o'. 3fa225cbcSrjs 4fa225cbcSrjsscriptversion=2005-05-14.22 5fa225cbcSrjs 6fa225cbcSrjs# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 7fa225cbcSrjs# Written by Tom Tromey <tromey@cygnus.com>. 8fa225cbcSrjs# 9fa225cbcSrjs# This program is free software; you can redistribute it and/or modify 10fa225cbcSrjs# it under the terms of the GNU General Public License as published by 11fa225cbcSrjs# the Free Software Foundation; either version 2, or (at your option) 12fa225cbcSrjs# any later version. 13fa225cbcSrjs# 14fa225cbcSrjs# This program is distributed in the hope that it will be useful, 15fa225cbcSrjs# but WITHOUT ANY WARRANTY; without even the implied warranty of 16fa225cbcSrjs# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17fa225cbcSrjs# GNU General Public License for more details. 18fa225cbcSrjs# 19fa225cbcSrjs# You should have received a copy of the GNU General Public License 20fa225cbcSrjs# along with this program; if not, write to the Free Software 21fa225cbcSrjs# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22fa225cbcSrjs 23fa225cbcSrjs# As a special exception to the GNU General Public License, if you 24fa225cbcSrjs# distribute this file as part of a program that contains a 25fa225cbcSrjs# configuration script generated by Autoconf, you may include it under 26fa225cbcSrjs# the same distribution terms that you use for the rest of that program. 27fa225cbcSrjs 28fa225cbcSrjs# This file is maintained in Automake, please report 29fa225cbcSrjs# bugs to <bug-automake@gnu.org> or send patches to 30fa225cbcSrjs# <automake-patches@gnu.org>. 31fa225cbcSrjs 32fa225cbcSrjscase $1 in 33fa225cbcSrjs '') 34fa225cbcSrjs echo "$0: No command. Try \`$0 --help' for more information." 1>&2 35fa225cbcSrjs exit 1; 36fa225cbcSrjs ;; 37fa225cbcSrjs -h | --h*) 38fa225cbcSrjs cat <<\EOF 39fa225cbcSrjsUsage: compile [--help] [--version] PROGRAM [ARGS] 40fa225cbcSrjs 41fa225cbcSrjsWrapper for compilers which do not understand `-c -o'. 42fa225cbcSrjsRemove `-o dest.o' from ARGS, run PROGRAM with the remaining 43fa225cbcSrjsarguments, and rename the output as expected. 44fa225cbcSrjs 45fa225cbcSrjsIf you are trying to build a whole package this is not the 46fa225cbcSrjsright script to run: please start by reading the file `INSTALL'. 47fa225cbcSrjs 48fa225cbcSrjsReport bugs to <bug-automake@gnu.org>. 49fa225cbcSrjsEOF 50fa225cbcSrjs exit $? 51fa225cbcSrjs ;; 52fa225cbcSrjs -v | --v*) 53fa225cbcSrjs echo "compile $scriptversion" 54fa225cbcSrjs exit $? 55fa225cbcSrjs ;; 56fa225cbcSrjsesac 57fa225cbcSrjs 58fa225cbcSrjsofile= 59fa225cbcSrjscfile= 60fa225cbcSrjseat= 61fa225cbcSrjs 62fa225cbcSrjsfor arg 63fa225cbcSrjsdo 64fa225cbcSrjs if test -n "$eat"; then 65fa225cbcSrjs eat= 66fa225cbcSrjs else 67fa225cbcSrjs case $1 in 68fa225cbcSrjs -o) 69fa225cbcSrjs # configure might choose to run compile as `compile cc -o foo foo.c'. 70fa225cbcSrjs # So we strip `-o arg' only if arg is an object. 71fa225cbcSrjs eat=1 72fa225cbcSrjs case $2 in 73fa225cbcSrjs *.o | *.obj) 74fa225cbcSrjs ofile=$2 75fa225cbcSrjs ;; 76fa225cbcSrjs *) 77fa225cbcSrjs set x "$@" -o "$2" 78fa225cbcSrjs shift 79fa225cbcSrjs ;; 80fa225cbcSrjs esac 81fa225cbcSrjs ;; 82fa225cbcSrjs *.c) 83fa225cbcSrjs cfile=$1 84fa225cbcSrjs set x "$@" "$1" 85fa225cbcSrjs shift 86fa225cbcSrjs ;; 87fa225cbcSrjs *) 88fa225cbcSrjs set x "$@" "$1" 89fa225cbcSrjs shift 90fa225cbcSrjs ;; 91fa225cbcSrjs esac 92fa225cbcSrjs fi 93fa225cbcSrjs shift 94fa225cbcSrjsdone 95fa225cbcSrjs 96fa225cbcSrjsif test -z "$ofile" || test -z "$cfile"; then 97fa225cbcSrjs # If no `-o' option was seen then we might have been invoked from a 98fa225cbcSrjs # pattern rule where we don't need one. That is ok -- this is a 99fa225cbcSrjs # normal compilation that the losing compiler can handle. If no 100fa225cbcSrjs # `.c' file was seen then we are probably linking. That is also 101fa225cbcSrjs # ok. 102fa225cbcSrjs exec "$@" 103fa225cbcSrjsfi 104fa225cbcSrjs 105fa225cbcSrjs# Name of file we expect compiler to create. 106fa225cbcSrjscofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` 107fa225cbcSrjs 108fa225cbcSrjs# Create the lock directory. 109fa225cbcSrjs# Note: use `[/.-]' here to ensure that we don't use the same name 110fa225cbcSrjs# that we are using for the .o file. Also, base the name on the expected 111fa225cbcSrjs# object file name, since that is what matters with a parallel build. 112fa225cbcSrjslockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d 113fa225cbcSrjswhile true; do 114fa225cbcSrjs if mkdir "$lockdir" >/dev/null 2>&1; then 115fa225cbcSrjs break 116fa225cbcSrjs fi 117fa225cbcSrjs sleep 1 118fa225cbcSrjsdone 119fa225cbcSrjs# FIXME: race condition here if user kills between mkdir and trap. 120fa225cbcSrjstrap "rmdir '$lockdir'; exit 1" 1 2 15 121fa225cbcSrjs 122fa225cbcSrjs# Run the compile. 123fa225cbcSrjs"$@" 124fa225cbcSrjsret=$? 125fa225cbcSrjs 126fa225cbcSrjsif test -f "$cofile"; then 127fa225cbcSrjs mv "$cofile" "$ofile" 128fa225cbcSrjselif test -f "${cofile}bj"; then 129fa225cbcSrjs mv "${cofile}bj" "$ofile" 130fa225cbcSrjsfi 131fa225cbcSrjs 132fa225cbcSrjsrmdir "$lockdir" 133fa225cbcSrjsexit $ret 134fa225cbcSrjs 135fa225cbcSrjs# Local Variables: 136fa225cbcSrjs# mode: shell-script 137fa225cbcSrjs# sh-indentation: 2 138fa225cbcSrjs# eval: (add-hook 'write-file-hooks 'time-stamp) 139fa225cbcSrjs# time-stamp-start: "scriptversion=" 140fa225cbcSrjs# time-stamp-format: "%:y-%02m-%02d.%02H" 141fa225cbcSrjs# time-stamp-end: "$" 142fa225cbcSrjs# End: 143