-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakei.sh
executable file
·93 lines (71 loc) · 1.74 KB
/
makei.sh
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
#
# makei.sh
#
cmdline=makei
usagestr=$(
cat <<EOF
$ $(basename $0) directory
\tCreate .i files from all the c files in the kernel tree.
\t - This must be executed from the top of the kernel tree.
\0
EOF
)
usage() {
echo -e "$usagestr"
exit
}
[ $# -gt 0 ] || usage
dirspec=$1
if ! [ -d "$dirspec" ]; then
echo
echo "$dirspec is not a directory"
usage
fi
cpucount=$(cat /proc/cpuinfo | grep processor | wc -l)
# leave one processor on multi-processor systems.
#
[ $cpucount -gt 1 ] && let --cpucount
START1=$(date +%s)
echo -e "\n********* Creating file list *********** \n"
echo -e "\tThis could take a while.\n"
files=$(find $dirspec -type f -name \*.c -exec sh -c \
'path=$(dirname $1); \
file=$(basename $1); \
suffix=${file#*.}; \
[ "$suffix" != "c" ] && exit; \
stem=${file%.*}; \
grep -qm1 "EXPORT_SYMBOL" $1; \
[ $? -eq 0 ] || exit; \
echo -n "$path/$stem.i "' \
sh '{}' \;)
END=$(date +%s)
DIFF=$(( $END - $START1 ))
minutes=$(( $DIFF / 60 ))
seconds=$(( $DIFF % 60 ))
echo
echo "That took $minutes minutes and $seconds seconds."
echo
START2=$(date +%s)
echo -e "\n************** make the .i files *****************\n"
echo -e "\tGo get some coffee. This will take some time."
echo
echo -e "\tThis script seeks to execute the gcc preprocessor"
echo -e "\ton every .c file in the tree starting at $dirspec."
echo
echo "$ make -k -j$cpucount \<list of .i files\>"
echo
make -k -j$cpucount $files 2>/dev/null
END=$(date +%s)
DIFF=$(( $END - $START2 ))
minutes=$(( $DIFF / 60 ))
seconds=$(( $DIFF % 60 ))
echo
echo "That took $minutes minutes and $seconds seconds."
echo
DIFF=$(( $END - $START1 ))
minutes=$(( $DIFF / 60 ))
seconds=$(( $DIFF % 60 ))
echo
echo "Total running time: $minutes minutes and $seconds seconds."
echo