compile revision 91a17321
191a17321Smrg#! /bin/sh 291a17321Smrg# Wrapper for compilers which do not understand `-c -o'. 391a17321Smrg 491a17321Smrgscriptversion=2005-05-14.22 591a17321Smrg 691a17321Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 791a17321Smrg# Written by Tom Tromey <tromey@cygnus.com>. 891a17321Smrg# 991a17321Smrg# This program is free software; you can redistribute it and/or modify 1091a17321Smrg# it under the terms of the GNU General Public License as published by 1191a17321Smrg# the Free Software Foundation; either version 2, or (at your option) 1291a17321Smrg# any later version. 1391a17321Smrg# 1491a17321Smrg# This program is distributed in the hope that it will be useful, 1591a17321Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1691a17321Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1791a17321Smrg# GNU General Public License for more details. 1891a17321Smrg# 1991a17321Smrg# You should have received a copy of the GNU General Public License 2091a17321Smrg# along with this program; if not, write to the Free Software 2191a17321Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 2291a17321Smrg 2391a17321Smrg# As a special exception to the GNU General Public License, if you 2491a17321Smrg# distribute this file as part of a program that contains a 2591a17321Smrg# configuration script generated by Autoconf, you may include it under 2691a17321Smrg# the same distribution terms that you use for the rest of that program. 2791a17321Smrg 2891a17321Smrg# This file is maintained in Automake, please report 2991a17321Smrg# bugs to <bug-automake@gnu.org> or send patches to 3091a17321Smrg# <automake-patches@gnu.org>. 3191a17321Smrg 3291a17321Smrgcase $1 in 3391a17321Smrg '') 3491a17321Smrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2 3591a17321Smrg exit 1; 3691a17321Smrg ;; 3791a17321Smrg -h | --h*) 3891a17321Smrg cat <<\EOF 3991a17321SmrgUsage: compile [--help] [--version] PROGRAM [ARGS] 4091a17321Smrg 4191a17321SmrgWrapper for compilers which do not understand `-c -o'. 4291a17321SmrgRemove `-o dest.o' from ARGS, run PROGRAM with the remaining 4391a17321Smrgarguments, and rename the output as expected. 4491a17321Smrg 4591a17321SmrgIf you are trying to build a whole package this is not the 4691a17321Smrgright script to run: please start by reading the file `INSTALL'. 4791a17321Smrg 4891a17321SmrgReport bugs to <bug-automake@gnu.org>. 4991a17321SmrgEOF 5091a17321Smrg exit $? 5191a17321Smrg ;; 5291a17321Smrg -v | --v*) 5391a17321Smrg echo "compile $scriptversion" 5491a17321Smrg exit $? 5591a17321Smrg ;; 5691a17321Smrgesac 5791a17321Smrg 5891a17321Smrgofile= 5991a17321Smrgcfile= 6091a17321Smrgeat= 6191a17321Smrg 6291a17321Smrgfor arg 6391a17321Smrgdo 6491a17321Smrg if test -n "$eat"; then 6591a17321Smrg eat= 6691a17321Smrg else 6791a17321Smrg case $1 in 6891a17321Smrg -o) 6991a17321Smrg # configure might choose to run compile as `compile cc -o foo foo.c'. 7091a17321Smrg # So we strip `-o arg' only if arg is an object. 7191a17321Smrg eat=1 7291a17321Smrg case $2 in 7391a17321Smrg *.o | *.obj) 7491a17321Smrg ofile=$2 7591a17321Smrg ;; 7691a17321Smrg *) 7791a17321Smrg set x "$@" -o "$2" 7891a17321Smrg shift 7991a17321Smrg ;; 8091a17321Smrg esac 8191a17321Smrg ;; 8291a17321Smrg *.c) 8391a17321Smrg cfile=$1 8491a17321Smrg set x "$@" "$1" 8591a17321Smrg shift 8691a17321Smrg ;; 8791a17321Smrg *) 8891a17321Smrg set x "$@" "$1" 8991a17321Smrg shift 9091a17321Smrg ;; 9191a17321Smrg esac 9291a17321Smrg fi 9391a17321Smrg shift 9491a17321Smrgdone 9591a17321Smrg 9691a17321Smrgif test -z "$ofile" || test -z "$cfile"; then 9791a17321Smrg # If no `-o' option was seen then we might have been invoked from a 9891a17321Smrg # pattern rule where we don't need one. That is ok -- this is a 9991a17321Smrg # normal compilation that the losing compiler can handle. If no 10091a17321Smrg # `.c' file was seen then we are probably linking. That is also 10191a17321Smrg # ok. 10291a17321Smrg exec "$@" 10391a17321Smrgfi 10491a17321Smrg 10591a17321Smrg# Name of file we expect compiler to create. 10691a17321Smrgcofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'` 10791a17321Smrg 10891a17321Smrg# Create the lock directory. 10991a17321Smrg# Note: use `[/.-]' here to ensure that we don't use the same name 11091a17321Smrg# that we are using for the .o file. Also, base the name on the expected 11191a17321Smrg# object file name, since that is what matters with a parallel build. 11291a17321Smrglockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d 11391a17321Smrgwhile true; do 11491a17321Smrg if mkdir "$lockdir" >/dev/null 2>&1; then 11591a17321Smrg break 11691a17321Smrg fi 11791a17321Smrg sleep 1 11891a17321Smrgdone 11991a17321Smrg# FIXME: race condition here if user kills between mkdir and trap. 12091a17321Smrgtrap "rmdir '$lockdir'; exit 1" 1 2 15 12191a17321Smrg 12291a17321Smrg# Run the compile. 12391a17321Smrg"$@" 12491a17321Smrgret=$? 12591a17321Smrg 12691a17321Smrgif test -f "$cofile"; then 12791a17321Smrg mv "$cofile" "$ofile" 12891a17321Smrgelif test -f "${cofile}bj"; then 12991a17321Smrg mv "${cofile}bj" "$ofile" 13091a17321Smrgfi 13191a17321Smrg 13291a17321Smrgrmdir "$lockdir" 13391a17321Smrgexit $ret 13491a17321Smrg 13591a17321Smrg# Local Variables: 13691a17321Smrg# mode: shell-script 13791a17321Smrg# sh-indentation: 2 13891a17321Smrg# eval: (add-hook 'write-file-hooks 'time-stamp) 13991a17321Smrg# time-stamp-start: "scriptversion=" 14091a17321Smrg# time-stamp-format: "%:y-%02m-%02d.%02H" 14191a17321Smrg# time-stamp-end: "$" 14291a17321Smrg# End: 143