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