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