annotate kdiff3/admin/compile @ 75:08ea9b86c12c

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