Whamcloud - gitweb
file jbd-stats-2.6.9.patch was initially added on branch b1_4.
[fs/lustre-release.git] / lnet / tests / build-osx
1 #! /bin/sh
2
3 if false ;then
4         OPTVAL=`getopt -o cb:l:s:k:L:v -n 'build-all' -- "$@"`
5 else
6         # XNU/BSD getopt is special...
7         OPTVAL=$(getopt cb:l:s:k:L:v "$@")
8 fi
9
10 if [ $? != 0 ]
11 then
12         echo 'Usage: see source...'
13         exit 2
14 fi
15
16 eval set -- "$OPTVAL"
17
18 cd $(dirname $0)
19
20 #set -x
21
22 b=$PWD # base directory
23 l=$b/build.log    # where to log operations
24 s=$b/build.seq    # build sequence
25 k=$b/kext.stage   # where to place kexts after build
26
27 load=''           # list of kexts to load
28 clean=0
29 verbose=0
30
31 while true ;do
32         case "$1" in
33                 -c)
34                         clean=1
35                         shift 1
36                 ;;
37                 -v)
38                         verbose=$(($verbose + 1))
39                         shift 1
40                 ;;
41                 -b)
42                         b=$2
43                         shift 2
44                 ;;
45                 -l)
46                         l=$2
47                         shift 2
48                 ;;
49                 -s)
50                         s=$2
51                         shift 2
52                 ;;
53                 -k)
54                         k=$2
55                         shift 2
56                 ;;
57                 -L)
58                         load=$2
59                         shift 2
60                 ;;
61                 --) 
62                         shift 
63                         break 
64                 ;;
65                 *) 
66                         echo "Internal error!" 
67                         exit 1 
68                 ;;
69         esac
70 done
71
72 echo > $l
73
74 function message ()
75 {
76         local msg
77
78         msg="$1"
79         echo $msg
80         echo $msg >> $l
81 }
82
83 function abort ()
84 {
85         local msg
86
87         msg=$1
88
89         message "$1"
90         exit 1
91 }
92
93 function configure_xcode ()
94 {
95         local path
96         local pfile
97         local module
98
99         path=$PWD
100         module=$(basename $path)
101         pfile=$path/$module.xcode/project.pbxproj
102         if [ -r $pfile.template ] ;then
103                 cpp \
104                         -P \
105                         -include $b/build-config \
106                         $pfile.template | \
107                 tail +2 > $pfile
108         else
109                 abort "missing $pfile.template"
110         fi
111 }
112
113 if [ x$clean != x0 ] ;then
114         echo "Removing..."
115         find $b/ -type d -name build
116         rm -fr $(find $b/ -type d -name build)
117         find $b/ -print0 | xargs -0 touch
118 fi
119
120 cat $s | while read ;do
121         d=$REPLY
122         if [ x$d = x ] ;then
123                 : # empty line. Do nothing
124         elif [ ${d:0:1} = '#' ] ;then
125                 : # comment. Skip
126         else
127                 cd $d  || abort "Cannot cd to $d"
128                 message "________ Building in $d __________"
129                 #configure_xcode
130         if [ $verbose -gt 0 ] ;then
131             xcodebuild 2>&1 | tee -a $l
132         else
133                     xcodebuild >> $l 2>&1 || abort "Build failure in $d. See $l"
134         fi
135                 # tail -2 $l
136                 cd $b
137         fi
138 done
139
140 # copy all built kexts into $k
141 # sudo is used, because extensions are later chowned to root.
142 sudo rm -f ../include/arch
143 ln -s ../include/arch-xnu ../include/arch
144 sudo rm -fr $k || abort "Cannot clean $k"
145 mkdir $k || abort "Cannot create $k"
146 cp -R $(find ../ -name \*.kext -type d) $k || abort "Cannot stage kexts"
147 cd $k || abort "Cannot chdir to $k"
148 sudo chown -R root:wheel * || abort "Cannot chown kexts to root:wheel"
149
150 if [ x$load != x ] ;then
151         cd $k
152         sudo kextload -r $k $load
153 else    
154         sudo chown -R root:wheel *
155 fi
156 cd $b
157
158 sync;sync;sync
159