2 # Build all of the am-utils package in a directory A.<cpu-company-system>
3 # Used by am-utils users.
4 # Erez Zadok <ezk AT am-utils.org>
6 # run "buildall -h" to get usage
10 ##############################################################################
11 # first test if we are in the right directory to run this script
12 # change to the right directory
13 test -f ..
/config.guess
&& cd ..
14 test -f ..
/..
/config.guess
&& cd ..
/..
16 host_alias
=`(cd /tmp; $pwd/config.guess.long)`
17 if test -z "$host_alias" ; then
18 echo "$0: must run from the source or the A. directory."
19 echo "$0: cannot find $pwd/config.guess"
25 ##############################################################################
26 # pattern of lines to remove from config.cache (for developers only)
27 # Example: if you change TRY_COMPILE_NFS, redo these:
28 #pat='fhandle|nfs_fh|nfs_args|struct_nfs|opt'
29 #pat='style_|mount_trap|mtype|transport|dref'
31 #pat='nfs_args|fh_len|irix|proto|vers'
32 #pat='3|proto|tcp|ver|nfs_prot|mtype'
33 #pat='trap|style|mtype|transport|os_libs|restartable|unmount_args|yp_order'
36 ##############################################################################
37 # initialize variables (build command, config command, variables)
41 cnf_flags
="-C" # use config.cache cache file
49 ##############################################################################
50 # check if CFLAGS or AM_CFLAGS was passed
51 test -z "$CFLAGS" || vars
="$vars CFLAGS=\"${CFLAGS}\""
52 test -z "$CFLAGS" || expvars
="$expvars CFLAGS"
53 test -z "$AM_CFLAGS" || vars
="$vars AM_CFLAGS=\"${AM_CFLAGS}\""
55 ##############################################################################
64 vars
="$vars AM_CFLAGS=\"-Werror\""
66 expvars
="$expvars AM_CFLAGS"
77 vars
="$vars AM_CFLAGS=\"-Wall -Werror\""
78 AM_CFLAGS
="-Wall -Werror"
79 expvars
="$expvars AM_CFLAGS"
85 cnf_cmd
="$cnf_cmd --enable-shared --disable-static"
89 cnf_cmd
="$cnf_cmd --prefix=/usr/local/AMD"
92 ##############################################################################
93 # iterate over all options, and set the command to run with any variables
97 # look for GNU make if possible
98 gmake
--version -f /dev
/null
> /dev
/null
2>&1
101 bld_cmd
="${MAKE:-gmake}"
103 bld_cmd
="${MAKE:-make}"
110 # look for GNU make if possible
111 gmake
--version -f /dev
/null
> /dev
/null
2>&1
114 inst_cmd
="${MAKE:-gmake} install"
116 inst_cmd
="${MAKE:-make} install"
123 cnf_cmd
="../configure --enable-debug=yes"
130 cnf_cmd
="../configure --enable-debug=yes"
138 cnf_cmd
="../configure --enable-debug=yes"
145 cnf_cmd
="../configure --enable-debug=yes"
153 cnf_cmd
="../configure --enable-debug=yes"
161 cnf_cmd
="../configure --enable-debug=yes"
170 cnf_cmd
="../configure --enable-debug=yes"
178 cnf_cmd
="../configure -enable-debug=yes"
179 # cnf_cmd="../configure -enable-debug=mem"
180 # cnf_cmd="../configure --prefix=/usr/local/AMD --enable-debug=yes --enable-shared --disable-static \
181 # --enable-cppflags=\"-I${HOME}/ldap/include -I${HOME}/hesiod/include\" \
182 # --enable-ldflags=\"-L${HOME}/ldap/lib -L${HOME}/hesiod/lib\""
183 # cnf_cmd="$cnf_cmd \
184 # --enable-cppflags=-I${HOME}/ldap/include \
185 # --enable-ldflags=-L${HOME}/ldap/lib"
186 # cnf_cmd="../configure -enable-debug=yes --enable-cppflags=-I/usr/local/include --enable-ldflags=-L/usr/local/lib"
195 # mkcnf_cmd="../m4/mkconf"
196 mkcnf_cmd
="../bootstrap"
197 if test -f bootstrap
; then
200 echo "am-utils maintainer option only!"
208 cnf_cmd
="./config.status"
215 cmdline_cnf_flags
="$*"
216 break # from while loop
221 Usage: buildall [-b] [-[cCdD][s]] [-K] [-q] [-h] [-- configopts]
223 -c: configure (debugging)
224 -cs: configure (debugging, shared libs)
225 -C: configure (strict compile, debugging)
226 -Cs: configure (strict compile, debugging, shared libs)
227 -d: configure in /usr/local/AMD (debugging)
228 -ds: configure in /usr/local/AMD (debugging, shared libs)
229 -D: configure in /usr/local/AMD (strict compile, debugging)
230 -Ds: configure in /usr/local/AMD (strict compile, debugging, shared libs)
231 -K: run mkconf to update *.in files (developers only)
232 -i: build and install
233 -q: quick configure only (run config.status)
235 configopts: options to pass to configure (must be last and after a --)
236 You may pass variables: CFLAGS for build, MAKE for your make program
237 and AM_CFLAGS for additional build flags.
245 # if AM_CFLAGS was set before, then add it to the configure option
246 if test -n "${AM_CFLAGS}"; then
247 extra_cnf_flags
="--enable-am-cflags=${AM_CFLAGS}"
252 # check if no options were given, and set to defaults
253 if test "$default" = "yes"; then
254 # look for GNU make if possible
255 gmake
--version -f /dev
/null
> /dev
/null
2>&1
258 bld_cmd
="${MAKE:-gmake}"
260 bld_cmd
="${MAKE:-make}"
262 cnf_cmd
="../configure"
267 ##############################################################################
268 # make build directory if needed
269 if test -d .
/A.
${host_alias} ; then
272 mkdir .
/A.
${host_alias}
274 echo "Configuring/building am-utils in directory ./A.${host_alias} ..."
275 echo cd .
/A.
${host_alias}
276 cd .
/A.
${host_alias} ||
exit 1
278 ##############################################################################
279 # this is for developers only (remove config.cache entries)
280 if test -n "$pat"; then
281 if test -f config.cache
; then
282 egrep $pat config.cache |
while read i
; do echo ' '$i;done
283 egrep -v $pat config.cache
> tmp.$$
&& \
284 mv config.cache config.cache.old
&& mv tmp.$$ config.cache
292 ##############################################################################
293 # Some system's /bin/sh has limits/bugs which prevent it from being used
295 case "${host_alias}" in
297 if test -n "$cnf_cmd"; then
298 if test -f /bin
/bash
; then
299 cnf_cmd
="/bin/bash $cnf_cmd"
300 elif test -f /bin
/ksh
; then
301 cnf_cmd
="/bin/ksh $cnf_cmd"
306 echo "WARNING: do not use /bin/make under this system."
307 echo "Instead, use GNU make or 'ksh ./configure' directly."
310 echo "WARNING: do not use /bin/make under this system."
311 echo "Instead, use GNU make or ./configure directly."
315 ##############################################################################
316 # see if need to run mkconf
317 if test -n "$mkcnf_cmd"; then
324 ##############################################################################
325 # see if need to [re]configure
326 if test -n "$cnf_cmd"; then
327 if test -n "$vars"; then
335 if test -z "${cnf_flags}${extra_cnf_flags}"; then
336 echo $cnf_cmd $cmdline_cnf_flags
337 $cnf_cmd $cmdline_cnf_flags ||
exit 1
339 echo $cnf_cmd "$cnf_flags" "$extra_cnf_flags" $cmdline_cnf_flags
340 $cnf_cmd "$cnf_flags" "$extra_cnf_flags" $cmdline_cnf_flags ||
exit 1
346 ##############################################################################
347 # if need to [re]build
348 if test -n "$bld_cmd"; then
349 echo $bld_cmd $bld_flags
350 $bld_cmd $bld_flags ||
exit 1
355 ##############################################################################
357 if test -n "$inst_cmd"; then
358 echo $inst_cmd $inst_flags
359 $inst_cmd $inst_flags ||
exit 1
364 ##############################################################################