summaryrefslogtreecommitdiff
path: root/mk/buildlink3/libtool-post-logic
blob: b5592f4a935b4406ee1b521b4e99cd02b61772c2 (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
# $NetBSD: libtool-post-logic,v 1.8 2004/05/17 10:37:57 jlam Exp $

case $arg in
#
# Workaround software authors that don't follow the libtool
# documentation and link against uninstalled libtool archives with:
#
#	-L../package/source/dir -lfoo
#
# instead of the correct (according to the libtool documentation)
#
#	../package/source/dir/libfoo.la
#
# We convert the former into the latter by remembering all "local"
# directories that are mentioned in -L* arguments to to libtool
# wrapper, and checking to see if <dir>/libfoo.la exists when we see
# "-lfoo" on the libtool command line.  Avoid matching the buildlink
# directory here for the WRKSRC == WRKDIR case.
#
-L${BUILDLINK_DIR}/*)
	;;
-L.|-L./*|-L..*|-L[!/]*|-L${WRKSRC}*)
	case $fixlibpath in
	yes)
		case $arg in
		*/.libs)
			# ignore -L.../.libs
			;;
		*)
			$echo "*** [buildlink3] Warning: libtool detected $arg" >> $wrapperlog
			$echo "*** [buildlink3] Warning: libtool detected $arg" 1>&2
			lpath=`$echo "X$arg" | $Xsed -e "s/^-L//"`
			case "$rellpath" in
			*"$lpath "*)	;;
			*"$lpath"*)	;;
			*)		rellpath="$rellpath $lpath" ;;
			esac
			addtocache=no
			;;
		esac
		;;
	esac
	;;
-l*)
	case $fixlibpath in
	yes)
		lib=`$echo "X$arg" | $Xsed -e "s/^-l//"`
		for dir in $rellpath; do
			la="$dir/lib$lib.la"
			if $test -f "$la"; then
				ldir=`cd $dir; $pwd`
				buildlibdir=`. $la; $echo $buildlibdir`
				if $test "$ldir" != "$buildlibdir"; then
					la="$buildlibdir/lib$lib.la"
				fi
				$echo "*** [buildlink3] Warning: libtool replaced $arg with $la" >> $wrapperlog
				$echo "*** [buildlink3] Warning: libtool replaced $arg with $la" 1>&2
				arg="$la"
				cachesettings='skipcache=yes'
				break
			fi
		done
		;;
	esac
	addtoprivatecache=yes
	;;

# Replace all references to locally-linked libtool archives with the full
# paths to the archives in $buildlibdir if $buildlibdir differs from the
# referenced directory.  This makes linking against a symlinked local
# libtool archive possible.
#
./*.la|../*.la|[!-/]*.la|${WRKSRC}/*.la)
	labase=`$basename $arg`
	ladir=`$dirname $arg`
	ldir=`cd $ladir; $pwd`
	buildlibdir=`. $ladir/$labase; $echo $buildlibdir`
	if $test -n "$buildlibdir" -a "$ldir" != "$buildlibdir" -a -e "$buildlibdir/$labase"; then
		arg="$buildlibdir/$labase"
		$echo "*** [buildlink3] Warning: libtool replaced $ladir/$labase with $arg" >> $wrapperlog
		$echo "*** [buildlink3] Warning: libtool replaced $ladir/$labase with $arg" 1>&2
	fi
	addtoprivatecache=yes
	;;
esac