summaryrefslogtreecommitdiff
path: root/mk/buildlink3/buildcmd
blob: d8889296809109b29eb14cf5ec48093990d688d0 (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
# $NetBSD: buildcmd,v 1.4 2004/01/30 10:56:11 jlam Exp $
#
# Append $arg to $cmd to build up the command line to be executed, but
# directly add the next few arguments to $cmd if $skipargs > 0.
#
if $test $skipargs -gt 0; then
	cmd="$cmd $arg"
	while $test $skipargs -gt 0; do
		arg=$1; shift
		. $quotearg
		arg="$qarg"
		cmd="$cmd $arg"
		skipargs=`$expr $skipargs - 1`
	done
else
	#
	# Reduce command length by not appending options that we've
	# already seen to the command.
	#
	case $arg in
	-[DILR]*|-Wl,-R*|-Wl,-*,/*)
		#
		# These options are only ever useful the first time
		# they're given.  All other instances are redundant.
		#
		case $arg in
		-L*)
			case "$ldflags" in
			*" "$arg|*" "$arg" "*)	   ;;
			*) ldflags="$ldflags $arg" ;;
			esac
			;;
		*)
			case "$cmd" in
			*" "$arg|*" "$arg" "*) ;;
			*) cmd="$cmd $arg"     ;;
			esac
			;;
		esac
		;;
	-l*)
		#
		# Suppressed sequentially repeated libraries,
		# e.g. "-lm -lm -lm -lm" -> "-lm".
		#
		case "$libs" in
		*" "$arg)	     ;;
		*) libs="$libs $arg" ;;
		esac
		;;
	*)
		cmd="$cmd $arg"
		;;
	esac
fi