• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/gettext-0.17/gettext-runtime/
1#!/bin/sh
2# Compile a C# program.
3
4# Copyright (C) 2003-2006 Free Software Foundation, Inc.
5# Written by Bruno Haible <bruno@clisp.org>, 2003.
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20# This uses the same choices as csharpcomp.c, but instead of relying on the
21# environment settings at run time, it uses the environment variables
22# present at configuration time.
23#
24# This is a separate shell script, because the various C# compilers have
25# different command line options.
26#
27# Usage: /bin/sh csharpcomp.sh [OPTION] SOURCE.cs ... RES.resource ...
28# Options:
29#   -o PROGRAM.exe  or  -o LIBRARY.dll
30#                     set the output assembly name
31#   -L DIRECTORY      search for C# libraries also in DIRECTORY
32#   -l LIBRARY        reference the C# library LIBRARY.dll
33#   -O                optimize
34#   -g                generate debugging information
35
36# func_tmpdir
37# creates a temporary directory.
38# Sets variable
39# - tmp             pathname of freshly created temporary directory
40func_tmpdir ()
41{
42  # Use the environment variable TMPDIR, falling back to /tmp. This allows
43  # users to specify a different temporary directory, for example, if their
44  # /tmp is filled up or too small.
45  : ${TMPDIR=/tmp}
46  {
47    # Use the mktemp program if available. If not available, hide the error
48    # message.
49    tmp=`(umask 077 && mktemp -d -q "$TMPDIR/gtXXXXXX") 2>/dev/null` &&
50    test -n "$tmp" && test -d "$tmp"
51  } ||
52  {
53    # Use a simple mkdir command. It is guaranteed to fail if the directory
54    # already exists.  $RANDOM is bash specific and expands to empty in shells
55    # other than bash, ksh and zsh.  Its use does not increase security;
56    # rather, it minimizes the probability of failure in a very cluttered /tmp
57    # directory.
58    tmp=$TMPDIR/gt$$-$RANDOM
59    (umask 077 && mkdir "$tmp")
60  } ||
61  {
62    echo "$0: cannot create a temporary directory in $TMPDIR" >&2
63    { (exit 1); exit 1; }
64  }
65}
66
67sed_quote_subst='s/\([|&;<>()$`"'"'"'*?[#~=% 	\\]\)/\\\1/g'
68options_cscc=
69options_mcs=
70options_csc="-nologo"
71sources=
72while test $# != 0; do
73  case "$1" in
74    -o)
75      case "$2" in
76        *.dll)
77          options_cscc="$options_cscc -shared"
78          options_mcs="$options_mcs -target:library"
79          options_csc="$options_csc -target:library"
80          ;;
81        *.exe)
82          options_csc="$options_csc -target:exe"
83          ;;
84      esac
85      options_cscc="$options_cscc -o "`echo "$2" | sed -e "$sed_quote_subst"`
86      options_mcs="$options_mcs -out:"`echo "$2" | sed -e "$sed_quote_subst"`
87      options_csc="$options_csc -out:"`echo "$2" | sed -e "$sed_quote_subst"`
88      shift
89      ;;
90    -L)
91      options_cscc="$options_cscc -L "`echo "$2" | sed -e "$sed_quote_subst"`
92      options_mcs="$options_mcs -lib:"`echo "$2" | sed -e "$sed_quote_subst"`
93      options_csc="$options_csc -lib:"`echo "$2" | sed -e "$sed_quote_subst"`
94      shift
95      ;;
96    -l)
97      options_cscc="$options_cscc -l "`echo "$2" | sed -e "$sed_quote_subst"`
98      options_mcs="$options_mcs -reference:"`echo "$2" | sed -e "$sed_quote_subst"`
99      options_csc="$options_csc -reference:"`echo "$2" | sed -e "$sed_quote_subst"`".dll"
100      shift
101      ;;
102    -O)
103      options_cscc="$options_cscc -O"
104      options_csc="$options_csc -optimize+"
105      ;;
106    -g)
107      options_cscc="$options_cscc -g"
108      options_mcs="$options_mcs -debug"
109      options_csc="$options_csc -debug+"
110      ;;
111    -*)
112      echo "csharpcomp: unknown option '$1'" 1>&2
113      exit 1
114      ;;
115    *.resources)
116      options_cscc="$options_cscc -fresources="`echo "$1" | sed -e "$sed_quote_subst"`
117      options_mcs="$options_mcs -resource:"`echo "$1" | sed -e "$sed_quote_subst"`
118      options_csc="$options_csc -resource:"`echo "$1" | sed -e "$sed_quote_subst"`
119      ;;
120    *.cs)
121      sources="$sources "`echo "$1" | sed -e "$sed_quote_subst"`
122      ;;
123    *)
124      echo "csharpcomp: unknown type of argument '$1'" 1>&2
125      exit 1
126      ;;
127  esac
128  shift
129done
130
131if test -n ""; then
132  test -z "$CSHARP_VERBOSE" || echo cscc $options_cscc $sources
133  exec cscc $options_cscc $sources
134else
135  if test -n "1"; then
136    # mcs prints it errors and warnings to stdout, not stderr. Furthermore it
137    # adds a useless line "Compilation succeeded..." at the end. Correct both.
138    sed_drop_success_line='${
139/^Compilation succeeded/d
140}'
141    func_tmpdir
142    trap 'rm -rf "$tmp"' 1 2 3 15
143    test -z "$CSHARP_VERBOSE" || echo mcs $options_mcs $sources
144    mcs $options_mcs $sources > "$tmp"/mcs.err
145    result=$?
146    sed -e "$sed_drop_success_line" < "$tmp"/mcs.err >&2
147    rm -rf "$tmp"
148    exit $result
149  else
150    if test -n ""; then
151      test -z "$CSHARP_VERBOSE" || echo csc $options_csc $sources
152      exec csc $options_csc $sources
153    else
154      echo 'C# compiler not found, try installing pnet, then reconfigure' 1>&2
155      exit 1
156    fi
157  fi
158fi
159