summaryrefslogtreecommitdiff
path: root/src/cmd/INIT/cc.darwin
blob: 081bd43b58ef2a5d059acad73e8615cf3aa43af1 (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
: unix wrapper for mac osx cc : 2012-01-20 :

HOSTTYPE=darwin.generic

case " $* " in
*" -dumpmachine "*) echo $HOSTTYPE; exit ;;
esac

CC=/usr/bin/cc
op=init
for arg
do	case $op in
	init)	op=ld
		set ''
		;;
	esac
	case $arg in
	-c)	op=cc
		;;
	-E)	op=cpp
		continue
		;;
	-G)	op=dll
		continue
		;;
	-lc)	continue
		;;
	-lm)	continue
		;;
	-O)	continue
		;;
	esac
	set "$@" "$arg"
done
case $# in
0)	;;
*)	shift ;;
esac
case $* in
-v)	$CC "$@"; exit ;;
esac
case $op in
init)	echo "cc: arguments expected" >&2
	exit 1
	;;
cpp)	$CC -E "$@"
	;;
cc)	$CC -DCLK_TCK=100 "$@"
	;;
dll)	# what a compatibility mess -- surely they can get the apis to play nice
	tmp=/tmp/cc.${USER:-$LOGNAME}.$$.err
	trap "rm -f $tmp" EXIT
	case `MACOSX_DEPLOYMENT_TARGET=10.3 ld -undefined dynamic_lookup 2>&1` in
	*undefined*dynamic_lookup*)
		ld -m -flat_namespace -undefined suppress -dylib -dynamic \
			-ldylib1.o "$@" -lcc_dynamic -framework System >$tmp 2>&1
		status=$?
		;;
	*)	MACOSX_DEPLOYMENT_TARGET=10.3 $CC -Wl,-flat_namespace -dynamiclib -undefined dynamic_lookup "$@" >$tmp 2>&1
		status=$?
		;;
	esac
	egrep -v ' (warning .*multiple definitions|definition) of ' $tmp >&2
	exit $status
	;;
ld)	tmp=/tmp/cc.${USER:-$LOGNAME}.$$.err
	trap "rm -f $tmp" EXIT
	$CC -Wl,-m -DCLK_TCK=100 "$@" >$tmp 2>&1
	status=$?
	egrep -v ' (warning .*multiple definitions of|definition of|as lazy binding|not from earlier dynamic) ' $tmp >&2
	exit $status
	;;
esac