summaryrefslogtreecommitdiff
path: root/mk/buildlink3/buffer
blob: 4d6d743790e62d23254ec6e741d88c8879f5a969 (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
# $NetBSD: buffer,v 1.7 2004/01/30 13:44:52 jlam Exp $
#
# Push arguments onto the argument stack and shift the arguments.  The
# next argument checked by the cache and logic files is take from the
# the top of the stack.
#
if $test -z "$depth"; then
	arg="$1"; shift
	#
	# Marshall any group of consecutive arguments into a single
	# $arg to be checked in the cache and logic files.
	#
	. $marshall
	#
	# Push the argument onto the stack.
	#
	depth=${depth}0
	eval stack${depth}="\$arg"
fi

argok=no
while $test "$argok" = "no"; do
	#
	# Take $arg from the top of the stack.
	#
	eval arg="\$stack${depth}"
	depth=${depth%0}
	argok=yes

	case $arg in
	#
	# Change "-<rpath_flag>/path1:/path2" into
	# "-<rpath_flag>/path1 -<rpath_flag>/path2" so that
	# they can be checked correctly in the cache and logic
	# files.
	#
	-R*:*|-Wl,-R*:*|-Wl,-rpath,*:*|-Wl,-rpath-link,*:*|\
	-Wl,--rpath,*:*|-Wl,--rpath-link,*:*)
		case $arg in
		-R*)			R="-R" ;;
		-Wl,-R*)		R="-Wl,-R" ;;
		-Wl,-rpath,*)		R="-Wl,-rpath," ;;
		-Wl,-rpath-link,*)	R="-Wl,-rpath-link," ;;
		-Wl,--rpath,*)		R="-Wl,--rpath," ;;
		-Wl,--rpath-link,*)	R="-Wl,--rpath-link," ;;
		esac
		arg=`$echo "X$arg" | $Xsed -e "s|^"$R"||g"`
		save_IFS="${IFS}"; IFS=":"
		revarg=
		for dir in $arg; do
			revarg="$dir $revarg"
		done
		IFS="${save_IFS}"
		for dir in $revarg; do
			depth=${depth}0
			eval stack${depth}="\$R\$dir"
		done
		argok=no
		;;
	esac
done