summaryrefslogtreecommitdiff
blob: c4d9eeb62cd28cf9cfb5dc6157f2d1cf94198cff (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
#!/bin/bash
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
# Author: Martin Schlemmer <azarah@gentoo.org>
# $Header: /var/cvsroot/gentoo-x86/eclass/libtool.eclass,v 1.9 2002/06/26 22:38:07 azarah Exp $
# This eclass patches ltmain.sh distributed with libtoolized packages with the
# relink and portage patch
ECLASS=libtool
newdepend sys-devel/libtool

DESCRIPTION="Based on the ${ECLASS} eclass"

ELIBTOOL_VERSION=1.8.1

elibtoolize() {

	local x=""
	local y=""
	local dopatch="no"
	local dotest="yes"
	local dorelink="yes"
	local dotmp="yes"
	local doportage="yes"
	local portage="no"
	local mylist=""

	mylist="$(find_ltmain)"
	# Only apply portage patch, and dont "libtoolize --copy --force"
	# if all patches fail.
	for x in ${*}
	do
		if [ "${x}" = "--portage" ]
		then
			portage="yes"
		fi
		# Only patch the ltmain.sh in ${S}
		if [ "${x}" = "--shallow" ]
		then
			if [ -f ${S}/ltmain.sh ]
			then
				mylist="${S}"
			else
				mylist=""
			fi
		else
			mylist="$(find_ltmain)"
		fi
	done

	for x in ${mylist}
	do
		cd ${x}
		einfo "Working directory: ${x}..."
		dopatch="yes"
		dotest="yes"
		dorelink="yes"
		dotmp="yes"
		doportage="yes"

		for y in test_patch relink_patch tmp_patch portage_patch
		do
			if ! eval ${y} --test $>${T}/libtool.foo
			then
				case ${y} in
					test_patch)
						# non critical patch
						dotest="no"
						;;
					relink_patch)
						# critical patch, but could be applied
						if [ -z "$(grep -e "inst_prefix_dir" ltmain.sh)" ] && \
						   [ "${portage}" = "no" ]
						then
							dopatch="no"
						fi
						dorelink="no"
						;;
					tmp_patch)
						# non critical patch
						dotmp="no"
						;;
					portage_patch)
						# critical patch
						if [ "${portage}" = "yes" ]
						then
							echo
							eerror "Portage patch requested, but failed to apply!"
							die
						fi
						dopatch="no"
						doportage="no"
						;;
				esac
			fi
		done

		for y in test_patch relink_patch tmp_patch portage_patch
		do
			if [ "${dopatch}" = "yes" ]
			then
				case ${y} in
					test_patch)
						if [ "${dotest}" = "no" ]
						then
							continue
						fi
						;;
					relink_patch)
						if [ "${dorelink}" = "no" ]
						then
							continue
						fi
						;;
					tmp_patch)
						if [ "${dotmp}" = "no" ]
						then
							continue
						fi
						;;
					portage_patch)
						if [ "${doportage}" = "no" ]
						then
							continue
						fi
						;;
				esac
				
				einfo "Applying libtool-${y/_patch/}.patch..."
				eval ${y} $>${T}/libtool.foo
			elif [ "${portage}" = "no" ]
			then
				libtoolize --copy --force
				break
			fi
		done
	done

	if [ -f libtool ]
	then
		rm -f libtool
	fi

	# We need to change the pwd back to $S, as we may be called in
	# src_compile()
	cd ${S}
}

#
# Returns all the directories containing ltmain.sh
#
find_ltmain() {
	
	local x=""
	local dirlist=""

	for x in $(find ${S} -name 'ltmain.sh')
	do
		dirlist="${dirlist} ${x%/*}"
	done

	echo "${dirlist}"
}

#
# Various patches we want to apply.
#
# Contains:  portage_patch
#            relink_patch
#            test_patch
#
portage_patch() {

	local opts=""

	if [ "${1}" = "--test" ]
	then
		opts="--force --dry-run"
	fi

	patch ${opts} -p0 <<-"ENDPATCH"
		--- ltmain.sh.orig	Wed Apr  3 01:19:37 2002
		+++ ltmain.sh	Sun May 26 19:50:52 2002
		@@ -3940,9 +3940,41 @@
		 		  $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
		 		  exit 1
		 		fi
		-		newdependency_libs="$newdependency_libs $libdir/$name"
		+		# We do not want portage's install root ($D) present.  Check only for
		+		# this if the .la is being installed.
		+		if test "$installed" = yes && test "$D"; then
		+		  mynewdependency_lib="`echo "$libdir/$name" |sed -e "s:$D::g" -e 's://:/:g'`"
		+		else
		+		  mynewdependency_lib="$libdir/$name"
		+		fi
		+		# Do not add duplicates
		+		if test "$mynewdependency_lib"; then
		+		  if test -z "`echo $newdependency_libs |grep -e "$mynewdependency_lib"`"; then
		+		    newdependency_libs="$newdependency_libs $mynewdependency_lib"
		+		  fi
		+		fi
		+		;;
		+	      *)
		+	      	if test "$installed" = yes; then
		+		  # We do not want portage's build root ($S) present.
		+	          if test -n "`echo $deplib |grep -e "$S"`" && test "$S"; then
		+		    newdependency_libs=""
		+		  # We do not want portage's install root ($D) present.
		+		  elif test -n "`echo $deplib |grep -e "$D"`" && test "$D"; then
		+		    mynewdependency_lib="`echo "$deplib" |sed -e "s:$D::g" -e 's://:/:g'`"
		+		  else
		+		    mynewdependency_lib="$deplib"
		+		  fi
		+		else
		+		  mynewdependency_lib="$deplib"
		+		fi
		+		# Do not add duplicates
		+		if test "$mynewdependency_lib"; then
		+		  if test -z "`echo $newdependency_libs |grep -e "$mynewdependency_lib"`"; then
		+			newdependency_libs="$newdependency_libs $mynewdependency_lib"
		+		  fi
		+		fi
		 		;;
		-	      *) newdependency_libs="$newdependency_libs $deplib" ;;
		 	      esac
		 	    done
		 	    dependency_libs="$newdependency_libs"
		@@ -3975,6 +4005,10 @@
		 	  case $host,$output,$installed,$module,$dlname in
		 	    *cygwin*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
		 	  esac
		+	  # Do not add duplicates
		+	  if test "$installed" = yes && test "$D"; then
		+	    install_libdir="`echo "$install_libdir" |sed -e "s:$D::g" -e 's://:/:g'`"
		+	  fi
		 	  $echo > $output "\
		 # $outputname - a libtool library file
		 # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
	ENDPATCH
}

relink_patch() {

	local opts=""
	local retval=0

	if [ "${1}" = "--test" ]
	then
		opts="--force --dry-run"
	fi

	patch ${opts} -p0 <<-"ENDPATCH"
		--- ltmain.sh	Sun Aug 12 18:08:05 2001
		+++ ltmain-relinkable.sh	Tue Aug 28 18:55:13 2001
		@@ -827,6 +827,7 @@
		     linker_flags=
		     dllsearchpath=
		     lib_search_path=`pwd`
		+    inst_prefix_dir=
		 
		     avoid_version=no
		     dlfiles=
		@@ -959,6 +960,11 @@
		 	  prev=
		 	  continue
		 	  ;;
		+        inst_prefix)
		+	  inst_prefix_dir="$arg"
		+	  prev=
		+	  continue
		+	  ;;
		 	release)
		 	  release="-$arg"
		 	  prev=
		@@ -1167,6 +1173,11 @@
		 	continue
		 	;;
		 
		+      -inst-prefix-dir)
		+	prev=inst_prefix
		+	continue
		+	;;
		+
		       # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
		       # so, if we see these flags be careful not to treat them like -L
		       -L[A-Z][A-Z]*:*)
		@@ -2231,7 +2242,16 @@
		 	    if test "$hardcode_direct" = yes; then
		 	      add="$libdir/$linklib"
		 	    elif test "$hardcode_minus_L" = yes; then
		-	      add_dir="-L$libdir"
		+	      # Try looking first in the location we're being installed to.
		+	      add_dir=
		+	      if test -n "$inst_prefix_dir"; then
		+		case "$libdir" in
		+		[\\/]*)
		+		  add_dir="-L$inst_prefix_dir$libdir"
		+		  ;;
		+		esac
		+	      fi
		+	      add_dir="$add_dir -L$libdir"
		 	      add="-l$name"
		 	    elif test "$hardcode_shlibpath_var" = yes; then
		 	      case :$finalize_shlibpath: in
		@@ -2241,7 +2261,16 @@
		 	      add="-l$name"
		 	    else
		 	      # We cannot seem to hardcode it, guess we'll fake it.
		-	      add_dir="-L$libdir"
		+	      # Try looking first in the location we're being installed to.
		+	      add_dir=
		+	      if test -n "$inst_prefix_dir"; then
		+		case "$libdir" in
		+		[\\/]*)
		+		  add_dir="-L$inst_prefix_dir$libdir"
		+		  ;;
		+		esac
		+	      fi
		+	      add_dir="$add_dir -L$libdir"
		 	      add="-l$name"
		 	    fi
		 
		@@ -4622,12 +4651,30 @@
		 	dir="$dir$objdir"
		 
		 	if test -n "$relink_command"; then
		+	  # Determine the prefix the user has applied to our future dir.
		+	  inst_prefix_dir=`$echo "$destdir" | sed "s%$libdir\$%%"`
		+
		+	  # Don't allow the user to place us outside of our expected
		+	  # location b/c this prevents finding dependent libraries that
		+	  # are installed to the same prefix.
		+	  if test "$inst_prefix_dir" = "$destdir"; then
		+	    $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
		+	    exit 1
		+	  fi
		+
		+	  if test -n "$inst_prefix_dir"; then
		+	    # Stick the inst_prefix_dir data into the link command.
		+	    relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
		+	  else
		+	    relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%%"`
		+	  fi
		+
		 	  $echo "$modename: warning: relinking \`$file'" 1>&2
		 	  $show "$relink_command"
		 	  if $run eval "$relink_command"; then :
		 	  else
		 	    $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
		-	    continue
		+	    exit 1
		 	  fi
		 	fi
		 
	ENDPATCH

    retval=$?

    # This one dont apply clean to libtool-1.4.2a, so do it manually.
    if [ "${1}" != "--test" ] && [ "${retval}" -eq 0 ]
    then
        cp ltmain.sh ltmain.sh.orig
        sed -e 's:cd `pwd`; $SHELL $0 --mode=relink $libtool_args:cd `pwd`; $SHELL $0 --mode=relink $libtool_args @inst_prefix_dir@:' \
            ltmain.sh.orig > ltmain.sh
        rm -f ltmain.sh.orig
    fi

    return ${retval}
}

tmp_patch() {

	local opts=""

	if [ "${1}" = "--test" ]
	then
		opts="--force --dry-run"
	fi
	
	patch ${opts} -p0 <<-"ENDPATCH"
		--- ltmain.sh   Sun Aug 12 18:08:05 2001
		+++ ltmain-relinkable.sh    Tue Aug 28 18:55:13 2001
		@@ -4782,7 +4829,11 @@
		 	    if test "$finalize" = yes && test -z "$run"; then
		 	      tmpdir="/tmp"
		 	      test -n "$TMPDIR" && tmpdir="$TMPDIR"
		-	      tmpdir="$tmpdir/libtool-$$"
		+              tmpdir=`mktemp -d $tmpdir/libtool-XXXXXX 2> /dev/null`
		+              if test $? = 0 ; then :
		+              else
		+                tmpdir="$tmpdir/libtool-$$"
		+              fi
		 	      if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then :
		 	      else
		 		$echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
	ENDPATCH
}

test_patch() {

	local opts=""

	if [ "${1}" = "--test" ]
	then
		opts="--force --dry-run"
	fi

	patch ${opts} -p0 <<-"ENDPATCH"
		--- ./ltmain.sh	Tue May 29 19:16:03 2001
		+++ ./ltmain.sh	Tue May 29 21:26:50 2001
		@@ -459,7 +459,7 @@
		       pic_mode=default
		       ;;
		     esac
		-    if test $pic_mode = no && test "$deplibs_check_method" != pass_all; then
		+    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
		       # non-PIC code in shared libraries is not supported
		       pic_mode=default
		     fi
		@@ -1343,7 +1343,7 @@
		 	;;
		     esac
		     for pass in $passes; do
		-      if test $linkmode = prog; then
		+      if test "$linkmode" = prog; then
		 	# Determine which files to process
		 	case $pass in
		 	dlopen)
		@@ -1360,11 +1360,11 @@
		 	found=no
		 	case $deplib in
		 	-l*)
		-	  if test $linkmode = oldlib && test $linkmode = obj; then
		+	  if test "$linkmode" = oldlib && test "$linkmode" = obj; then
		 	    $echo "$modename: warning: \`-l' is ignored for archives/objects: $deplib" 1>&2
		 	    continue
		 	  fi
		-	  if test $pass = conv; then
		+	  if test "$pass" = conv; then
		 	    deplibs="$deplib $deplibs"
		 	    continue
		 	  fi
		@@ -1384,7 +1384,7 @@
		 	      finalize_deplibs="$deplib $finalize_deplibs"
		 	    else
		 	      deplibs="$deplib $deplibs"
		-	      test $linkmode = lib && newdependency_libs="$deplib $newdependency_libs"
		+	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
		 	    fi
		 	    continue
		 	  fi
		@@ -1393,16 +1393,16 @@
		 	  case $linkmode in
		 	  lib)
		 	    deplibs="$deplib $deplibs"
		-	    test $pass = conv && continue
		+	    test "$pass" = conv && continue
		 	    newdependency_libs="$deplib $newdependency_libs"
		 	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
		 	    ;;
		 	  prog)
		-	    if test $pass = conv; then
		+	    if test "$pass" = conv; then
		 	      deplibs="$deplib $deplibs"
		 	      continue
		 	    fi
		-	    if test $pass = scan; then
		+	    if test "$pass" = scan; then
		 	      deplibs="$deplib $deplibs"
		 	      newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
		 	    else
		@@ -1417,7 +1417,7 @@
		 	  continue
		 	  ;; # -L
		 	-R*)
		-	  if test $pass = link; then
		+	  if test "$pass" = link; then
		 	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
		 	    # Make sure the xrpath contains only unique directories.
		 	    case "$xrpath " in
		@@ -1430,7 +1430,7 @@
		 	  ;;
		 	*.la) lib="$deplib" ;;
		 	*.$libext)
		-	  if test $pass = conv; then
		+	  if test "$pass" = conv; then
		 	    deplibs="$deplib $deplibs"
		 	    continue
		 	  fi
		@@ -1451,7 +1451,7 @@
		 	    continue
		 	    ;;
		 	  prog)
		-	    if test $pass != link; then
		+	    if test "$pass" != link; then
		 	      deplibs="$deplib $deplibs"
		 	    else
		 	      compile_deplibs="$deplib $compile_deplibs"
		@@ -1462,7 +1462,7 @@
		 	  esac # linkmode
		 	  ;; # *.$libext
		 	*.lo | *.$objext)
		-	  if test $pass = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
		+	  if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
		 	    # If there is no dlopen support or we're linking statically,
		 	    # we need to preload.
		 	    newdlprefiles="$newdlprefiles $deplib"
		@@ -1512,13 +1512,13 @@
		 
		 	if test "$linkmode,$pass" = "lib,link" ||
		 	   test "$linkmode,$pass" = "prog,scan" ||
		-	   { test $linkmode = oldlib && test $linkmode = obj; }; then
		+	   { test "$linkmode" = oldlib && test "$linkmode" = obj; }; then
		 	   # Add dl[pre]opened files of deplib
		 	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
		 	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
		 	fi
		 
		-	if test $pass = conv; then
		+	if test "$pass" = conv; then
		 	  # Only check for convenience libraries
		 	  deplibs="$lib $deplibs"
		 	  if test -z "$libdir"; then
		@@ -1537,7 +1537,7 @@
		 	      esac
		 	      tmp_libs="$tmp_libs $deplib"
		 	    done
		-	  elif test $linkmode != prog && test $linkmode != lib; then
		+	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
		 	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
		 	    exit 1
		 	  fi
		@@ -1555,7 +1555,7 @@
		 	fi
		 
		 	# This library was specified with -dlopen.
		-	if test $pass = dlopen; then
		+	if test "$pass" = dlopen; then
		 	  if test -z "$libdir"; then
		 	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
		 	    exit 1
		@@ -1604,7 +1604,7 @@
		 	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
		 
		 	# This library was specified with -dlpreopen.
		-	if test $pass = dlpreopen; then
		+	if test "$pass" = dlpreopen; then
		 	  if test -z "$libdir"; then
		 	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
		 	    exit 1
		@@ -1623,7 +1623,7 @@
		 
		 	if test -z "$libdir"; then
		 	  # Link the convenience library
		-	  if test $linkmode = lib; then
		+	  if test "$linkmode" = lib; then
		 	    deplibs="$dir/$old_library $deplibs"
		 	  elif test "$linkmode,$pass" = "prog,link"; then
		 	    compile_deplibs="$dir/$old_library $compile_deplibs"
		@@ -1634,7 +1634,7 @@
		 	  continue
		 	fi
		 
		-	if test $linkmode = prog && test $pass != link; then
		+	if test "$linkmode" = prog && test "$pass" != link; then
		 	  newlib_search_path="$newlib_search_path $ladir"
		 	  deplibs="$lib $deplibs"
		 
		@@ -1671,7 +1671,7 @@
		 	  # Link against this shared library
		 
		 	  if test "$linkmode,$pass" = "prog,link" ||
		-	   { test $linkmode = lib && test $hardcode_into_libs = yes; }; then
		+	   { test "$linkmode" = lib && test "$hardcode_into_libs" = yes; }; then
		 	    # Hardcode the library path.
		 	    # Skip directories that are in the system default run-time
		 	    # search path.
		@@ -1693,7 +1693,7 @@
		 	      esac
		 	      ;;
		 	    esac
		-	    if test $linkmode = prog; then
		+	    if test "$linkmode" = prog; then
		 	      # We need to hardcode the library path
		 	      if test -n "$shlibpath_var"; then
		 		# Make sure the rpath contains only unique directories.
		@@ -1777,7 +1777,7 @@
		 	    linklib=$newlib
		 	  fi # test -n $old_archive_from_expsyms_cmds
		 
		-	  if test $linkmode = prog || test "$mode" != relink; then
		+	  if test "$linkmode" = prog || test "$mode" != relink; then
		 	    add_shlibpath=
		 	    add_dir=
		 	    add=
		@@ -1826,7 +1826,7 @@
		 	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
		 	      esac
		 	    fi
		-	    if test $linkmode = prog; then
		+	    if test "$linkmode" = prog; then
		 	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
		 	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
		 	    else
		@@ -1843,7 +1843,7 @@
		 	    fi
		 	  fi
		 
		-	  if test $linkmode = prog || test "$mode" = relink; then
		+	  if test "$linkmode" = prog || test "$mode" = relink; then
		 	    add_shlibpath=
		 	    add_dir=
		 	    add=
		@@ -1865,7 +1865,7 @@
		 	      add="-l$name"
		 	    fi
		 
		-	    if test $linkmode = prog; then
		+	    if test "$linkmode" = prog; then
		 	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
		 	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
		 	    else
		@@ -1873,7 +1873,7 @@
		 	      test -n "$add" && deplibs="$add $deplibs"
		 	    fi
		 	  fi
		-	elif test $linkmode = prog; then
		+	elif test "$linkmode" = prog; then
		 	  if test "$alldeplibs" = yes &&
		 	     { test "$deplibs_check_method" = pass_all ||
		 	       { test "$build_libtool_libs" = yes &&
		@@ -1932,9 +1932,9 @@
		 	  fi
		 	fi # link shared/static library?
		 
		-	if test $linkmode = lib; then
		+	if test "$linkmode" = lib; then
		 	  if test -n "$dependency_libs" &&
		-	     { test $hardcode_into_libs != yes || test $build_old_libs = yes ||
		+	     { test "$hardcode_into_libs" != yes || test $build_old_libs = yes ||
		 	       test $link_static = yes; }; then
		 	    # Extract -R from dependency_libs
		 	    temp_deplibs=
		@@ -1964,7 +1964,7 @@
		 	    tmp_libs="$tmp_libs $deplib"
		 	  done
		 
		-	  if test $link_all_deplibs != no; then
		+	  if test "$link_all_deplibs" != no; then
		 	    # Add the search paths of all dependency libraries
		 	    for deplib in $dependency_libs; do
		 	      case $deplib in
		@@ -2007,15 +2007,15 @@
		 	  fi # link_all_deplibs != no
		 	fi # linkmode = lib
		       done # for deplib in $libs
		-      if test $pass = dlpreopen; then
		+      if test "$pass" = dlpreopen; then
		 	# Link the dlpreopened libraries before other libraries
		 	for deplib in $save_deplibs; do
		 	  deplibs="$deplib $deplibs"
		 	done
		       fi
		-      if test $pass != dlopen; then
		-	test $pass != scan && dependency_libs="$newdependency_libs"
		-	if test $pass != conv; then
		+      if test "$pass" != dlopen; then
		+	test "$pass" != scan && dependency_libs="$newdependency_libs"
		+	if test "$pass" != conv; then
		 	  # Make sure lib_search_path contains only unique directories.
		 	  lib_search_path=
		 	  for dir in $newlib_search_path; do
		@@ -2073,7 +2073,7 @@
		 	deplibs=
		       fi
		     done # for pass
		-    if test $linkmode = prog; then
		+    if test "$linkmode" = prog; then
		       dlfiles="$newdlfiles"
		       dlprefiles="$newdlprefiles"
		     fi
		@@ -2410,7 +2410,7 @@
		 	    ;;
		 	  *)
		 	    # Add libc to deplibs on all other systems if necessary.
		-	    if test $build_libtool_need_lc = "yes"; then
		+	    if test "$build_libtool_need_lc" = "yes"; then
		 	      deplibs="$deplibs -lc"
		 	    fi
		 	    ;;
		@@ -2683,7 +2683,7 @@
		 
		       # Test again, we may have decided not to build it any more
		       if test "$build_libtool_libs" = yes; then
		-	if test $hardcode_into_libs = yes; then
		+	if test "$hardcode_into_libs" = yes; then
		 	  # Hardcode the library paths
		 	  hardcode_libdirs=
		 	  dep_rpath=
	ENDPATCH
}