compile revision ef421f66f47224a42073deaf087378c5d0c9952e
7e5b2100ea65658a7ec3795919b4ecd29a6f118aMark Andrews# Wrapper for compilers which do not understand `-c -o'.
821d2613356f81e5bb5c107288d6d5cf35c2a1e8Mark Andrews# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software
46e873c835bf7d9ec3e1097e0aceb8db5b1ae93aMark Andrews# Foundation, Inc.
a3b428812703d22a605a9f882e71ed65f0ffdc65Mark Andrews# Written by Tom Tromey <tromey@cygnus.com>.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# This program is free software; you can redistribute it and/or modify
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# it under the terms of the GNU General Public License as published by
068a66979695c77359e7a9181bb3f831c965b21cMark Andrews# the Free Software Foundation; either version 2, or (at your option)
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# any later version.
c718d15a9a95054ee3c71540c02335426071fc6dMark Andrews# This program is distributed in the hope that it will be useful,
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews# but WITHOUT ANY WARRANTY; without even the implied warranty of
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c718d15a9a95054ee3c71540c02335426071fc6dMark Andrews# GNU General Public License for more details.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# You should have received a copy of the GNU General Public License
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# along with this program. If not, see <http://www.gnu.org/licenses/>.
c718d15a9a95054ee3c71540c02335426071fc6dMark Andrews# As a special exception to the GNU General Public License, if you
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# distribute this file as part of a program that contains a
821d2613356f81e5bb5c107288d6d5cf35c2a1e8Mark Andrews# configuration script generated by Autoconf, you may include it under
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson# the same distribution terms that you use for the rest of that program.
821d2613356f81e5bb5c107288d6d5cf35c2a1e8Mark Andrews# This file is maintained in Automake, please report
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson# bugs to <bug-automake@gnu.org> or send patches to
821d2613356f81e5bb5c107288d6d5cf35c2a1e8Mark Andrews# <automake-patches@gnu.org>.
c718d15a9a95054ee3c71540c02335426071fc6dMark Andrews echo "$0: No command. Try \`$0 --help' for more information." 1>&2
4038ab55037184d76153afd3c469aa8c85adf85dMark AndrewsUsage: compile [--help] [--version] PROGRAM [ARGS]
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark AndrewsWrapper for compilers which do not understand `-c -o'.
bac2ed6ec3fbb5420e6ce69dd1218745d4e02b1eMark AndrewsRemove `-o dest.o' from ARGS, run PROGRAM with the remaining
1eb1e1e838d2ea00b166c918bf50764a95826be8Mark AndrewsIf you are trying to build a whole package this is not the
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsright script to run: please start by reading the file `INSTALL'.
91216cff91b34c9ff6e846dc23f248219cafe660Andreas GustafssonReport bugs to <bug-automake@gnu.org>.
821d2613356f81e5bb5c107288d6d5cf35c2a1e8Mark Andrews echo "compile $scriptversion"
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews if test -n "$eat"; then
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson # configure might choose to run compile as `compile cc -o foo foo.c'.
821d2613356f81e5bb5c107288d6d5cf35c2a1e8Mark Andrews # So we strip `-o arg' only if arg is an object.
413988c8166976498250c0ebb2e3a645d0366bd3Mark Andrews set x "$@" "$1"
413988c8166976498250c0ebb2e3a645d0366bd3Mark Andrews set x "$@" "$1"
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews # If no `-o' option was seen then we might have been invoked from a
642e0716c8b4ab82ebc8e60f94c9e897ee89f19aMark Andrews # pattern rule where we don't need one. That is ok -- this is a
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews # normal compilation that the losing compiler can handle. If no
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews # `.c' file was seen then we are probably linking. That is also
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews# Name of file we expect compiler to create.
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrewscofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
413988c8166976498250c0ebb2e3a645d0366bd3Mark Andrews# Create the lock directory.
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews# Note: use `[/\\:.-]' here to ensure that we don't use the same name
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews# that we are using for the .o file. Also, base the name on the expected
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews# object file name, since that is what matters with a parallel build.
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrewslockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrewswhile true; do
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# FIXME: race condition here if user kills between mkdir and trap.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# Run the compile.
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsif test -f "$cofile"; then
46e873c835bf7d9ec3e1097e0aceb8db5b1ae93aMark Andrews test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewselif test -f "${cofile}bj"; then
ed178efa9ab8f813538fce4ff603b81ded9f1799Mark Andrews test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews# Local Variables:
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews# mode: shell-script
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# sh-indentation: 2
068a66979695c77359e7a9181bb3f831c965b21cMark Andrews# eval: (add-hook 'write-file-hooks 'time-stamp)
a9789e288ee11ae4315e27235c33bae5405bd7c4Mark Andrews# time-stamp-start: "scriptversion="
642e0716c8b4ab82ebc8e60f94c9e897ee89f19aMark Andrews# time-stamp-format: "%:y-%02m-%02d.%02H"
1eb1e1e838d2ea00b166c918bf50764a95826be8Mark Andrews# time-stamp-time-zone: "UTC"
068a66979695c77359e7a9181bb3f831c965b21cMark Andrews# time-stamp-end: "; # UTC"