~ubuntu-branches/ubuntu/lucid/sage/lucid

« back to all changes in this revision

Viewing changes to compile

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2007-12-24 11:26:32 UTC
  • mfrom: (1.1.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20071224112632-lle5ptmz1sa60orh
Tags: 0.2.0-3
* Fixed clean target in debian/rules.
* Replaced ${Source-Version} in debian/control.
* Updated Standards-Version to 3.7.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /bin/sh
2
2
# Wrapper for compilers which do not understand `-c -o'.
3
3
 
4
 
scriptversion=2003-11-09.00
 
4
scriptversion=2005-05-14.22
5
5
 
6
 
# Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
 
6
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
7
7
# Written by Tom Tromey <tromey@cygnus.com>.
8
8
#
9
9
# This program is free software; you can redistribute it and/or modify
18
18
#
19
19
# You should have received a copy of the GNU General Public License
20
20
# along with this program; if not, write to the Free Software
21
 
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
21
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
22
 
23
23
# As a special exception to the GNU General Public License, if you
24
24
# distribute this file as part of a program that contains a
47
47
 
48
48
Report bugs to <bug-automake@gnu.org>.
49
49
EOF
50
 
    exit 0
 
50
    exit $?
51
51
    ;;
52
52
  -v | --v*)
53
53
    echo "compile $scriptversion"
54
 
    exit 0
 
54
    exit $?
55
55
    ;;
56
56
esac
57
57
 
58
 
 
59
 
prog=$1
60
 
shift
61
 
 
62
58
ofile=
63
59
cfile=
64
 
args=
65
 
while test $# -gt 0; do
66
 
  case "$1" in
67
 
    -o)
68
 
      # configure might choose to run compile as `compile cc -o foo foo.c'.
69
 
      # So we do something ugly here.
70
 
      ofile=$2
71
 
      shift
72
 
      case "$ofile" in
73
 
        *.o | *.obj)
74
 
          ;;
75
 
        *)
76
 
          args="$args -o $ofile"
77
 
          ofile=
78
 
          ;;
79
 
      esac
80
 
       ;;
81
 
    *.c)
82
 
      cfile=$1
83
 
      args="$args $1"
84
 
      ;;
85
 
    *)
86
 
      args="$args $1"
87
 
      ;;
88
 
  esac
 
60
eat=
 
61
 
 
62
for arg
 
63
do
 
64
  if test -n "$eat"; then
 
65
    eat=
 
66
  else
 
67
    case $1 in
 
68
      -o)
 
69
        # configure might choose to run compile as `compile cc -o foo foo.c'.
 
70
        # So we strip `-o arg' only if arg is an object.
 
71
        eat=1
 
72
        case $2 in
 
73
          *.o | *.obj)
 
74
            ofile=$2
 
75
            ;;
 
76
          *)
 
77
            set x "$@" -o "$2"
 
78
            shift
 
79
            ;;
 
80
        esac
 
81
        ;;
 
82
      *.c)
 
83
        cfile=$1
 
84
        set x "$@" "$1"
 
85
        shift
 
86
        ;;
 
87
      *)
 
88
        set x "$@" "$1"
 
89
        shift
 
90
        ;;
 
91
    esac
 
92
  fi
89
93
  shift
90
94
done
91
95
 
95
99
  # normal compilation that the losing compiler can handle.  If no
96
100
  # `.c' file was seen then we are probably linking.  That is also
97
101
  # ok.
98
 
  exec "$prog" $args
 
102
  exec "$@"
99
103
fi
100
104
 
101
105
# Name of file we expect compiler to create.
102
 
cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
 
106
cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
103
107
 
104
108
# Create the lock directory.
105
109
# Note: use `[/.-]' here to ensure that we don't use the same name
106
110
# that we are using for the .o file.  Also, base the name on the expected
107
111
# object file name, since that is what matters with a parallel build.
108
 
lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d
 
112
lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
109
113
while true; do
110
 
  if mkdir $lockdir > /dev/null 2>&1; then
 
114
  if mkdir "$lockdir" >/dev/null 2>&1; then
111
115
    break
112
116
  fi
113
117
  sleep 1
114
118
done
115
119
# FIXME: race condition here if user kills between mkdir and trap.
116
 
trap "rmdir $lockdir; exit 1" 1 2 15
 
120
trap "rmdir '$lockdir'; exit 1" 1 2 15
117
121
 
118
122
# Run the compile.
119
 
"$prog" $args
120
 
status=$?
 
123
"$@"
 
124
ret=$?
121
125
 
122
126
if test -f "$cofile"; then
123
127
  mv "$cofile" "$ofile"
 
128
elif test -f "${cofile}bj"; then
 
129
  mv "${cofile}bj" "$ofile"
124
130
fi
125
131
 
126
 
rmdir $lockdir
127
 
exit $status
 
132
rmdir "$lockdir"
 
133
exit $ret
128
134
 
129
135
# Local Variables:
130
136
# mode: shell-script