annotate lib/swig/swigwin-2.0.11/Tools/config/compile @ 2169:5b27c035a241

small cleaning
author Ritor1
date Mon, 20 Jan 2014 00:02:22 +0600
parents b3009adc0e2f
children
rev   line source
1899
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
1 #! /bin/sh
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
2 # Wrapper for compilers which do not understand '-c -o'.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
3
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
4 scriptversion=2012-01-04.17; # UTC
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
5
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
6 # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
7 # Software Foundation, Inc.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
8 # Written by Tom Tromey <tromey@cygnus.com>.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
9 #
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
10 # This program is free software; you can redistribute it and/or modify
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
11 # it under the terms of the GNU General Public License as published by
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
12 # the Free Software Foundation; either version 2, or (at your option)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
13 # any later version.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
14 #
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
15 # This program is distributed in the hope that it will be useful,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
18 # GNU General Public License for more details.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
19 #
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
20 # You should have received a copy of the GNU General Public License
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
22
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
23 # As a special exception to the GNU General Public License, if you
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
24 # distribute this file as part of a program that contains a
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
25 # configuration script generated by Autoconf, you may include it under
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
26 # the same distribution terms that you use for the rest of that program.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
27
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
28 # This file is maintained in Automake, please report
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
29 # bugs to <bug-automake@gnu.org> or send patches to
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
30 # <automake-patches@gnu.org>.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
31
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
32 nl='
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
33 '
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
34
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
35 # We need space, tab and new line, in precisely that order. Quoting is
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
36 # there to prevent tools from complaining about whitespace usage.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
37 IFS=" "" $nl"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
38
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
39 file_conv=
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
40
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
41 # func_file_conv build_file lazy
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
42 # Convert a $build file to $host form and store it in $file
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
43 # Currently only supports Windows hosts. If the determined conversion
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
44 # type is listed in (the comma separated) LAZY, no conversion will
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
45 # take place.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
46 func_file_conv ()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
47 {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
48 file=$1
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
49 case $file in
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
50 / | /[!/]*) # absolute file, and not a UNC file
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
51 if test -z "$file_conv"; then
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
52 # lazily determine how to convert abs files
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
53 case `uname -s` in
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
54 MINGW*)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
55 file_conv=mingw
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
56 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
57 CYGWIN*)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
58 file_conv=cygwin
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
59 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
60 *)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
61 file_conv=wine
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
62 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
63 esac
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
64 fi
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
65 case $file_conv/,$2, in
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
66 *,$file_conv,*)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
67 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
68 mingw/*)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
69 file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
70 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
71 cygwin/*)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
72 file=`cygpath -m "$file" || echo "$file"`
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
73 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
74 wine/*)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
75 file=`winepath -w "$file" || echo "$file"`
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
76 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
77 esac
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
78 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
79 esac
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
80 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
81
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
82 # func_cl_wrapper cl arg...
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
83 # Adjust compile command to suit cl
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
84 func_cl_wrapper ()
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
85 {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
86 # Assume a capable shell
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
87 lib_path=
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
88 shared=:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
89 linker_opts=
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
90 for arg
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
91 do
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
92 if test -n "$eat"; then
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
93 eat=
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
94 else
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
95 case $1 in
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
96 -o)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
97 # configure might choose to run compile as 'compile cc -o foo foo.c'.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
98 eat=1
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
99 case $2 in
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
100 *.o | *.[oO][bB][jJ])
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
101 func_file_conv "$2"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
102 set x "$@" -Fo"$file"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
103 shift
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
104 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
105 *)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
106 func_file_conv "$2"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
107 set x "$@" -Fe"$file"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
108 shift
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
109 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
110 esac
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
111 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
112 -I*)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
113 func_file_conv "${1#-I}" mingw
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
114 set x "$@" -I"$file"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
115 shift
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
116 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
117 -l*)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
118 lib=${1#-l}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
119 found=no
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
120 save_IFS=$IFS
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
121 IFS=';'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
122 for dir in $lib_path $LIB
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
123 do
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
124 IFS=$save_IFS
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
125 if $shared && test -f "$dir/$lib.dll.lib"; then
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
126 found=yes
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
127 set x "$@" "$dir/$lib.dll.lib"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
128 break
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
129 fi
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
130 if test -f "$dir/$lib.lib"; then
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
131 found=yes
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
132 set x "$@" "$dir/$lib.lib"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
133 break
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
134 fi
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
135 done
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
136 IFS=$save_IFS
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
137
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
138 test "$found" != yes && set x "$@" "$lib.lib"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
139 shift
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
140 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
141 -L*)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
142 func_file_conv "${1#-L}"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
143 if test -z "$lib_path"; then
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
144 lib_path=$file
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
145 else
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
146 lib_path="$lib_path;$file"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
147 fi
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
148 linker_opts="$linker_opts -LIBPATH:$file"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
149 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
150 -static)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
151 shared=false
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
152 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
153 -Wl,*)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
154 arg=${1#-Wl,}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
155 save_ifs="$IFS"; IFS=','
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
156 for flag in $arg; do
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
157 IFS="$save_ifs"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
158 linker_opts="$linker_opts $flag"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
159 done
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
160 IFS="$save_ifs"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
161 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
162 -Xlinker)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
163 eat=1
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
164 linker_opts="$linker_opts $2"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
165 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
166 -*)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
167 set x "$@" "$1"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
168 shift
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
169 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
170 *.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
171 func_file_conv "$1"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
172 set x "$@" -Tp"$file"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
173 shift
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
174 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
175 *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
176 func_file_conv "$1" mingw
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
177 set x "$@" "$file"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
178 shift
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
179 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
180 *)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
181 set x "$@" "$1"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
182 shift
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
183 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
184 esac
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
185 fi
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
186 shift
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
187 done
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
188 if test -n "$linker_opts"; then
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
189 linker_opts="-link$linker_opts"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
190 fi
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
191 exec "$@" $linker_opts
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
192 exit 1
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
193 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
194
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
195 eat=
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
196
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
197 case $1 in
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
198 '')
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
199 echo "$0: No command. Try '$0 --help' for more information." 1>&2
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
200 exit 1;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
201 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
202 -h | --h*)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
203 cat <<\EOF
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
204 Usage: compile [--help] [--version] PROGRAM [ARGS]
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
205
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
206 Wrapper for compilers which do not understand '-c -o'.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
207 Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
208 arguments, and rename the output as expected.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
209
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
210 If you are trying to build a whole package this is not the
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
211 right script to run: please start by reading the file 'INSTALL'.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
212
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
213 Report bugs to <bug-automake@gnu.org>.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
214 EOF
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
215 exit $?
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
216 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
217 -v | --v*)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
218 echo "compile $scriptversion"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
219 exit $?
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
220 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
221 cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
222 func_cl_wrapper "$@" # Doesn't return...
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
223 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
224 esac
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
225
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
226 ofile=
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
227 cfile=
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
228
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
229 for arg
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
230 do
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
231 if test -n "$eat"; then
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
232 eat=
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
233 else
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
234 case $1 in
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
235 -o)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
236 # configure might choose to run compile as 'compile cc -o foo foo.c'.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
237 # So we strip '-o arg' only if arg is an object.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
238 eat=1
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
239 case $2 in
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
240 *.o | *.obj)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
241 ofile=$2
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
242 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
243 *)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
244 set x "$@" -o "$2"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
245 shift
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
246 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
247 esac
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
248 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
249 *.c)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
250 cfile=$1
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
251 set x "$@" "$1"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
252 shift
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
253 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
254 *)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
255 set x "$@" "$1"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
256 shift
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
257 ;;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
258 esac
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
259 fi
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
260 shift
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
261 done
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
262
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
263 if test -z "$ofile" || test -z "$cfile"; then
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
264 # If no '-o' option was seen then we might have been invoked from a
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
265 # pattern rule where we don't need one. That is ok -- this is a
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
266 # normal compilation that the losing compiler can handle. If no
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
267 # '.c' file was seen then we are probably linking. That is also
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
268 # ok.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
269 exec "$@"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
270 fi
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
271
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
272 # Name of file we expect compiler to create.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
273 cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
274
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
275 # Create the lock directory.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
276 # Note: use '[/\\:.-]' here to ensure that we don't use the same name
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
277 # that we are using for the .o file. Also, base the name on the expected
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
278 # object file name, since that is what matters with a parallel build.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
279 lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
280 while true; do
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
281 if mkdir "$lockdir" >/dev/null 2>&1; then
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
282 break
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
283 fi
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
284 sleep 1
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
285 done
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
286 # FIXME: race condition here if user kills between mkdir and trap.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
287 trap "rmdir '$lockdir'; exit 1" 1 2 15
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
288
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
289 # Run the compile.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
290 "$@"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
291 ret=$?
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
292
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
293 if test -f "$cofile"; then
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
294 test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
295 elif test -f "${cofile}bj"; then
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
296 test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
297 fi
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
298
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
299 rmdir "$lockdir"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
300 exit $ret
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
301
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
302 # Local Variables:
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
303 # mode: shell-script
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
304 # sh-indentation: 2
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
305 # eval: (add-hook 'write-file-hooks 'time-stamp)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
306 # time-stamp-start: "scriptversion="
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
307 # time-stamp-format: "%:y-%02m-%02d.%02H"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
308 # time-stamp-time-zone: "UTC"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
309 # time-stamp-end: "; # UTC"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
310 # End: