1#! /bin/sh 2# set -x 3# 4# %CopyrightBegin% 5# 6# Copyright Ericsson AB 2002-2016. All Rights Reserved. 7# 8# Licensed under the Apache License, Version 2.0 (the "License"); 9# you may not use this file except in compliance with the License. 10# You may obtain a copy of the License at 11# 12# http://www.apache.org/licenses/LICENSE-2.0 13# 14# Unless required by applicable law or agreed to in writing, software 15# distributed under the License is distributed on an "AS IS" BASIS, 16# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17# See the License for the specific language governing permissions and 18# limitations under the License. 19# 20# %CopyrightEnd% 21# 22# Save the command line for debug outputs 23SAVE="$@" 24CMD="" 25OUTPUT_DIRNAME="" 26 27# Find the correct mc.exe. This could be done by the configure script, 28# But as we seldom use the message compiler, it might as well be done here... 29MCC="" 30save_ifs=$IFS 31IFS=: 32for p in $PATH; do 33 if [ -f $p/mc.exe ]; then 34 if [ -n "`$p/mc.exe -? 2>&1 >/dev/null </dev/null \ 35 | grep -i \"message compiler\"`" ]; then 36 MCC=`echo "mc.exe" | sed 's/ /\\\\ /g'` 37 break 38 else 39 echo "Bad mc.exe in path" >&2 40 exit 1 41 fi 42 fi 43done 44IFS=$save_ifs 45 46if [ -z "$MCC" ]; then 47 echo 'mc.exe not found!' >&2 48 exit 1 49fi 50 51while test -n "$1" ; do 52 x="$1" 53 case "$x" in 54 -o) 55 shift 56 OUTPUT_DIRNAME="$1";; 57 -o/*) 58 y=`echo $x | sed 's,^-[Io]\(/.*\),\1,g'`; 59 OUTPUT_DIRNAME="$y";; 60 -I) 61 shift 62 MPATH=`w32_path.sh -d $1`; 63 CMD="$CMD -I\"$MPATH\"";; 64 -I/*) 65 y=`echo $x | sed 's,^-[Io]\(/.*\),\1,g'`; 66 MPATH=`w32_path.sh -d $y`; 67 CMD="$CMD -I\"$MPATH\"";; 68 *) 69 MPATH=`w32_path.sh -d -a $x`; 70 CMD="$CMD \"$MPATH\"";; 71 esac 72 shift 73done 74p=$$ 75if [ "X$MC_SH_DEBUG_LOG" != "X" ]; then 76 echo mc.sh "$SAVE" >>$MC_SH_DEBUG_LOG 77 echo mc.exe $CMD >>$MC_SH_DEBUG_LOG 78fi 79if [ -n "$OUTPUT_DIRNAME" ]; then 80 cd $OUTPUT_DIRNAME 81 RES=$? 82 if [ "$RES" != "0" ]; then 83 echo "mc.sh: Error: could not cd to $OUTPUT_DIRNAME">&2 84 exit $RES 85 fi 86fi 87 88eval $MCC "$CMD" >/tmp/mc.exe.${p}.1 2>/tmp/mc.exe.${p}.2 89RES=$? 90if [ $RES != 0 ]; then 91 echo Failed: $MCC "$CMD" 92fi 93tail -n +2 /tmp/mc.exe.${p}.2 >&2 94cat /tmp/mc.exe.${p}.1 95rm -f /tmp/mc.exe.${p}.2 /tmp/mc.exe.${p}.1 96exit $RES 97