1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27: basename="s,^.*/,,g"
28:
29:
30:
31:
32:
33:
34: progpath="$0"
35:
36:
37: progname=`echo "$progpath" | $SED $basename`
38: modename="$progname"
39:
40:
41: EXIT_SUCCESS=0
42: EXIT_FAILURE=1
43:
44: PROGRAM=ltmain.sh
45: PACKAGE=libtool
46: VERSION=1.5.22
47: TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
48:
49:
50: if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
51: emulate sh
52: NULLCMD=:
53:
54:
55: alias -g '${1+"$@"}'='"$@"'
56: setopt NO_GLOB_SUBST
57: else
58: case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
59: fi
60:
61:
62: if test "X$1" = X--no-reexec; then
63:
64: shift
65: elif test "X$1" = X--fallback-echo; then
66:
67: :
68: elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
69:
70: :
71: else
72:
73: exec $SHELL "$progpath" --no-reexec ${1+"$@"}
74: fi
75:
76: if test "X$1" = X--fallback-echo; then
77:
78: shift
79: cat <<EOF
80: $*
81: EOF
82: exit $EXIT_SUCCESS
83: fi
84:
85: default_mode=
86: help="Try \`$progname --help' for more information."
87: magic="%%%MAGIC variable%%%"
88: mkdir="mkdir"
89: mv="mv -f"
90: rm="rm -f"
91:
92:
93:
94: Xsed="${SED}"' -e 1s/^X//'
95: sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
96:
97: case `echo X|tr X '\101'` in
98: A)
99:
100: SP2NL='tr \040 \012'
101: NL2SP='tr \015\012 \040\040'
102: ;;
103: *)
104: SP2NL='tr \100 \n'
105: NL2SP='tr \r\n \100\100'
106: ;;
107: esac
108:
109:
110:
111:
112:
113:
114: for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
115: do
116: eval "if test \"\${$lt_var+set}\" = set; then
117: save_$lt_var=\$$lt_var
118: $lt_var=C
119: export $lt_var
120: fi"
121: done
122:
123:
124: lt_nl='
125: '
126: IFS=" $lt_nl"
127:
128: if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
129: $echo "$modename: not configured to build any kind of library" 1>&2
130: $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
131: exit $EXIT_FAILURE
132: fi
133:
134:
135: mode=$default_mode
136: nonopt=
137: prev=
138: prevopt=
139: run=
140: show="$echo"
141: show_help=
142: execute_dlfiles=
143: duplicate_deps=no
144: preserve_args=
145: lo2o="s/\\.lo\$/.${objext}/"
146: o2lo="s/\\.${objext}\$/.lo/"
147: extracted_archives=
148: extracted_serial=0
149:
150:
151:
152:
153:
154:
155:
156:
157:
158: func_mktempdir ()
159: {
160: my_template="${TMPDIR-/tmp}/${1-$progname}"
161:
162: if test "$run" = ":"; then
163:
164: my_tmpdir="${my_template}-$$"
165: else
166:
167:
168: my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
169:
170: if test ! -d "$my_tmpdir"; then
171:
172: my_tmpdir="${my_template}-${RANDOM-0}$$"
173:
174: save_mktempdir_umask=`umask`
175: umask 0077
176: $mkdir "$my_tmpdir"
177: umask $save_mktempdir_umask
178: fi
179:
180:
181: test -d "$my_tmpdir" || {
182: $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
183: exit $EXIT_FAILURE
184: }
185: fi
186:
187: $echo "X$my_tmpdir" | $Xsed
188: }
189:
190:
191:
192:
193:
194:
195:
196:
197: func_win32_libid ()
198: {
199: win32_libid_type="unknown"
200: win32_fileres=`file -L $1 2>/dev/null`
201: case $win32_fileres in
202: *ar\ archive\ import\ library*)
203: win32_libid_type="x86 archive import"
204: ;;
205: *ar\ archive*)
206: if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
207: $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
208: win32_nmres=`eval $NM -f posix -A $1 | \
209: $SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
210: case $win32_nmres in
211: import*) win32_libid_type="x86 archive import";;
212: *) win32_libid_type="x86 archive static";;
213: esac
214: fi
215: ;;
216: *DLL*)
217: win32_libid_type="x86 DLL"
218: ;;
219: *executable*)
220: case $win32_fileres in
221: *MS\ Windows\ PE\ Intel*)
222: win32_libid_type="x86 DLL"
223: ;;
224: esac
225: ;;
226: esac
227: $echo $win32_libid_type
228: }
229:
230:
231:
232:
233:
234:
235:
236:
237: func_infer_tag ()
238: {
239: if test -n "$available_tags" && test -z "$tagname"; then
240: CC_quoted=
241: for arg in $CC; do
242: case $arg in
243: *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
244: arg="\"$arg\""
245: ;;
246: esac
247: CC_quoted="$CC_quoted $arg"
248: done
249: case $@ in
250:
251:
252: " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
253:
254:
255: *)
256: for z in $available_tags; do
257: if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
258:
259: eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
260: CC_quoted=
261: for arg in $CC; do
262:
263: case $arg in
264: *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
265: arg="\"$arg\""
266: ;;
267: esac
268: CC_quoted="$CC_quoted $arg"
269: done
270: case "$@ " in
271: " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
272:
273:
274:
275: tagname=$z
276: break
277: ;;
278: esac
279: fi
280: done
281:
282:
283:
284: if test -z "$tagname"; then
285: $echo "$modename: unable to infer tagged configuration"
286: $echo "$modename: specify a tag with \`--tag'" 1>&2
287: exit $EXIT_FAILURE
288:
289:
290: fi
291: ;;
292: esac
293: fi
294: }
295:
296:
297:
298: func_extract_an_archive ()
299: {
300: f_ex_an_ar_dir="$1"; shift
301: f_ex_an_ar_oldlib="$1"
302:
303: $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
304: $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
305: if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
306: :
307: else
308: $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
309: exit $EXIT_FAILURE
310: fi
311: }
312:
313:
314: func_extract_archives ()
315: {
316: my_gentop="$1"; shift
317: my_oldlibs=${1+"$@"}
318: my_oldobjs=""
319: my_xlib=""
320: my_xabs=""
321: my_xdir=""
322: my_status=""
323:
324: $show "${rm}r $my_gentop"
325: $run ${rm}r "$my_gentop"
326: $show "$mkdir $my_gentop"
327: $run $mkdir "$my_gentop"
328: my_status=$?
329: if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
330: exit $my_status
331: fi
332:
333: for my_xlib in $my_oldlibs; do
334:
335: case $my_xlib in
336: [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
337: *) my_xabs=`pwd`"/$my_xlib" ;;
338: esac
339: my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
340: my_xlib_u=$my_xlib
341: while :; do
342: case " $extracted_archives " in
343: *" $my_xlib_u "*)
344: extracted_serial=`expr $extracted_serial + 1`
345: my_xlib_u=lt$extracted_serial-$my_xlib ;;
346: *) break ;;
347: esac
348: done
349: extracted_archives="$extracted_archives $my_xlib_u"
350: my_xdir="$my_gentop/$my_xlib_u"
351:
352: $show "${rm}r $my_xdir"
353: $run ${rm}r "$my_xdir"
354: $show "$mkdir $my_xdir"
355: $run $mkdir "$my_xdir"
356: exit_status=$?
357: if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
358: exit $exit_status
359: fi
360: case $host in
361: *-darwin*)
362: $show "Extracting $my_xabs"
363:
364: if test -z "$run"; then
365: darwin_orig_dir=`pwd`
366: cd $my_xdir || exit $?
367: darwin_archive=$my_xabs
368: darwin_curdir=`pwd`
369: darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
370: darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
371: if test -n "$darwin_arches"; then
372: darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
373: darwin_arch=
374: $show "$darwin_base_archive has multiple architectures $darwin_arches"
375: for darwin_arch in $darwin_arches ; do
376: mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
377: lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
378: cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
379: func_extract_an_archive "`pwd`" "${darwin_base_archive}"
380: cd "$darwin_curdir"
381: $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
382: done
383:
384: darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
385: darwin_file=
386: darwin_files=
387: for darwin_file in $darwin_filelist; do
388: darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
389: lipo -create -output "$darwin_file" $darwin_files
390: done
391: ${rm}r unfat-$$
392: cd "$darwin_orig_dir"
393: else
394: cd "$darwin_orig_dir"
395: func_extract_an_archive "$my_xdir" "$my_xabs"
396: fi
397: fi
398: ;;
399: *)
400: func_extract_an_archive "$my_xdir" "$my_xabs"
401: ;;
402: esac
403: my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
404: done
405: func_extract_archives_result="$my_oldobjs"
406: }
407:
408:
409:
410:
411: eval std_shrext=\"$shrext_cmds\"
412:
413: disable_libs=no
414:
415:
416: while test "$#" -gt 0
417: do
418: arg="$1"
419: shift
420:
421: case $arg in
422: -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
423: *) optarg= ;;
424: esac
425:
426:
427: if test -n "$prev"; then
428: case $prev in
429: execute_dlfiles)
430: execute_dlfiles="$execute_dlfiles $arg"
431: ;;
432: tag)
433: tagname="$arg"
434: preserve_args="${preserve_args}=$arg"
435:
436:
437: case $tagname in
438: *[!-_A-Za-z0-9,/]*)
439: $echo "$progname: invalid tag name: $tagname" 1>&2
440: exit $EXIT_FAILURE
441: ;;
442: esac
443:
444: case $tagname in
445: CC)
446:
447:
448: ;;
449: *)
450: if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
451: taglist="$taglist $tagname"
452:
453: eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
454: else
455: $echo "$progname: ignoring unknown tag $tagname" 1>&2
456: fi
457: ;;
458: esac
459: ;;
460: *)
461: eval "$prev=\$arg"
462: ;;
463: esac
464:
465: prev=
466: prevopt=
467: continue
468: fi
469:
470:
471: case $arg in
472: --help)
473: show_help=yes
474: ;;
475:
476: --version)
477: $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
478: $echo
479: $echo "Copyright (C) 2005 Free Software Foundation, Inc."
480: $echo "This is free software; see the source for copying conditions. There is NO"
481: $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
482: exit $?
483: ;;
484:
485: --config)
486: ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
487:
488: for tagname in $taglist; do
489: ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
490: done
491: exit $?
492: ;;
493:
494: --debug)
495: $echo "$progname: enabling shell trace mode"
496: set -x
497: preserve_args="$preserve_args $arg"
498: ;;
499:
500: --dry-run | -n)
501: run=:
502: ;;
503:
504: --features)
505: $echo "host: $host"
506: if test "$build_libtool_libs" = yes; then
507: $echo "enable shared libraries"
508: else
509: $echo "disable shared libraries"
510: fi
511: if test "$build_old_libs" = yes; then
512: $echo "enable static libraries"
513: else
514: $echo "disable static libraries"
515: fi
516: exit $?
517: ;;
518:
519: --finish) mode="finish" ;;
520:
521: --mode) prevopt="--mode" prev=mode ;;
522: --mode=*) mode="$optarg" ;;
523:
524: --preserve-dup-deps) duplicate_deps="yes" ;;
525:
526: --quiet | --silent)
527: show=:
528: preserve_args="$preserve_args $arg"
529: ;;
530:
531: --tag)
532: prevopt="--tag"
533: prev=tag
534: preserve_args="$preserve_args --tag"
535: ;;
536: --tag=*)
537: set tag "$optarg" ${1+"$@"}
538: shift
539: prev=tag
540: preserve_args="$preserve_args --tag"
541: ;;
542:
543: -dlopen)
544: prevopt="-dlopen"
545: prev=execute_dlfiles
546: ;;
547:
548: -*)
549: $echo "$modename: unrecognized option \`$arg'" 1>&2
550: $echo "$help" 1>&2
551: exit $EXIT_FAILURE
552: ;;
553:
554: *)
555: nonopt="$arg"
556: break
557: ;;
558: esac
559: done
560:
561: if test -n "$prevopt"; then
562: $echo "$modename: option \`$prevopt' requires an argument" 1>&2
563: $echo "$help" 1>&2
564: exit $EXIT_FAILURE
565: fi
566:
567: case $disable_libs in
568: no)
569: ;;
570: shared)
571: build_libtool_libs=no
572: build_old_libs=yes
573: ;;
574: static)
575: build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
576: ;;
577: esac
578:
579:
580:
581:
582: exec_cmd=
583:
584: if test -z "$show_help"; then
585:
586:
587: if test -z "$mode"; then
588: $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
589: $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
590: case $nonopt in
591: *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
592: mode=link
593: for arg
594: do
595: case $arg in
596: -c)
597: mode=compile
598: break
599: ;;
600: esac
601: done
602: ;;
603: *db | *