aboutsummaryrefslogtreecommitdiff
path: root/scripts/mkobjs
blob: 188465b81bc8b0d6b5b43920d9797ada25e5cff5 (plain) (blame)
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
#!/bin/sh

genobj () {
	path=$(dirname "$1")/
	obj=$(echo "$1" | sed "s/\\.[cS]/.${command_suffix}.o/")
	$cc_command -MM -MP $n | \
		sed "s|\\(.*\)\\.o|${path}\\1.${command_suffix}.o|" >> deps.mk

	echo "$obj: $n" >> deps.mk
	echo "	$cc_command -c $1 -o $obj" >> deps.mk

	cc_objs="$cc_objs $obj"
}

genlink () {
	link=$(echo "$1" | sed 's/\.S/.ld/')
	echo "$link: $1" >> deps.mk
	echo "	$cc_command $1 | sed -n '/^[^#]/p' > $link" >> deps.mk

	cc_objs="$cc_objs $link"
}

for n in "$@"
do
	case "$n" in
		--kern-files)
			command_suffix=k
			command_func=genobj
			continue
			;;

		--kern-lds)
			command_func=genlink
			continue
			;;

		--init-files)
			command_suffix=i
			command_func=genobj
			continue
			;;

		--init-lds)
			command_func=genlink
			continue
			;;
	esac

	if [ "$command_func" = "" ]
	then
		cc_command="$cc_command $n"
	else
		$command_func "$n"
	fi
done

echo "$cc_objs"