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