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.6
47: TIMESTAMP=" (1.1220.2.95 2004/04/11 05:50:42) Debian$Rev: 224 $"
48:
49:
50:
51: if test "X$1" = X--no-reexec; then
52:
53: shift
54: elif test "X$1" = X--fallback-echo; then
55:
56: :
57: elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
58:
59: :
60: else
61:
62: exec $SHELL "$progpath" --no-reexec ${1+"$@"}
63: fi
64:
65: if test "X$1" = X--fallback-echo; then
66:
67: shift
68: cat <<EOF
69: $*
70: EOF
71: exit $EXIT_SUCCESS
72: fi
73:
74: default_mode=
75: help="Try \`$progname --help' for more information."
76: magic="%%%MAGIC variable%%%"
77: mkdir="mkdir"
78: mv="mv -f"
79: rm="rm -f"
80:
81:
82:
83: Xsed="${SED}"' -e 1s/^X//'
84: sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
85:
86: case `echo A|tr A '\301'` in
87: A)
88: SP2NL="tr '\100' '\n'"
89: NL2SP="tr '\r\n' '\100\100'"
90: ;;
91: *)
92: SP2NL="tr '\040' '\012'"
93: NL2SP="tr '\015\012' '\040\040'"
94: ;;
95: esac
96:
97:
98:
99:
100:
101:
102: if test "${LC_ALL+set}" = set; then
103: save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
104: fi
105: if test "${LANG+set}" = set; then
106: save_LANG="$LANG"; LANG=C; export LANG
107: fi
108:
109:
110: : ${IFS="
111: "}
112:
113: if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
114: $echo "$modename: not configured to build any kind of library" 1>&2
115: $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
116: exit $EXIT_FAILURE
117: fi
118:
119:
120: mode=$default_mode
121: nonopt=
122: prev=
123: prevopt=
124: run=
125: show="$echo"
126: show_help=
127: execute_dlfiles=
128: lo2o="s/\\.lo\$/.${objext}/"
129: o2lo="s/\\.${objext}\$/.lo/"
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141: func_win32_libid () {
142: win32_libid_type="unknown"
143: win32_fileres=`file -L $1 2>/dev/null`
144: case $win32_fileres in
145: *ar\ archive\ import\ library*)
146: win32_libid_type="x86 archive import"
147: ;;
148: *ar\ archive*)
149: if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
150: $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
151: win32_nmres=`eval $NM -f posix -A $1 | \
152: sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
153: if test "X$win32_nmres" = "Ximport" ; then
154: win32_libid_type="x86 archive import"
155: else
156: win32_libid_type="x86 archive static"
157: fi
158: fi
159: ;;
160: *DLL*)
161: win32_libid_type="x86 DLL"
162: ;;
163: *executable*)
164: case $win32_fileres in
165: *MS\ Windows\ PE\ Intel*)
166: win32_libid_type="x86 DLL"
167: ;;
168: esac
169: ;;
170: esac
171: $echo $win32_libid_type
172: }
173:
174:
175:
176:
177:
178:
179:
180:
181: func_infer_tag () {
182: if test -n "$available_tags" && test -z "$tagname"; then
183: CC_quoted=
184: for arg in $CC; do
185: case $arg in
186: *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
187: arg="\"$arg\""
188: ;;
189: esac
190: CC_quoted="$CC_quoted $arg"
191: done
192: case $@ in
193:
194:
195: " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
196:
197:
198: *)
199: for z in $available_tags; do
200: if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
201:
202: eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
203: CC_quoted=
204: for arg in $CC; do
205:
206: case $arg in
207: *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
208: arg="\"$arg\""
209: ;;
210: esac
211: CC_quoted="$CC_quoted $arg"
212: done
213: case "$@ " in
214: " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
215:
216:
217:
218: tagname=$z
219: break
220: ;;
221: esac
222: fi
223: done
224:
225:
226:
227: if test -z "$tagname"; then
228: $echo "$modename: unable to infer tagged configuration"
229: $echo "$modename: specify a tag with \`--tag'" 1>&2
230: exit $EXIT_FAILURE
231:
232:
233: fi
234: ;;
235: esac
236: fi
237: }
238:
239:
240:
241:
242: eval std_shrext=\"$shrext_cmds\"
243:
244:
245: while test "$#" -gt 0
246: do
247: arg="$1"
248: shift
249:
250: case $arg in
251: -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
252: *) optarg= ;;
253: esac
254:
255:
256: if test -n "$prev"; then
257: case $prev in
258: execute_dlfiles)
259: execute_dlfiles="$execute_dlfiles $arg"
260: ;;
261: tag)
262: tagname="$arg"
263: preserve_args="${preserve_args}=$arg"
264:
265:
266: case $tagname in
267: *[!-_A-Za-z0-9,/]*)
268: $echo "$progname: invalid tag name: $tagname" 1>&2
269: exit $EXIT_FAILURE
270: ;;
271: esac
272:
273: case $tagname in
274: CC)
275:
276:
277: ;;
278: *)
279: if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
280: taglist="$taglist $tagname"
281:
282: eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
283: else
284: $echo "$progname: ignoring unknown tag $tagname" 1>&2
285: fi
286: ;;
287: esac
288: ;;
289: *)
290: eval "$prev=\$arg"
291: ;;
292: esac
293:
294: prev=
295: prevopt=
296: continue
297: fi
298:
299:
300: case $arg in
301: --help)
302: show_help=yes
303: ;;
304:
305: --version)
306: $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
307: $echo
308: $echo "Copyright (C) 2003 Free Software Foundation, Inc."
309: $echo "This is free software; see the source for copying conditions. There is NO"
310: $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
311: exit $EXIT_SUCCESS
312: ;;
313:
314: --config)
315: ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
316:
317: for tagname in $taglist; do
318: ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
319: done
320: exit $EXIT_SUCCESS
321: ;;
322:
323: --debug)
324: $echo "$progname: enabling shell trace mode"
325: set -x
326: preserve_args="$preserve_args $arg"
327: ;;
328:
329: --dry-run | -n)
330: run=:
331: ;;
332:
333: --features)
334: $echo "host: $host"
335: if test "$build_libtool_libs" = yes; then
336: $echo "enable shared libraries"
337: else
338: $echo "disable shared libraries"
339: fi
340: if test "$build_old_libs" = yes; then
341: $echo "enable static libraries"
342: else
343: $echo "disable static libraries"
344: fi
345: exit $EXIT_SUCCESS
346: ;;
347:
348: --finish) mode="finish" ;;
349:
350: --mode) prevopt="--mode" prev=mode ;;
351: --mode=*) mode="$optarg" ;;
352:
353: --preserve-dup-deps) duplicate_deps="yes" ;;
354:
355: --quiet | --silent)
356: show=:
357: preserve_args="$preserve_args $arg"
358: ;;
359:
360: --tag) prevopt="--tag" prev=tag ;;
361: --tag=*)
362: set tag "$optarg" ${1+"$@"}
363: shift
364: prev=tag
365: preserve_args="$preserve_args --tag"
366: ;;
367:
368: -dlopen)
369: prevopt="-dlopen"
370: prev=execute_dlfiles
371: ;;
372:
373: -*)
374: $echo "$modename: unrecognized option \`$arg'" 1>&2
375: $echo "$help" 1>&2
376: exit $EXIT_FAILURE
377: ;;
378:
379: *)
380: nonopt="$arg"
381: break
382: ;;
383: esac
384: done
385:
386: if test -n "$prevopt"; then
387: $echo "$modename: option \`$prevopt' requires an argument" 1>&2
388: $echo "$help" 1>&2
389: exit $EXIT_FAILURE
390: fi
391:
392:
393:
394:
395: exec_cmd=
396:
397: if test -z "$show_help"; then
398:
399:
400: if test -z "$mode"; then
401: $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
402: $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2
403: case $nonopt in
404: *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
405: mode=link
406: for arg
407: do
408: case $arg in
409: -c)
410: mode=compile
411: break
412: ;;
413: esac
414: done
415: ;;
416: *db | *dbx | *strace | *truss)
417: mode=execute
418: ;;
419: *install*|cp|mv)
420: mode=install
421: ;;
422: *rm)
423: mode=uninstall
424: ;;
425: *)
426:
427: test -n "$execute_dlfiles" && mode=execute
428:
429:
430: if test -z "$mode"; then
431: if test -n "$nonopt"; then
432: $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
433: else
434: $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
435: fi
436: fi
437: ;;
438: esac
439: fi
440:
441:
442: if test -n "$execute_dlfiles" && test "$mode" != execute; then
443: $echo "$modename: unrecognized option \`-dlopen'" 1>&2
444: $echo "$help" 1>&2
445: exit $EXIT_FAILURE
446: fi
447:
448:
449: generic_help="$help"
450: help="Try \`$modename --help --mode=$mode' for more information."
451:
452:
453: case $mode in
454:
455: compile)
456: modename="$modename: compile"
457:
458: base_compile=
459: srcfile="$nonopt"
460: suppress_opt=yes
461: suppress_output=
462: arg_mode=normal
463: libobj=
464: later=
465:
466: for arg
467: do
468: case "$arg_mode" in
469: arg )
470:
471: lastarg="$arg"
472: arg_mode=normal
473: ;;
474:
475: target )
476: libobj="$arg"
477: arg_mode=normal
478: continue
479: ;;
480:
481: normal )
482:
483: case $arg in
484: -o)
485: if test -n "$libobj" ; then
486: $echo "$modename: you cannot specify \`-o' more than once" 1>&2
487: exit $EXIT_FAILURE
488: fi
489: arg_mode=target
490: continue
491: ;;
492:
493: -static | -prefer-pic | -prefer-non-pic)
494: later="$later $arg"
495: continue
496: ;;
497:
498: -no-suppress)
499: suppress_opt=no
500: continue
501: ;;
502:
503: -Xcompiler)
504: arg_mode=arg
505: continue
506: ;;
507:
508: -Wc,*)
509: args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
510: lastarg=
511: save_ifs="$IFS"; IFS=','
512: for arg in $args; do
513: IFS="$save_ifs"
514:
515:
516:
517:
518: case $arg in
519: *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
520: arg="\"$arg\""
521: ;;
522: esac
523: lastarg="$lastarg $arg"
524: done
525: IFS="$save_ifs"
526: lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
527:
528:
529: base_compile="$base_compile $lastarg"
530: continue
531: ;;
532:
533: * )
534:
535:
536:
537: lastarg="$srcfile"
538: srcfile="$arg"
539: ;;
540: esac
541: ;;
542: esac
543:
544:
545: lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
546:
547: case $lastarg in
548:
549:
550:
551: *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
552: lastarg="\"$lastarg\""
553: ;;
554: esac
555:
556: base_compile="$base_compile $lastarg"
557: done
558:
559: case $arg_mode in
560: arg)
561: $echo "$modename: you must specify an argument for -Xcompile"
562: exit $EXIT_FAILURE
563: ;;
564: target)
565: $echo "$modename: you must specify a target with \`-o'" 1>&2
566: exit $EXIT_FAILURE
567: ;;
568: *)
569:
570: [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
571: ;;
572: esac
573:
574:
575:
576: xform='[cCFSifmso]'
577: case $libobj in
578: *.ada) xform=ada ;;
579: *.adb) xform=adb ;;
580: *.ads) xform=ads ;;
581: *.asm) xform=asm ;;
582: *.c++) xform=c++ ;;
583: *.cc) xform=cc ;;
584: *.ii) xform=ii ;;
585: *.class) xform=class ;;
586: *.cpp) xform=cpp ;;
587: *.cxx) xform=cxx ;;
588: *.f90) xform=f90 ;;
589: *.for) xform=for ;;
590: *.java) xform=java ;;
591: esac
592:
593: libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
594:
595: case $libobj in
596: *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
597: *)
598: $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
599: exit $EXIT_FAILURE
600: ;;
601: esac
602:
603: func_infer_tag $base_compile
604:
605: for arg in $later; do
606: case $arg in
607: -static)
608: build_old_libs=yes
609: continue
610: ;;
611:
612: -prefer-pic)
613: pic_mode=yes
614: continue
615: ;;
616:
617: -prefer-non-pic)
618: pic_mode=no
619: continue
620: ;;
621: esac
622: done
623:
624: objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
625: xdir=`$echo "