| 1 | # ltmain.sh - Provide generalized library-building support services. |
|---|
| 2 | # NOTE: Changing this file will not affect anything until you rerun ltconfig. |
|---|
| 3 | # |
|---|
| 4 | # Copyright (C) 1996-1999 Free Software Foundation, Inc. |
|---|
| 5 | # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 |
|---|
| 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 2 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, but |
|---|
| 13 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 15 | # 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, write to the Free Software |
|---|
| 19 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 20 | # |
|---|
| 21 | # As a special exception to the GNU General Public License, if you |
|---|
| 22 | # distribute this file as part of a program that contains a |
|---|
| 23 | # configuration script generated by Autoconf, you may include it under |
|---|
| 24 | # the same distribution terms that you use for the rest of that program. |
|---|
| 25 | |
|---|
| 26 | # Check that we have a working $echo. |
|---|
| 27 | if test "X$1" = X--no-reexec; then |
|---|
| 28 | # Discard the --no-reexec flag, and continue. |
|---|
| 29 | shift |
|---|
| 30 | elif test "X$1" = X--fallback-echo; then |
|---|
| 31 | # Avoid inline document here, it may be left over |
|---|
| 32 | : |
|---|
| 33 | elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then |
|---|
| 34 | # Yippee, $echo works! |
|---|
| 35 | : |
|---|
| 36 | else |
|---|
| 37 | # Restart under the correct shell, and then maybe $echo will work. |
|---|
| 38 | exec $SHELL "$0" --no-reexec ${1+"$@"} |
|---|
| 39 | fi |
|---|
| 40 | |
|---|
| 41 | if test "X$1" = X--fallback-echo; then |
|---|
| 42 | # used as fallback echo |
|---|
| 43 | shift |
|---|
| 44 | cat <<EOF |
|---|
| 45 | $* |
|---|
| 46 | EOF |
|---|
| 47 | exit 0 |
|---|
| 48 | fi |
|---|
| 49 | |
|---|
| 50 | # The name of this program. |
|---|
| 51 | progname=`$echo "$0" | sed 's%^.*/%%'` |
|---|
| 52 | modename="$progname" |
|---|
| 53 | |
|---|
| 54 | # Constants. |
|---|
| 55 | PROGRAM=ltmain.sh |
|---|
| 56 | PACKAGE=libtool |
|---|
| 57 | VERSION=1.3.3 |
|---|
| 58 | TIMESTAMP=" (1.385.2.181 1999/07/02 15:49:11)" |
|---|
| 59 | |
|---|
| 60 | default_mode= |
|---|
| 61 | help="Try \`$progname --help' for more information." |
|---|
| 62 | magic="%%%MAGIC variable%%%" |
|---|
| 63 | mkdir="mkdir" |
|---|
| 64 | mv="mv -f" |
|---|
| 65 | rm="rm -f" |
|---|
| 66 | |
|---|
| 67 | # Sed substitution that helps us do robust quoting. It backslashifies |
|---|
| 68 | # metacharacters that are still active within double-quoted strings. |
|---|
| 69 | Xsed='sed -e 1s/^X//' |
|---|
| 70 | sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' |
|---|
| 71 | SP2NL='tr \040 \012' |
|---|
| 72 | NL2SP='tr \015\012 \040\040' |
|---|
| 73 | |
|---|
| 74 | # NLS nuisances. |
|---|
| 75 | # Only set LANG and LC_ALL to C if already set. |
|---|
| 76 | # These must not be set unconditionally because not all systems understand |
|---|
| 77 | # e.g. LANG=C (notably SCO). |
|---|
| 78 | # We save the old values to restore during execute mode. |
|---|
| 79 | if test "${LC_ALL+set}" = set; then |
|---|
| 80 | save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL |
|---|
| 81 | fi |
|---|
| 82 | if test "${LANG+set}" = set; then |
|---|
| 83 | save_LANG="$LANG"; LANG=C; export LANG |
|---|
| 84 | fi |
|---|
| 85 | |
|---|
| 86 | if test "$LTCONFIG_VERSION" != "$VERSION"; then |
|---|
| 87 | echo "$modename: ltconfig version \`$LTCONFIG_VERSION' does not match $PROGRAM version \`$VERSION'" 1>&2 |
|---|
| 88 | echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 |
|---|
| 89 | exit 1 |
|---|
| 90 | fi |
|---|
| 91 | |
|---|
| 92 | if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then |
|---|
| 93 | echo "$modename: not configured to build any kind of library" 1>&2 |
|---|
| 94 | echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 |
|---|
| 95 | exit 1 |
|---|
| 96 | fi |
|---|
| 97 | |
|---|
| 98 | # Global variables. |
|---|
| 99 | mode=$default_mode |
|---|
| 100 | nonopt= |
|---|
| 101 | prev= |
|---|
| 102 | prevopt= |
|---|
| 103 | run= |
|---|
| 104 | show="$echo" |
|---|
| 105 | show_help= |
|---|
| 106 | execute_dlfiles= |
|---|
| 107 | lo2o="s/\\.lo\$/.${objext}/" |
|---|
| 108 | o2lo="s/\\.${objext}\$/.lo/" |
|---|
| 109 | |
|---|
| 110 | # Parse our command line options once, thoroughly. |
|---|
| 111 | while test $# -gt 0 |
|---|
| 112 | do |
|---|
| 113 | arg="$1" |
|---|
| 114 | shift |
|---|
| 115 | |
|---|
| 116 | case "$arg" in |
|---|
| 117 | -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; |
|---|
| 118 | *) optarg= ;; |
|---|
| 119 | esac |
|---|
| 120 | |
|---|
| 121 | # If the previous option needs an argument, assign it. |
|---|
| 122 | if test -n "$prev"; then |
|---|
| 123 | case "$prev" in |
|---|
| 124 | execute_dlfiles) |
|---|
| 125 | eval "$prev=\"\$$prev \$arg\"" |
|---|
| 126 | ;; |
|---|
| 127 | *) |
|---|
| 128 | eval "$prev=\$arg" |
|---|
| 129 | ;; |
|---|
| 130 | esac |
|---|
| 131 | |
|---|
| 132 | prev= |
|---|
| 133 | prevopt= |
|---|
| 134 | continue |
|---|
| 135 | fi |
|---|
| 136 | |
|---|
| 137 | # Have we seen a non-optional argument yet? |
|---|
| 138 | case "$arg" in |
|---|
| 139 | --help) |
|---|
| 140 | show_help=yes |
|---|
| 141 | ;; |
|---|
| 142 | |
|---|
| 143 | --version) |
|---|
| 144 | echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" |
|---|
| 145 | exit 0 |
|---|
| 146 | ;; |
|---|
| 147 | |
|---|
| 148 | --config) |
|---|
| 149 | sed -e '1,/^### BEGIN LIBTOOL CONFIG/d' -e '/^### END LIBTOOL CONFIG/,$d' $0 |
|---|
| 150 | exit 0 |
|---|
| 151 | ;; |
|---|
| 152 | |
|---|
| 153 | --debug) |
|---|
| 154 | echo "$progname: enabling shell trace mode" |
|---|
| 155 | set -x |
|---|
| 156 | ;; |
|---|
| 157 | |
|---|
| 158 | --dry-run | -n) |
|---|
| 159 | run=: |
|---|
| 160 | ;; |
|---|
| 161 | |
|---|
| 162 | --features) |
|---|
| 163 | echo "host: $host" |
|---|
| 164 | if test "$build_libtool_libs" = yes; then |
|---|
| 165 | echo "enable shared libraries" |
|---|
| 166 | else |
|---|
| 167 | echo "disable shared libraries" |
|---|
| 168 | fi |
|---|
| 169 | if test "$build_old_libs" = yes; then |
|---|
| 170 | echo "enable static libraries" |
|---|
| 171 | else |
|---|
| 172 | echo "disable static libraries" |
|---|
| 173 | fi |
|---|
| 174 | exit 0 |
|---|
| 175 | ;; |
|---|
| 176 | |
|---|
| 177 | --finish) mode="finish" ;; |
|---|
| 178 | |
|---|
| 179 | --mode) prevopt="--mode" prev=mode ;; |
|---|
| 180 | --mode=*) mode="$optarg" ;; |
|---|
| 181 | |
|---|
| 182 | --quiet | --silent) |
|---|
| 183 | show=: |
|---|
| 184 | ;; |
|---|
| 185 | |
|---|
| 186 | -dlopen) |
|---|
| 187 | prevopt="-dlopen" |
|---|
| 188 | prev=execute_dlfiles |
|---|
| 189 | ;; |
|---|
| 190 | |
|---|
| 191 | -*) |
|---|
| 192 | $echo "$modename: unrecognized option \`$arg'" 1>&2 |
|---|
| 193 | $echo "$help" 1>&2 |
|---|
| 194 | exit 1 |
|---|
| 195 | ;; |
|---|
| 196 | |
|---|
| 197 | *) |
|---|
| 198 | nonopt="$arg" |
|---|
| 199 | break |
|---|
| 200 | ;; |
|---|
| 201 | esac |
|---|
| 202 | done |
|---|
| 203 | |
|---|
| 204 | if test -n "$prevopt"; then |
|---|
| 205 | $echo "$modename: option \`$prevopt' requires an argument" 1>&2 |
|---|
| 206 | $echo "$help" 1>&2 |
|---|
| 207 | exit 1 |
|---|
| 208 | fi |
|---|
| 209 | |
|---|
| 210 | if test -z "$show_help"; then |
|---|
| 211 | |
|---|
| 212 | # Infer the operation mode. |
|---|
| 213 | if test -z "$mode"; then |
|---|
| 214 | case "$nonopt" in |
|---|
| 215 | *cc | *++ | gcc* | *-gcc*) |
|---|
| 216 | mode=link |
|---|
| 217 | for arg |
|---|
| 218 | do |
|---|
| 219 | case "$arg" in |
|---|
| 220 | -c) |
|---|
| 221 | mode=compile |
|---|
| 222 | break |
|---|
| 223 | ;; |
|---|
| 224 | esac |
|---|
| 225 | done |
|---|
| 226 | ;; |
|---|
| 227 | *db | *dbx | *strace | *truss) |
|---|
| 228 | mode=execute |
|---|
| 229 | ;; |
|---|
| 230 | *install*|cp|mv) |
|---|
| 231 | mode=install |
|---|
| 232 | ;; |
|---|
| 233 | *rm) |
|---|
| 234 | mode=uninstall |
|---|
| 235 | ;; |
|---|
| 236 | *) |
|---|
| 237 | # If we have no mode, but dlfiles were specified, then do execute mode. |
|---|
| 238 | test -n "$execute_dlfiles" && mode=execute |
|---|
| 239 | |
|---|
| 240 | # Just use the default operation mode. |
|---|
| 241 | if test -z "$mode"; then |
|---|
| 242 | if test -n "$nonopt"; then |
|---|
| 243 | $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 |
|---|
| 244 | else |
|---|
| 245 | $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 |
|---|
| 246 | fi |
|---|
| 247 | fi |
|---|
| 248 | ;; |
|---|
| 249 | esac |
|---|
| 250 | fi |
|---|
| 251 | |
|---|
| 252 | # Only execute mode is allowed to have -dlopen flags. |
|---|
| 253 | if test -n "$execute_dlfiles" && test "$mode" != execute; then |
|---|
| 254 | $echo "$modename: unrecognized option \`-dlopen'" 1>&2 |
|---|
| 255 | $echo "$help" 1>&2 |
|---|
| 256 | exit 1 |
|---|
| 257 | fi |
|---|
| 258 | |
|---|
| 259 | # Change the help message to a mode-specific one. |
|---|
| 260 | generic_help="$help" |
|---|
| 261 | help="Try \`$modename --help --mode=$mode' for more information." |
|---|
| 262 | |
|---|
| 263 | # These modes are in order of execution frequency so that they run quickly. |
|---|
| 264 | case "$mode" in |
|---|
| 265 | # libtool compile mode |
|---|
| 266 | compile) |
|---|
| 267 | modename="$modename: compile" |
|---|
| 268 | # Get the compilation command and the source file. |
|---|
| 269 | base_compile= |
|---|
| 270 | lastarg= |
|---|
| 271 | srcfile="$nonopt" |
|---|
| 272 | suppress_output= |
|---|
| 273 | |
|---|
| 274 | user_target=no |
|---|
| 275 | for arg |
|---|
| 276 | do |
|---|
| 277 | # Accept any command-line options. |
|---|
| 278 | case "$arg" in |
|---|
| 279 | -o) |
|---|
| 280 | if test "$user_target" != "no"; then |
|---|
| 281 | $echo "$modename: you cannot specify \`-o' more than once" 1>&2 |
|---|
| 282 | exit 1 |
|---|
| 283 | fi |
|---|
| 284 | user_target=next |
|---|
| 285 | ;; |
|---|
| 286 | |
|---|
| 287 | -static) |
|---|
| 288 | build_old_libs=yes |
|---|
| 289 | continue |
|---|
| 290 | ;; |
|---|
| 291 | esac |
|---|
| 292 | |
|---|
| 293 | case "$user_target" in |
|---|
| 294 | next) |
|---|
| 295 | # The next one is the -o target name |
|---|
| 296 | user_target=yes |
|---|
| 297 | continue |
|---|
| 298 | ;; |
|---|
| 299 | yes) |
|---|
| 300 | # We got the output file |
|---|
| 301 | user_target=set |
|---|
| 302 | libobj="$arg" |
|---|
| 303 | continue |
|---|
| 304 | ;; |
|---|
| 305 | esac |
|---|
| 306 | |
|---|
| 307 | # Accept the current argument as the source file. |
|---|
| 308 | lastarg="$srcfile" |
|---|
| 309 | srcfile="$arg" |
|---|
| 310 | |
|---|
| 311 | # Aesthetically quote the previous argument. |
|---|
| 312 | |
|---|
| 313 | # Backslashify any backslashes, double quotes, and dollar signs. |
|---|
| 314 | # These are the only characters that are still specially |
|---|
| 315 | # interpreted inside of double-quoted scrings. |
|---|
| 316 | lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` |
|---|
| 317 | |
|---|
| 318 | # Double-quote args containing other shell metacharacters. |
|---|
| 319 | # Many Bourne shells cannot handle close brackets correctly in scan |
|---|
| 320 | # sets, so we specify it separately. |
|---|
| 321 | case "$lastarg" in |
|---|
| 322 | *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) |
|---|
| 323 | lastarg="\"$lastarg\"" |
|---|
| 324 | ;; |
|---|
| 325 | esac |
|---|
| 326 | |
|---|
| 327 | # Add the previous argument to base_compile. |
|---|
| 328 | if test -z "$base_compile"; then |
|---|
| 329 | base_compile="$lastarg" |
|---|
| 330 | else |
|---|
| 331 | base_compile="$base_compile $lastarg" |
|---|
| 332 | fi |
|---|
| 333 | done |
|---|
| 334 | |
|---|
| 335 | case "$user_target" in |
|---|
| 336 | set) |
|---|
| 337 | ;; |
|---|
| 338 | no) |
|---|
| 339 | # Get the name of the library object. |
|---|
| 340 | libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` |
|---|
| 341 | ;; |
|---|
| 342 | *) |
|---|
| 343 | $echo "$modename: you must specify a target with \`-o'" 1>&2 |
|---|
| 344 | exit 1 |
|---|
| 345 | ;; |
|---|
| 346 | esac |
|---|
| 347 | |
|---|
| 348 | # Recognize several different file suffixes. |
|---|
| 349 | # If the user specifies -o file.o, it is replaced with file.lo |
|---|
| 350 | xform='[cCFSfmso]' |
|---|
| 351 | case "$libobj" in |
|---|
| 352 | *.ada) xform=ada ;; |
|---|
| 353 | *.adb) xform=adb ;; |
|---|
| 354 | *.ads) xform=ads ;; |
|---|
| 355 | *.asm) xform=asm ;; |
|---|
| 356 | *.c++) xform=c++ ;; |
|---|
| 357 | *.cc) xform=cc ;; |
|---|
| 358 | *.cpp) xform=cpp ;; |
|---|
| 359 | *.cxx) xform=cxx ;; |
|---|
| 360 | *.f90) xform=f90 ;; |
|---|
| 361 | *.for) xform=for ;; |
|---|
| 362 | esac |
|---|
| 363 | |
|---|
| 364 | libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` |
|---|
| 365 | |
|---|
| 366 | case "$libobj" in |
|---|
| 367 | *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; |
|---|
| 368 | *) |
|---|
| 369 | $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 |
|---|
| 370 | exit 1 |
|---|
| 371 | ;; |
|---|
| 372 | esac |
|---|
| 373 | |
|---|
| 374 | if test -z "$base_compile"; then |
|---|
| 375 | $echo "$modename: you must specify a compilation command" 1>&2 |
|---|
| 376 | $echo "$help" 1>&2 |
|---|
| 377 | exit 1 |
|---|
| 378 | fi |
|---|
| 379 | |
|---|
| 380 | # Delete any leftover library objects. |
|---|
| 381 | if test "$build_old_libs" = yes; then |
|---|
| 382 | removelist="$obj $libobj" |
|---|
| 383 | else |
|---|
| 384 | removelist="$libobj" |
|---|
| 385 | fi |
|---|
| 386 | |
|---|
| 387 | $run $rm $removelist |
|---|
| 388 | trap "$run $rm $removelist; exit 1" 1 2 15 |
|---|
| 389 | |
|---|
| 390 | # Calculate the filename of the output object if compiler does |
|---|
| 391 | # not support -o with -c |
|---|
| 392 | if test "$compiler_c_o" = no; then |
|---|
| 393 | output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\..*$%%'`.${objext} |
|---|
| 394 | lockfile="$output_obj.lock" |
|---|
| 395 | removelist="$removelist $output_obj $lockfile" |
|---|
| 396 | trap "$run $rm $removelist; exit 1" 1 2 15 |
|---|
| 397 | else |
|---|
| 398 | need_locks=no |
|---|
| 399 | lockfile= |
|---|
| 400 | fi |
|---|
| 401 | |
|---|
| 402 | # Lock this critical section if it is needed |
|---|
| 403 | # We use this script file to make the link, it avoids creating a new file |
|---|
| 404 | if test "$need_locks" = yes; then |
|---|
| 405 | until ln "$0" "$lockfile" 2>/dev/null; do |
|---|
| 406 | $show "Waiting for $lockfile to be removed" |
|---|
| 407 | sleep 2 |
|---|
| 408 | done |
|---|
| 409 | elif test "$need_locks" = warn; then |
|---|
| 410 | if test -f "$lockfile"; then |
|---|
| 411 | echo "\ |
|---|
| 412 | *** ERROR, $lockfile exists and contains: |
|---|
| 413 | `cat $lockfile 2>/dev/null` |
|---|
| 414 | |
|---|
| 415 | This indicates that another process is trying to use the same |
|---|
| 416 | temporary object file, and libtool could not work around it because |
|---|
| 417 | your compiler does not support \`-c' and \`-o' together. If you |
|---|
| 418 | repeat this compilation, it may succeed, by chance, but you had better |
|---|
| 419 | avoid parallel builds (make -j) in this platform, or get a better |
|---|
| 420 | compiler." |
|---|
| 421 | |
|---|
| 422 | $run $rm $removelist |
|---|
| 423 | exit 1 |
|---|
| 424 | fi |
|---|
| 425 | echo $srcfile > "$lockfile" |
|---|
| 426 | fi |
|---|
| 427 | |
|---|
| 428 | if test -n "$fix_srcfile_path"; then |
|---|
| 429 | eval srcfile=\"$fix_srcfile_path\" |
|---|
| 430 | fi |
|---|
| 431 | |
|---|
| 432 | # Only build a PIC object if we are building libtool libraries. |
|---|
| 433 | if test "$build_libtool_libs" = yes; then |
|---|
| 434 | # Without this assignment, base_compile gets emptied. |
|---|
| 435 | fbsd_hideous_sh_bug=$base_compile |
|---|
| 436 | |
|---|
| 437 | # All platforms use -DPIC, to notify preprocessed assembler code. |
|---|
| 438 | command="$base_compile $pic_flag -DPIC $srcfile" |
|---|
| 439 | if test "$build_old_libs" = yes; then |
|---|
| 440 | lo_libobj="$libobj" |
|---|
| 441 | dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` |
|---|
| 442 | if test "X$dir" = "X$libobj"; then |
|---|
| 443 | dir="$objdir" |
|---|
| 444 | else |
|---|
| 445 | dir="$dir/$objdir" |
|---|
| 446 | fi |
|---|
| 447 | libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` |
|---|
| 448 | |
|---|
| 449 | if test -d "$dir"; then |
|---|
| 450 | $show "$rm $libobj" |
|---|
| 451 | $run $rm $libobj |
|---|
| 452 | else |
|---|
| 453 | $show "$mkdir $dir" |
|---|
| 454 | $run $mkdir $dir |
|---|
| 455 | status=$? |
|---|
| 456 | if test $status -ne 0 && test ! -d $dir; then |
|---|
| 457 | exit $status |
|---|
| 458 | fi |
|---|
| 459 | fi |
|---|
| 460 | fi |
|---|
| 461 | if test "$compiler_o_lo" = yes; then |
|---|
| 462 | output_obj="$libobj" |
|---|
| 463 | command="$command -o $output_obj" |
|---|
| 464 | elif test "$compiler_c_o" = yes; then |
|---|
| 465 | output_obj="$obj" |
|---|
| 466 | command="$command -o $output_obj" |
|---|
| 467 | fi |
|---|
| 468 | |
|---|
| 469 | $run $rm "$output_obj" |
|---|
| 470 | $show "$command" |
|---|
| 471 | if $run eval "$command"; then : |
|---|
| 472 | else |
|---|
| 473 | test -n "$output_obj" && $run $rm $removelist |
|---|
| 474 | exit 1 |
|---|
| 475 | fi |
|---|
| 476 | |
|---|
| 477 | if test "$need_locks" = warn && |
|---|
| 478 | test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then |
|---|
| 479 | echo "\ |
|---|
| 480 | *** ERROR, $lockfile contains: |
|---|
| 481 | `cat $lockfile 2>/dev/null` |
|---|
| 482 | |
|---|
| 483 | but it should contain: |
|---|
| 484 | $srcfile |
|---|
| 485 | |
|---|
| 486 | This indicates that another process is trying to use the same |
|---|
| 487 | temporary object file, and libtool could not work around it because |
|---|
| 488 | your compiler does not support \`-c' and \`-o' together. If you |
|---|
| 489 | repeat this compilation, it may succeed, by chance, but you had better |
|---|
| 490 | avoid parallel builds (make -j) in this platform, or get a better |
|---|
| 491 | compiler." |
|---|
| 492 | |
|---|
| 493 | $run $rm $removelist |
|---|
| 494 | exit 1 |
|---|
| 495 | fi |
|---|
| 496 | |
|---|
| 497 | # Just move the object if needed, then go on to compile the next one |
|---|
| 498 | if test x"$output_obj" != x"$libobj"; then |
|---|
| 499 | $show "$mv $output_obj $libobj" |
|---|
| 500 | if $run $mv $output_obj $libobj; then : |
|---|
| 501 | else |
|---|
| 502 | error=$? |
|---|
| 503 | $run $rm $removelist |
|---|
| 504 | exit $error |
|---|
| 505 | fi |
|---|
| 506 | fi |
|---|
| 507 | |
|---|
| 508 | # If we have no pic_flag, then copy the object into place and finish. |
|---|
| 509 | if test -z "$pic_flag" && test "$build_old_libs" = yes; then |
|---|
| 510 | # Rename the .lo from within objdir to obj |
|---|
| 511 | if test -f $obj; then |
|---|
| 512 | $show $rm $obj |
|---|
| 513 | $run $rm $obj |
|---|
| 514 | fi |
|---|
| 515 | |
|---|
| 516 | $show "$mv $libobj $obj" |
|---|
| 517 | if $run $mv $libobj $obj; then : |
|---|
| 518 | else |
|---|
| 519 | error=$? |
|---|
| 520 | $run $rm $removelist |
|---|
| 521 | exit $error |
|---|
| 522 | fi |
|---|
| 523 | |
|---|
| 524 | # Now arrange that obj and lo_libobj become the same file |
|---|
| 525 | $show "$LN_S $obj $lo_libobj" |
|---|
| 526 | if $run $LN_S $obj $lo_libobj; then |
|---|
| 527 | exit 0 |
|---|
| 528 | else |
|---|
| 529 | error=$? |
|---|
| 530 | $run $rm $removelist |
|---|
| 531 | exit $error |
|---|
| 532 | fi |
|---|
| 533 | fi |
|---|
| 534 | |
|---|
| 535 | # Allow error messages only from the first compilation. |
|---|
| 536 | suppress_output=' >/dev/null 2>&1' |
|---|
| 537 | fi |
|---|
| 538 | |
|---|
| 539 | # Only build a position-dependent object if we build old libraries. |
|---|
| 540 | if test "$build_old_libs" = yes; then |
|---|
| 541 | command="$base_compile $srcfile" |
|---|
| 542 | if test "$compiler_c_o" = yes; then |
|---|
| 543 | command="$command -o $obj" |
|---|
| 544 | output_obj="$obj" |
|---|
| 545 | fi |
|---|
| 546 | |
|---|
| 547 | # Suppress compiler output if we already did a PIC compilation. |
|---|
| 548 | command="$command$suppress_output" |
|---|
| 549 | $run $rm "$output_obj" |
|---|
| 550 | $show "$command" |
|---|
| 551 | if $run eval "$command"; then : |
|---|
| 552 | else |
|---|
| 553 | $run $rm $removelist |
|---|
| 554 | exit 1 |
|---|
| 555 | fi |
|---|
| 556 | |
|---|
| 557 | if test "$need_locks" = warn && |
|---|
| 558 | test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then |
|---|
| 559 | echo "\ |
|---|
| 560 | *** ERROR, $lockfile contains: |
|---|
| 561 | `cat $lockfile 2>/dev/null` |
|---|
| 562 | |
|---|
| 563 | but it should contain: |
|---|
| 564 | $srcfile |
|---|
| 565 | |
|---|
| 566 | This indicates that another process is trying to use the same |
|---|
| 567 | temporary object file, and libtool could not work around it because |
|---|
| 568 | your compiler does not support \`-c' and \`-o' together. If you |
|---|
| 569 | repeat this compilation, it may succeed, by chance, but you had better |
|---|
| 570 | avoid parallel builds (make -j) in this platform, or get a better |
|---|
| 571 | compiler." |
|---|
| 572 | |
|---|
| 573 | $run $rm $removelist |
|---|
| 574 | exit 1 |
|---|
| 575 | fi |
|---|
| 576 | |
|---|
| 577 | # Just move the object if needed |
|---|
| 578 | if test x"$output_obj" != x"$obj"; then |
|---|
| 579 | $show "$mv $output_obj $obj" |
|---|
| 580 | if $run $mv $output_obj $obj; then : |
|---|
| 581 | else |
|---|
| 582 | error=$? |
|---|
| 583 | $run $rm $removelist |
|---|
| 584 | exit $error |
|---|
| 585 | fi |
|---|
| 586 | fi |
|---|
| 587 | |
|---|
| 588 | # Create an invalid libtool object if no PIC, so that we do not |
|---|
| 589 | # accidentally link it into a program. |
|---|
| 590 | if test "$build_libtool_libs" != yes; then |
|---|
| 591 | $show "echo timestamp > $libobj" |
|---|
| 592 | $run eval "echo timestamp > \$libobj" || exit $? |
|---|
| 593 | else |
|---|
| 594 | # Move the .lo from within objdir |
|---|
| 595 | $show "$mv $libobj $lo_libobj" |
|---|
| 596 | if $run $mv $libobj $lo_libobj; then : |
|---|
| 597 | else |
|---|
| 598 | error=$? |
|---|
| 599 | $run $rm $removelist |
|---|
| 600 | exit $error |
|---|
| 601 | fi |
|---|
| 602 | fi |
|---|
| 603 | fi |
|---|
| 604 | |
|---|
| 605 | # Unlock the critical section if it was locked |
|---|
| 606 | if test "$need_locks" != no; then |
|---|
| 607 | $rm "$lockfile" |
|---|
| 608 | fi |
|---|
| 609 | |
|---|
| 610 | exit 0 |
|---|
| 611 | ;; |
|---|
| 612 | |
|---|
| 613 | # libtool link mode |
|---|
| 614 | link) |
|---|
| 615 | modename="$modename: link" |
|---|
| 616 | C_compiler="$CC" # save it, to compile generated C sources |
|---|
| 617 | CC="$nonopt" |
|---|
| 618 | case "$host" in |
|---|
| 619 | *-*-cygwin* | *-*-mingw* | *-*-os2*) |
|---|
| 620 | # It is impossible to link a dll without this setting, and |
|---|
| 621 | # we shouldn't force the makefile maintainer to figure out |
|---|
| 622 | # which system we are compiling for in order to pass an extra |
|---|
| 623 | # flag for every libtool invokation. |
|---|
| 624 | # allow_undefined=no |
|---|
| 625 | |
|---|
| 626 | # FIXME: Unfortunately, there are problems with the above when trying |
|---|
| 627 | # to make a dll which has undefined symbols, in which case not |
|---|
| 628 | # even a static library is built. For now, we need to specify |
|---|
| 629 | # -no-undefined on the libtool link line when we can be certain |
|---|
| 630 | # that all symbols are satisfied, otherwise we get a static library. |
|---|
| 631 | allow_undefined=yes |
|---|
| 632 | |
|---|
| 633 | # This is a source program that is used to create dlls on Windows |
|---|
| 634 | # Don't remove nor modify the starting and closing comments |
|---|
| 635 | # /* ltdll.c starts here */ |
|---|
| 636 | # #define WIN32_LEAN_AND_MEAN |
|---|
| 637 | # #include <windows.h> |
|---|
| 638 | # #undef WIN32_LEAN_AND_MEAN |
|---|
| 639 | # #include <stdio.h> |
|---|
| 640 | # |
|---|
| 641 | # #ifndef __CYGWIN__ |
|---|
| 642 | # # ifdef __CYGWIN32__ |
|---|
| 643 | # # define __CYGWIN__ __CYGWIN32__ |
|---|
| 644 | # # endif |
|---|
| 645 | # #endif |
|---|
| 646 | # |
|---|
| 647 | # #ifdef __cplusplus |
|---|
| 648 | # extern "C" { |
|---|
| 649 | # #endif |
|---|
| 650 | # BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); |
|---|
| 651 | # #ifdef __cplusplus |
|---|
| 652 | # } |
|---|
| 653 | # #endif |
|---|
| 654 | # |
|---|
| 655 | # #ifdef __CYGWIN__ |
|---|
| 656 | # #include <cygwin/cygwin_dll.h> |
|---|
| 657 | # DECLARE_CYGWIN_DLL( DllMain ); |
|---|
| 658 | # #endif |
|---|
| 659 | # HINSTANCE __hDllInstance_base; |
|---|
| 660 | # |
|---|
| 661 | # BOOL APIENTRY |
|---|
| 662 | # DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) |
|---|
| 663 | # { |
|---|
| 664 | # __hDllInstance_base = hInst; |
|---|
| 665 | # return TRUE; |
|---|
| 666 | # } |
|---|
| 667 | # /* ltdll.c ends here */ |
|---|
| 668 | # This is a source program that is used to create import libraries |
|---|
| 669 | # on Windows for dlls which lack them. Don't remove nor modify the |
|---|
| 670 | # starting and closing comments |
|---|
| 671 | # /* impgen.c starts here */ |
|---|
| 672 | # /* Copyright (C) 1999 Free Software Foundation, Inc. |
|---|
| 673 | # |
|---|
| 674 | # This file is part of GNU libtool. |
|---|
| 675 | # |
|---|
| 676 | # This program is free software; you can redistribute it and/or modify |
|---|
| 677 | # it under the terms of the GNU General Public License as published by |
|---|
| 678 | # the Free Software Foundation; either version 2 of the License, or |
|---|
| 679 | # (at your option) any later version. |
|---|
| 680 | # |
|---|
| 681 | # This program is distributed in the hope that it will be useful, |
|---|
| 682 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 683 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 684 | # GNU General Public License for more details. |
|---|
| 685 | # |
|---|
| 686 | # You should have received a copy of the GNU General Public License |
|---|
| 687 | # along with this program; if not, write to the Free Software |
|---|
| 688 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 689 | # */ |
|---|
| 690 | # |
|---|
| 691 | # #include <stdio.h> /* for printf() */ |
|---|
| 692 | # #include <unistd.h> /* for open(), lseek(), read() */ |
|---|
| 693 | # #include <fcntl.h> /* for O_RDONLY, O_BINARY */ |
|---|
| 694 | # #include <string.h> /* for strdup() */ |
|---|
| 695 | # |
|---|
| 696 | # static unsigned int |
|---|
| 697 | # pe_get16 (fd, offset) |
|---|
| 698 | # int fd; |
|---|
| 699 | # int offset; |
|---|
| 700 | # { |
|---|
| 701 | # unsigned char b[2]; |
|---|
| 702 | # lseek (fd, offset, SEEK_SET); |
|---|
| 703 | # read (fd, b, 2); |
|---|
| 704 | # return b[0] + (b[1]<<8); |
|---|
| 705 | # } |
|---|
| 706 | # |
|---|
| 707 | # static unsigned int |
|---|
| 708 | # pe_get32 (fd, offset) |
|---|
| 709 | # int fd; |
|---|
| 710 | # int offset; |
|---|
| 711 | # { |
|---|
| 712 | # unsigned char b[4]; |
|---|
| 713 | # lseek (fd, offset, SEEK_SET); |
|---|
| 714 | # read (fd, b, 4); |
|---|
| 715 | # return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); |
|---|
| 716 | # } |
|---|
| 717 | # |
|---|
| 718 | # static unsigned int |
|---|
| 719 | # pe_as32 (ptr) |
|---|
| 720 | # void *ptr; |
|---|
| 721 | # { |
|---|
| 722 | # unsigned char *b = ptr; |
|---|
| 723 | # return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); |
|---|
| 724 | # } |
|---|
| 725 | # |
|---|
| 726 | # int |
|---|
| 727 | # main (argc, argv) |
|---|
| 728 | # int argc; |
|---|
| 729 | # char *argv[]; |
|---|
| 730 | # { |
|---|
| 731 | # int dll; |
|---|
| 732 | # unsigned long pe_header_offset, opthdr_ofs, num_entries, i; |
|---|
| 733 | # unsigned long export_rva, export_size, nsections, secptr, expptr; |
|---|
| 734 | # unsigned long name_rvas, nexp; |
|---|
| 735 | # unsigned char *expdata, *erva; |
|---|
| 736 | # char *filename, *dll_name; |
|---|
| 737 | # |
|---|
| 738 | # filename = argv[1]; |
|---|
| 739 | # |
|---|
| 740 | # dll = open(filename, O_RDONLY|O_BINARY); |
|---|
| 741 | # if (!dll) |
|---|
| 742 | # return 1; |
|---|
| 743 | # |
|---|
| 744 | # dll_name = filename; |
|---|
| 745 | # |
|---|
| 746 | # for (i=0; filename[i]; i++) |
|---|
| 747 | # if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':') |
|---|
| 748 | # dll_name = filename + i +1; |
|---|
| 749 | # |
|---|
| 750 | # pe_header_offset = pe_get32 (dll, 0x3c); |
|---|
| 751 | # opthdr_ofs = pe_header_offset + 4 + 20; |
|---|
| 752 | # num_entries = pe_get32 (dll, opthdr_ofs + 92); |
|---|
| 753 | # |
|---|
| 754 | # if (num_entries < 1) /* no exports */ |
|---|
| 755 | # return 1; |
|---|
| 756 | # |
|---|
| 757 | # export_rva = pe_get32 (dll, opthdr_ofs + 96); |
|---|
| 758 | # export_size = pe_get32 (dll, opthdr_ofs + 100); |
|---|
| 759 | # nsections = pe_get16 (dll, pe_header_offset + 4 +2); |
|---|
| 760 | # secptr = (pe_header_offset + 4 + 20 + |
|---|
| 761 | # pe_get16 (dll, pe_header_offset + 4 + 16)); |
|---|
| 762 | # |
|---|
| 763 | # expptr = 0; |
|---|
| 764 | # for (i = 0; i < nsections; i++) |
|---|
| 765 | # { |
|---|
| 766 | # char sname[8]; |
|---|
| 767 | # unsigned long secptr1 = secptr + 40 * i; |
|---|
| 768 | # unsigned long vaddr = pe_get32 (dll, secptr1 + 12); |
|---|
| 769 | # unsigned long vsize = pe_get32 (dll, secptr1 + 16); |
|---|
| 770 | # unsigned long fptr = pe_get32 (dll, secptr1 + 20); |
|---|
| 771 | # lseek(dll, secptr1, SEEK_SET); |
|---|
| 772 | # read(dll, sname, 8); |
|---|
| 773 | # if (vaddr <= export_rva && vaddr+vsize > export_rva) |
|---|
| 774 | # { |
|---|
| 775 | # expptr = fptr + (export_rva - vaddr); |
|---|
| 776 | # if (export_rva + export_size > vaddr + vsize) |
|---|
| 777 | # export_size = vsize - (export_rva - vaddr); |
|---|
| 778 | # break; |
|---|
| 779 | # } |
|---|
| 780 | # } |
|---|
| 781 | # |
|---|
| 782 | # expdata = (unsigned char*)malloc(export_size); |
|---|
| 783 | # lseek (dll, expptr, SEEK_SET); |
|---|
| 784 | # read (dll, expdata, export_size); |
|---|
| 785 | # erva = expdata - export_rva; |
|---|
| 786 | # |
|---|
| 787 | # nexp = pe_as32 (expdata+24); |
|---|
| 788 | # name_rvas = pe_as32 (expdata+32); |
|---|
| 789 | # |
|---|
| 790 | # printf ("EXPORTS\n"); |
|---|
| 791 | # for (i = 0; i<nexp; i++) |
|---|
| 792 | # { |
|---|
| 793 | # unsigned long name_rva = pe_as32 (erva+name_rvas+i*4); |
|---|
| 794 | # printf ("\t%s @ %ld ;\n", erva+name_rva, 1+ i); |
|---|
| 795 | # } |
|---|
| 796 | # |
|---|
| 797 | # return 0; |
|---|
| 798 | # } |
|---|
| 799 | # /* impgen.c ends here */ |
|---|
| 800 | ;; |
|---|
| 801 | *) |
|---|
| 802 | allow_undefined=yes |
|---|
| 803 | ;; |
|---|
| 804 | esac |
|---|
| 805 | compile_command="$CC" |
|---|
| 806 | finalize_command="$CC" |
|---|
| 807 | |
|---|
| 808 | compile_rpath= |
|---|
| 809 | finalize_rpath= |
|---|
| 810 | compile_shlibpath= |
|---|
| 811 | finalize_shlibpath= |
|---|
| 812 | convenience= |
|---|
| 813 | old_convenience= |
|---|
| 814 | deplibs= |
|---|
| 815 | linkopts= |
|---|
| 816 | |
|---|
| 817 | if test -n "$shlibpath_var"; then |
|---|
| 818 | # get the directories listed in $shlibpath_var |
|---|
| 819 | eval lib_search_path=\`\$echo \"X \${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` |
|---|
| 820 | else |
|---|
| 821 | lib_search_path= |
|---|
| 822 | fi |
|---|
| 823 | # now prepend the system-specific ones |
|---|
| 824 | eval lib_search_path=\"$sys_lib_search_path_spec\$lib_search_path\" |
|---|
| 825 | eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" |
|---|
| 826 | |
|---|
| 827 | avoid_version=no |
|---|
| 828 | dlfiles= |
|---|
| 829 | dlprefiles= |
|---|
| 830 | dlself=no |
|---|
| 831 | export_dynamic=no |
|---|
| 832 | export_symbols= |
|---|
| 833 | export_symbols_regex= |
|---|
| 834 | generated= |
|---|
| 835 | libobjs= |
|---|
| 836 | link_against_libtool_libs= |
|---|
| 837 | ltlibs= |
|---|
| 838 | module=no |
|---|
| 839 | objs= |
|---|
| 840 | prefer_static_libs=no |
|---|
| 841 | preload=no |
|---|
| 842 | prev= |
|---|
| 843 | prevarg= |
|---|
| 844 | release= |
|---|
| 845 | rpath= |
|---|
| 846 | xrpath= |
|---|
| 847 | perm_rpath= |
|---|
| 848 | temp_rpath= |
|---|
| 849 | thread_safe=no |
|---|
| 850 | vinfo= |
|---|
| 851 | |
|---|
| 852 | # We need to know -static, to get the right output filenames. |
|---|
| 853 | for arg |
|---|
| 854 | do |
|---|
| 855 | case "$arg" in |
|---|
| 856 | -all-static | -static) |
|---|
| 857 | if test "X$arg" = "X-all-static"; then |
|---|
| 858 | if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then |
|---|
| 859 | $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 |
|---|
| 860 | fi |
|---|
| 861 | if test -n "$link_static_flag"; then |
|---|
| 862 | dlopen_self=$dlopen_self_static |
|---|
| 863 | fi |
|---|
| 864 | else |
|---|
| 865 | if test -z "$pic_flag" && test -n "$link_static_flag"; then |
|---|
| 866 | dlopen_self=$dlopen_self_static |
|---|
| 867 | fi |
|---|
| 868 | fi |
|---|
| 869 | build_libtool_libs=no |
|---|
| 870 | build_old_libs=yes |
|---|
| 871 | prefer_static_libs=yes |
|---|
| 872 | break |
|---|
| 873 | ;; |
|---|
|
|---|