summaryrefslogtreecommitdiff
path: root/mk/buildlink3/marshall
blob: 4d3d32762db7153c7e39b9f5f7b0e6dfd33265aa (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
# $NetBSD: marshall,v 1.12 2004/08/29 14:25:10 wiz Exp $
#
# Handle cases where multiple consecutive arguments must be processed
# together, either by merging the arguments or "skipping" the extra
# arguments.
#
case $arg in
#
# If we see "-I dir" (or -L/-R), we convert it to "-Idir" so that it may be
# transformed correctly.
#
-[ILR])
	arg="$arg$1"
	shift
	;;
#
# Merge "-Wl,-R -Wl,/path/to/dir" into a single argument
# "-Wl,-R/path/to/dir" and merge "-Wl,--rpath -Wl,/path/to/dir" into
# "-Wl,--rpath,/path/to/dir" so that we can look them up in the cache.
# Also deal with "-Xlinker" being equivalent to "-Wl,".
#
-Xlinker|-Wl,-R|-Wl,-rpath|-Wl,-rpath-link|-Wl,--rpath|-Wl,--rpath-link)
	R=
	case $arg in
	-Xlinker)
		case $1 in
		-Wl,-R)				R="$1";	     shift ;;
		-Wl,-rpath|-Wl,-rpath-link)	R="$1,";     shift ;;
		-Wl,--rpath|-Wl,--rpath-link)	R="$1,";     shift ;;
		-Wl,*)				arg="$1";    shift ;;
		-R)				R="-Wl,$1";  shift ;;
		-rpath|-rpath-link)		R="-Wl,$1,"; shift ;;
		--rpath|--rpath-link)		R="-Wl,$1,"; shift ;;
		esac
		;;
	-Wl,-R)					R="$arg"  ;;
	-Wl,-rpath|-Wl,-rpath-link)		R="$arg," ;;
	-Wl,--rpath|-Wl,--rpath-link)		R="$arg," ;;
	esac
	if $test -n "$R"; then
		nextarg=$1; shift
		case $nextarg in
		-Xlinker)  nextarg=$1; shift ;;
		esac
		case $nextarg in
		-Wl,*)	nextarg=`$echo "X$nextarg" | $Xsed -e "s|^-Wl,||g"` ;;
		esac
		arg="$R$nextarg"
	fi
	;;
#
# If we're linking a shared library by "cc -shared -o /srcdir/shlib",
# we need to protect the full path after "-o" from being transformed
# from "/srcdir/shlib" to "-L/srcdir -lshlib"
#
-o)
	skipargs=1
	;;
#
# Darwin's linker uses:
#
#	-dylib_file /path/shlib:/path2/shlib
#	-dylib_install_name /path/shlib
#	-install_name /path/shlib
#
# to pass the installed locations for the shared libraries to the linker,
# and we need to protect the full path from "/path/shlib" -> "-L/path -lshlib"
# transformation. (-seg_addr_table_filename's purpose is more obscure,
# but darwin's imake rules use it.)
#
-dylib_file|-dylib_install_name|-install_name|-seg_addr_table_filename)
	skipargs=1
	;;
esac