Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / bsd / am-utils / dist / buildall
blob6268b89c9313c939c8fb9695f8b9b8cb476857a2
1 #!/bin/sh
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
8 #set -x
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 ../..
15 pwd=`pwd`
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"
20 exit 1
21 else
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'
30 #pat='mntent|mnttab'
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'
34 #pat='yp_all|nsl|nis'
36 ##############################################################################
37 # initialize variables (build command, config command, variables)
38 bld_cmd=""
39 bld_flags=""
40 cnf_cmd=""
41 cnf_flags="-C" # use config.cache cache file
42 inst_cmd=""
43 inst_flags=""
44 mkcnf_cmd=""
45 vars=""
46 expvars=""
47 default=yes
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 ##############################################################################
56 # functions
58 add_gcc_flags1 () {
59 case "${CC}" in
60 cc | */cc )
61 # do nothing
63 * )
64 vars="$vars AM_CFLAGS=\"-Werror\""
65 AM_CFLAGS="-Werror"
66 expvars="$expvars AM_CFLAGS"
68 esac
71 add_gcc_flags2 () {
72 case "${CC}" in
73 cc | */cc )
74 # do nothing
76 * )
77 vars="$vars AM_CFLAGS=\"-Wall -Werror\""
78 AM_CFLAGS="-Wall -Werror"
79 expvars="$expvars AM_CFLAGS"
81 esac
84 add_shared_flags () {
85 cnf_cmd="$cnf_cmd --enable-shared --disable-static"
88 add_prefix_flags () {
89 cnf_cmd="$cnf_cmd --prefix=/usr/local/AMD"
92 ##############################################################################
93 # iterate over all options, and set the command to run with any variables
94 while [ $# != 0 ]; do
95 case "$1" in
96 -b )
97 # look for GNU make if possible
98 gmake --version -f /dev/null > /dev/null 2>&1
99 if [ $? = 0 ]
100 then
101 bld_cmd="${MAKE:-gmake}"
102 else
103 bld_cmd="${MAKE:-make}"
105 default=no
106 shift
109 -i )
110 # look for GNU make if possible
111 gmake --version -f /dev/null > /dev/null 2>&1
112 if [ $? = 0 ]
113 then
114 inst_cmd="${MAKE:-gmake} install"
115 else
116 inst_cmd="${MAKE:-make} install"
118 default=no
119 shift
122 -c )
123 cnf_cmd="../configure --enable-debug=yes"
124 # add_gcc_flags1
125 default=no
126 shift
129 -cs )
130 cnf_cmd="../configure --enable-debug=yes"
131 add_shared_flags
132 # add_gcc_flags1
133 default=no
134 shift
137 -C )
138 cnf_cmd="../configure --enable-debug=yes"
139 add_gcc_flags2
140 default=no
141 shift
144 -Cs )
145 cnf_cmd="../configure --enable-debug=yes"
146 add_shared_flags
147 add_gcc_flags2
148 default=no
149 shift
152 -d )
153 cnf_cmd="../configure --enable-debug=yes"
154 add_prefix_flags
155 # add_gcc_flags1
156 default=no
157 shift
160 -ds )
161 cnf_cmd="../configure --enable-debug=yes"
162 add_prefix_flags
163 add_shared_flags
164 # add_gcc_flags1
165 default=no
166 shift
169 -D )
170 cnf_cmd="../configure --enable-debug=yes"
171 add_prefix_flags
172 add_gcc_flags2
173 default=no
174 shift
177 -Ds )
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"
187 add_prefix_flags
188 add_shared_flags
189 add_gcc_flags2
190 default=no
191 shift
194 -K )
195 # mkcnf_cmd="../m4/mkconf"
196 mkcnf_cmd="../bootstrap"
197 if test -f bootstrap ; then
199 else
200 echo "am-utils maintainer option only!"
201 exit 1
203 default=no
204 shift
207 -q )
208 cnf_cmd="./config.status"
209 default=no
210 shift
213 -- )
214 shift
215 cmdline_cnf_flags="$*"
216 break # from while loop
219 -h | * )
220 cat <<EOF
221 Usage: buildall [-b] [-[cCdD][s]] [-K] [-q] [-h] [-- configopts]
222 -b: build only
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)
234 -h: print usage
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.
239 exit 1
242 esac
243 done
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}"
248 else
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
256 if [ $? = 0 ]
257 then
258 bld_cmd="${MAKE:-gmake}"
259 else
260 bld_cmd="${MAKE:-make}"
262 cnf_cmd="../configure"
263 else
267 ##############################################################################
268 # make build directory if needed
269 if test -d ./A.${host_alias} ; then
271 else
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
285 else
288 else
292 ##############################################################################
293 # Some system's /bin/sh has limits/bugs which prevent it from being used
294 # with configure
295 case "${host_alias}" in
296 *hpux9* | *aix5.1* )
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"
303 else
306 echo "WARNING: do not use /bin/make under this system."
307 echo "Instead, use GNU make or 'ksh ./configure' directly."
309 mips-sgi-irix5.2)
310 echo "WARNING: do not use /bin/make under this system."
311 echo "Instead, use GNU make or ./configure directly."
313 esac
315 ##############################################################################
316 # see if need to run mkconf
317 if test -n "$mkcnf_cmd"; then
318 echo $mkcnf_cmd
319 $mkcnf_cmd || exit 1
320 else
324 ##############################################################################
325 # see if need to [re]configure
326 if test -n "$cnf_cmd"; then
327 if test -n "$vars"; then
328 echo $vars
329 eval $vars
330 echo export $expvars
331 export $expvars
332 else
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
338 else
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
342 else
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
351 else
355 ##############################################################################
356 # if need to install
357 if test -n "$inst_cmd"; then
358 echo $inst_cmd $inst_flags
359 $inst_cmd $inst_flags || exit 1
360 else
364 ##############################################################################