-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildall
executable file
·364 lines (330 loc) · 8.57 KB
/
buildall
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
#!/bin/sh
# Build all of the am-utils package in a directory A.<cpu-company-system>
# Used by am-utils users.
# Erez Zadok <ezk@cs.columbia.edu>
#
# run "buildall -h" to get usage
#
#set -x
##############################################################################
# first test if we are in the right directory to run this script
# change to the right directory
test -f ../config.guess && cd ..
test -f ../../config.guess && cd ../..
pwd=`pwd`
host_alias=`(cd /tmp; $pwd/config.guess.long)`
if test -z "$host_alias" ; then
echo "$0: must run from the source or the A. directory."
echo "$0: cannot find $pwd/config.guess"
exit 1
else
:
fi
##############################################################################
# pattern of lines to remove from config.cache (for developers only)
# Example: if you change TRY_COMPILE_NFS, redo these:
#pat='fhandle|nfs_fh|nfs_args|struct_nfs|opt'
#pat='style_|mount_trap|mtype|transport|dref'
#pat='mntent|mnttab'
#pat='nfs_args|fh_len|irix|proto|vers'
#pat='3|proto|tcp|ver|nfs_prot|mtype'
#pat='trap|style|mtype|transport|os_libs|restartable|unmount_args|yp_order'
#pat='yp_all|nsl|nis'
##############################################################################
# initialize variables (build command, config command, variables)
bld_cmd=""
bld_flags=""
cnf_cmd=""
cnf_flags="-C" # use config.cache cache file
inst_cmd=""
inst_flags=""
mkcnf_cmd=""
vars=""
expvars=""
default=yes
##############################################################################
# check if CFLAGS or AM_CFLAGS was passed
test -z "$CFLAGS" || vars="$vars CFLAGS=\"${CFLAGS}\""
test -z "$CFLAGS" || expvars="$expvars CFLAGS"
test -z "$AM_CFLAGS" || vars="$vars AM_CFLAGS=\"${AM_CFLAGS}\""
##############################################################################
# functions
add_gcc_flags1 () {
case "${CC}" in
cc | */cc )
# do nothing
;;
* )
vars="$vars AM_CFLAGS=\"-Werror\""
AM_CFLAGS="-Werror"
expvars="$expvars AM_CFLAGS"
;;
esac
}
add_gcc_flags2 () {
case "${CC}" in
cc | */cc )
# do nothing
;;
* )
vars="$vars AM_CFLAGS=\"-Wall -Werror\""
AM_CFLAGS="-Wall -Werror"
expvars="$expvars AM_CFLAGS"
;;
esac
}
add_shared_flags () {
cnf_cmd="$cnf_cmd --enable-shared --disable-static"
}
add_prefix_flags () {
cnf_cmd="$cnf_cmd --prefix=/usr/local/AMD"
}
##############################################################################
# iterate over all options, and set the command to run with any variables
while [ $# != 0 ]; do
case "$1" in
-b )
# look for GNU make if possible
gmake --version -f /dev/null > /dev/null 2>&1
if [ $? = 0 ]
then
bld_cmd="${MAKE:-gmake}"
else
bld_cmd="${MAKE:-make}"
fi
default=no
shift
;;
-i )
# look for GNU make if possible
gmake --version -f /dev/null > /dev/null 2>&1
if [ $? = 0 ]
then
inst_cmd="${MAKE:-gmake} install"
else
inst_cmd="${MAKE:-make} install"
fi
default=no
shift
;;
-c )
cnf_cmd="../configure --enable-debug=yes"
# add_gcc_flags1
default=no
shift
;;
-cs )
cnf_cmd="../configure --enable-debug=yes"
add_shared_flags
# add_gcc_flags1
default=no
shift
;;
-C )
cnf_cmd="../configure --enable-debug=yes"
add_gcc_flags2
default=no
shift
;;
-Cs )
cnf_cmd="../configure --enable-debug=yes"
add_shared_flags
add_gcc_flags2
default=no
shift
;;
-d )
cnf_cmd="../configure --enable-debug=yes"
add_prefix_flags
# add_gcc_flags1
default=no
shift
;;
-ds )
cnf_cmd="../configure --enable-debug=yes"
add_prefix_flags
add_shared_flags
# add_gcc_flags1
default=no
shift
;;
-D )
cnf_cmd="../configure --enable-debug=yes"
add_prefix_flags
add_gcc_flags2
default=no
shift
;;
-Ds )
cnf_cmd="../configure -enable-debug=yes"
# cnf_cmd="../configure -enable-debug=mem"
# cnf_cmd="../configure --prefix=/usr/local/AMD --enable-debug=yes --enable-shared --disable-static \
# --enable-cppflags=\"-I${HOME}/ldap/include -I${HOME}/hesiod/include\" \
# --enable-ldflags=\"-L${HOME}/ldap/lib -L${HOME}/hesiod/lib\""
# cnf_cmd="$cnf_cmd \
# --enable-cppflags=-I${HOME}/ldap/include \
# --enable-ldflags=-L${HOME}/ldap/lib"
# cnf_cmd="../configure -enable-debug=yes --enable-cppflags=-I/usr/local/include --enable-ldflags=-L/usr/local/lib"
add_prefix_flags
add_shared_flags
add_gcc_flags2
default=no
shift
;;
-K )
# mkcnf_cmd="../m4/mkconf"
mkcnf_cmd="../bootstrap"
if test -f bootstrap ; then
:
else
echo "am-utils maintainer option only!"
exit 1
fi
default=no
shift
;;
-q )
cnf_cmd="./config.status"
default=no
shift
;;
-- )
shift
cmdline_cnf_flags="$*"
break # from while loop
;;
-h | * )
cat <<EOF
Usage: buildall [-b] [-[cCdD][s]] [-K] [-q] [-h] [-- configopts]
-b: build only
-c: configure (debugging)
-cs: configure (debugging, shared libs)
-C: configure (strict compile, debugging)
-Cs: configure (strict compile, debugging, shared libs)
-d: configure in /usr/local/AMD (debugging)
-ds: configure in /usr/local/AMD (debugging, shared libs)
-D: configure in /usr/local/AMD (strict compile, debugging)
-Ds: configure in /usr/local/AMD (strict compile, debugging, shared libs)
-K: run mkconf to update *.in files (developers only)
-i: build and install
-q: quick configure only (run config.status)
-h: print usage
configopts: options to pass to configure (must be last and after a --)
You may pass variables: CFLAGS for build, MAKE for your make program
and AM_CFLAGS for additional build flags.
EOF
exit 1
;;
esac
done
# if AM_CFLAGS was set before, then add it to the configure option
if test -n "${AM_CFLAGS}"; then
extra_cnf_flags="--enable-am-cflags=${AM_CFLAGS}"
else
:
fi
# check if no options were given, and set to defaults
if test "$default" = "yes"; then
# look for GNU make if possible
gmake --version -f /dev/null > /dev/null 2>&1
if [ $? = 0 ]
then
bld_cmd="${MAKE:-gmake}"
else
bld_cmd="${MAKE:-make}"
fi
cnf_cmd="../configure"
else
:
fi
##############################################################################
# make build directory if needed
if test -d ./A.${host_alias} ; then
:
else
mkdir ./A.${host_alias}
fi
echo "Configuring/building am-utils in directory ./A.${host_alias} ..."
echo cd ./A.${host_alias}
cd ./A.${host_alias} || exit 1
##############################################################################
# this is for developers only (remove config.cache entries)
if test -n "$pat"; then
if test -f config.cache; then
egrep $pat config.cache | while read i; do echo ' '$i;done
egrep -v $pat config.cache > tmp.$$ && \
mv config.cache config.cache.old && mv tmp.$$ config.cache
else
:
fi
else
:
fi
##############################################################################
# Some system's /bin/sh has limits/bugs which prevent it from being used
# with configure
case "${host_alias}" in
*hpux9* | *aix5.1* )
if test -n "$cnf_cmd"; then
if test -f /bin/bash; then
cnf_cmd="/bin/bash $cnf_cmd"
elif test -f /bin/ksh; then
cnf_cmd="/bin/ksh $cnf_cmd"
fi
else
:
fi
echo "WARNING: do not use /bin/make under this system."
echo "Instead, use GNU make or 'ksh ./configure' directly."
;;
mips-sgi-irix5.2)
echo "WARNING: do not use /bin/make under this system."
echo "Instead, use GNU make or ./configure directly."
;;
esac
##############################################################################
# see if need to run mkconf
if test -n "$mkcnf_cmd"; then
echo $mkcnf_cmd
$mkcnf_cmd || exit 1
else
:
fi
##############################################################################
# see if need to [re]configure
if test -n "$cnf_cmd"; then
if test -n "$vars"; then
echo $vars
eval $vars
echo export $expvars
export $expvars
else
:
fi
if test -z "${cnf_flags}${extra_cnf_flags}"; then
echo $cnf_cmd $cmdline_cnf_flags
$cnf_cmd $cmdline_cnf_flags || exit 1
else
echo $cnf_cmd "$cnf_flags" "$extra_cnf_flags" $cmdline_cnf_flags
$cnf_cmd "$cnf_flags" "$extra_cnf_flags" $cmdline_cnf_flags || exit 1
fi
else
:
fi
##############################################################################
# if need to [re]build
if test -n "$bld_cmd"; then
echo $bld_cmd $bld_flags
$bld_cmd $bld_flags || exit 1
else
:
fi
##############################################################################
# if need to install
if test -n "$inst_cmd"; then
echo $inst_cmd $inst_flags
$inst_cmd $inst_flags || exit 1
else
:
fi
##############################################################################