Import sendmail 8.13.7
[dragonfly.git] / contrib / sendmail-8.13.7 / devtools / bin / Build
bloba973aba3db63c6eebfd70e436a577a2df82304fe
1 #!/bin/sh
3 # Copyright (c) 1998-2002 Sendmail, Inc. and its suppliers.
4 # All rights reserved.
5 # Copyright (c) 1993, 1996-1997 Eric P. Allman. All rights reserved.
6 # Copyright (c) 1993
7 # The Regents of the University of California. All rights reserved.
9 # By using this file, you agree to the terms and conditions set
10 # forth in the LICENSE file which can be found at the top level of
11 # the sendmail distribution.
14 # $Id: Build,v 8.186 2006/03/15 19:46:04 eric Exp $
18 # A quick-and-dirty script to compile sendmail and related programs
19 # in the presence of multiple architectures. To use, just use
20 # "sh Build".
23 trap "rm -f $obj/.settings$$; exit" 1 2 3 15
25 cflag=""
26 mflag=""
27 Mflag=""
28 Aflag=""
29 sflag=""
30 makeargs=""
31 libdirs=""
32 incdirs=""
33 libsrch=""
34 libpath=""
35 siteconfig=""
36 pfx=""
37 obj=""
38 oscf=""
39 arch=""
40 os=""
41 rel=""
42 mkdir="mkdir -p"
43 SENDMAIL_BUILD_FLAGS=""
44 EX_OK=0
45 EX_USAGE=64
46 EX_NOINPUT=66
47 EX_UNAVAILABLE=69
48 SHELL=/bin/sh
50 # default to a optimized build to behave like the old system.
51 build_variant="optimized"
53 full_src_dir=`pwd`
54 if [ -z "$src_dir" ]
55 then
56 src_dir=`basename ${full_src_dir}`
58 absolute_base_dir=`echo ${full_src_dir} | sed "s#${src_dir}\\$##"`
59 obj_rel_base_dir='../..'
61 while [ ! -z "$1" ]
63 case $1
65 -src) # Specify pathname of source directory relative to
66 # root of cvs tree. This relative pathname may have
67 # multiple components, as in 'foo/bar/baz', and will also
68 # be used to form the pathname of the object directory.
69 shift
70 arg=$1
71 if [ -z "$arg" ]
72 then
73 echo "Missing arg for -src" >&2
74 exit $EX_USAGE
76 case $arg
78 /*) echo "Arg for -src must not begin with / ($arg)" >&2
79 exit $EX_USAGE
81 esac
82 src_dir="$arg"
83 absolute_base_dir=`echo ${full_src_dir} | sed "s;/${src_dir}$;;"`
84 obj_rel_base_dir=`echo x/${src_dir} | sed "s;[^/][^/]*;..;g"`
85 SMROOT=${absolute_base_dir}
86 shift
88 -c) # clean out existing $obj tree
89 cflag=1
90 SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS $1"
91 shift
94 -m) # show Makefile name only
95 mflag=1
96 shift
99 -M) # show the name of the obj. directory
100 Mflag=1
101 shift
104 -A) # show the name of the architecture
105 Aflag=1
106 shift
109 -E*) # environment variables to pass into Build
110 arg=`echo $1 | sed 's/^-E//'`
111 if [ -z "$arg" ]
112 then
113 shift # move to argument
114 arg=$1
116 if [ -z "$arg" ]
117 then
118 echo "Empty -E flag" >&2
119 exit $EX_USAGE
120 else
121 case $arg
123 *=*) # check format
124 eval $arg
125 export `echo $arg | sed 's;=.*;;'`
126 SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS -E \"$arg\""
128 *) # bad format
129 echo "Bad format for -E argument ($arg)" >&2
130 exit $EX_USAGE
132 esac
133 shift
137 -L*) # set up LIBDIRS
138 libdirs="$libdirs $1"
139 SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS $1"
140 shift
143 -I*) # set up INCDIRS
144 incdirs="$incdirs $1"
145 SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS $1"
146 shift
149 -f*) # select site config file
150 arg=`echo $1 | sed 's/^-f//'`
151 if [ -z "$arg" ]
152 then
153 shift # move to argument
154 arg=$1
156 if [ "$pfx" ]
157 then
158 echo "May not use -f and -Q together"
159 exit $EX_USAGE
161 if [ "$siteconfig" ]
162 then
163 echo "Only one -f flag allowed" >&2
164 exit $EX_USAGE
165 else
166 siteconfig=$arg
167 if [ -z "$siteconfig" ]
168 then
169 echo "Missing argument for -f flag" >&2
170 exit $EX_USAGE
171 elif [ ! -f "$siteconfig" ]
172 then
173 echo "${siteconfig}: File not found"
174 exit $EX_NOINPUT
175 else
176 shift # move past argument
177 case $arg
180 SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS -f \"$siteconfig\""
183 SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS -f \"${full_src_dir}/$siteconfig\""
185 esac
190 -O*) # Set object directory manually.
191 arg="`echo $1 | sed 's/^-O//'`"
192 if [ -z "$arg" ]
193 then
194 shift # move to argument
195 arg="$1"
197 case $arg
200 OBJ_ROOT="$arg"
201 SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS -O \"$OBJ_ROOT\""
202 obj_rel_base_dir=$absolute_base_dir
205 echo "Absolute directory path required for -O flag" >&2
206 exit $EX_USAGE
208 esac
209 shift
212 -S) # skip auto-configure
213 sflag="-s"
214 SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS $1"
215 shift
218 -Q*) # Select a prefix for the Site/*.config.m4 file
219 arg=`echo $1 | sed 's/^-Q//'`
220 if [ -z "$arg" ]
221 then
222 shift # move to argument
223 arg=$1
225 if [ -z "$arg" ]
226 then
227 echo "Empty -Q flag" >&2
228 exit $EX_USAGE
229 elif [ "$siteconfig" ]
230 then
231 echo "May not use -Q and -f together" >&2
232 exit $EX_USAGE
233 elif [ "$pfx" ]
234 then
235 echo "Only one -Q allowed" >&2
236 exit $EX_USAGE
237 else
238 pfx=$arg
239 SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS -Q \"$pfx\""
241 shift
244 -v) # Select a build variant: debug, optimized, purify, whatever.
245 shift
246 build_variant=$1
247 if [ -z "$build_variant" ]
248 then
249 echo "Usage error with \"-v\" <build_variant>" >&2
250 echo "You must specify exactly one build variant of debug|optimized|purify" >&2
251 exit $EX_USAGE
253 shift
256 *) # pass argument to make
257 makeargs="$makeargs \"$1\""
258 #SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS \"$1\""
259 shift
261 esac
262 done
264 # process selected build variant.
265 case $build_variant in
266 debug)
267 M4_BLDVARIANT_FLAGS="-DconfBLDVARIANT=DEBUG"
269 optimized)
270 M4_BLDVARIANT_FLAGS="-DconfBLDVARIANT=OPTIMIZED"
272 purify)
273 M4_BLDVARIANT_FLAGS="-DconfBLDVARIANT=PURIFY"
274 echo "Sorry, the purify build variant has not been plumbed yet. (Bummer.)" >&2
275 exit $EX_USAGE
278 exit $EX_USAGE
280 esac
284 # Do heuristic guesses !ONLY! for machines that do not have uname
286 if [ -d /NextApps -a ! -f /bin/uname -a ! -f /usr/bin/uname ]
287 then
288 # probably a NeXT box
289 arch=`hostinfo | sed -n 's/.*Processor type: \([^ ]*\).*/\1/p'`
290 os=NeXT
291 rel=`hostinfo | sed -n 's/.*NeXT Mach \([0-9\.]*\).*/\1/p'`
292 elif [ -f /usr/sony/bin/machine -a -f /etc/osversion ]
293 then
294 # probably a Sony NEWS 4.x
295 os=NEWS-OS
296 rel=`awk '{ print $3}' /etc/osversion`
297 arch=`/usr/sony/bin/machine`
298 elif [ -d /usr/omron -a -f /bin/luna ]
299 then
300 # probably a Omron LUNA
301 os=LUNA
302 if [ -f /bin/luna1 ] && /bin/luna1
303 then
304 rel=unios-b
305 arch=luna1
306 elif [ -f /bin/luna2 ] && /bin/luna2
307 then
308 rel=Mach
309 arch=luna2
310 elif [ -f /bin/luna88k ] && /bin/luna88k
311 then
312 rel=Mach
313 arch=luna88k
315 elif [ -d /usr/apollo -a -d \`node_data ]
316 then
317 # probably a Apollo/DOMAIN
318 os=DomainOS
319 arch=$ISP
320 rel=`/usr/apollo/bin/bldt | grep Domain | awk '{ print $4 }' | sed -e 's/,//g'`
323 if [ ! "$arch" -a ! "$os" -a ! "$rel" ]
324 then
325 arch=`uname -m | sed -e 's/ //g' -e 's/\//-/g'`
326 os=`uname -s | sed -e 's/\//-/g' -e 's/ //g'`
327 rel=`uname -r | sed -e 's/(/-/g' -e 's/)//g' -e 's/ //g'`
331 # Tweak the values we have already got. PLEASE LIMIT THESE to
332 # tweaks that are absolutely necessary because your system uname
333 # routine doesn't return something sufficiently unique. Don't do
334 # it just because you don't like the name that is returned. You
335 # can combine the architecture name with the os name to create a
336 # unique Makefile name.
339 # tweak machine architecture
340 case $arch
342 sun4*) arch=sun4;;
344 9000/*) arch=`echo $arch | sed -e 's/9000.//' -e 's/..$/xx/'`;;
346 DS/907000) arch=ds90;;
348 NILE*) arch=NILE
349 os=`uname -v`;;
351 CRAYT3E) os=UNICOS-mk;;
353 CRAY[CJT]90*|CRAYTS|CRAYSV1*|CRAYY-MP)
354 os=UNICOS;;
355 esac
357 # tweak operating system type and release
358 node=`uname -n | sed -e 's/\//-/g' -e 's/ //g'`
359 if [ "$os" = "$node" -a "$arch" = "i386" -a "$rel" = 3.2 -a "`uname -v`" = 2 ]
360 then
361 # old versions of SCO UNIX set uname -s the same as uname -n
362 os=SCO_SV
364 if [ "$rel" = 4.0 ]
365 then
366 case $arch in
367 3[34]??|3[34]??,*|3[34]??[A-Z]|4[48]??|56??)
368 if [ -d /usr/sadm/sysadm/add-ons/WIN-TCP ]
369 then
370 os=NCR.MP-RAS
371 rel=2.x
372 arch=i486
373 elif [ -d /usr/sadm/sysadm/add-ons/inet ]
374 then
375 os=NCR.MP-RAS
376 rel=3.x
377 arch=i486
380 esac
383 case $os
385 DYNIX-ptx) os=PTX;;
386 Paragon*) os=Paragon;;
387 HP-UX) rel=`echo $rel | sed -e 's/^[^.]*\.0*//'`;;
388 AIX) osl=""
389 if [ -x /bin/lslpp ]
390 then
391 osl=`/bin/lslpp -Lcq bos.rte | cut -f3 -d: | cut -f1-3 -d. 2>/dev/null`
392 if [ $? = 0 -a -n "$osl" ]
393 then
394 rel=$osl
395 else
396 # command failed; fall back to old method
397 osl=""
400 # check whether it worked
401 if [ -z "$osl" ]
402 then
403 rela=$rel
404 rel=`uname -v`
405 rel=$rel.$rela
407 arch=PPC
409 BSD-386) os=BSD-OS;;
410 SCO_SV) os=SCO; rel=`uname -X | sed -n 's/Release = 3.2v//p'`;;
411 UNIX_System_V) if [ "$arch" = "ds90" ]
412 then
413 os="UXPDS"
414 rel=`uname -v | sed -e 's/\(V.*\)L.*/\1/'`
415 fi;;
416 ReliantUNIX-?|SINIX-?) os=SINIX;;
417 DomainOS) case $rel in
418 10.4*) rel=10.4;;
419 esac
421 IRIX*) rel=`echo $rel | sed -e 's/-.*$//'`;;
422 NeXT) mkdir="mkdirs";;
423 UNICOSMK) rel=`echo $rel | sed -e 's/\(.*\)\.\(.*\)\.\(.*\)\..*$/\1.\2.\3/'`;;
424 UNICOS*) rel=`echo $rel | sed -e 's/\(.*\)\.\(.*\)\..*$/\1.\2/'`;;
425 esac
427 # get "base part" of operating system release
428 rroot=`echo $rel | sed -e 's/\.[^.]*$//'`
429 rbase=`echo $rel | sed -e 's/\..*//'`
430 if [ "$rroot" = "$rbase" ]
431 then
432 rroot=$rel
435 # heuristic tweaks to clean up names -- PLEASE LIMIT THESE!
436 if [ "$os" = "unix" ]
437 then
438 # might be Altos System V
439 case $rel
441 5.3*) os=Altos;;
442 esac
443 elif [ -r /unix -a -r /usr/lib/libseq.a -a -r /lib/cpp ]
444 then
445 # might be a DYNIX/ptx 2.x system, which has a broken uname
446 if strings /lib/cpp | grep _SEQUENT_ > /dev/null
447 then
448 os=PTX
450 elif [ -d /usr/nec ]
451 then
452 # NEC machine -- what is it running?
453 if [ "$os" = "UNIX_System_V" ]
454 then
455 os=EWS-UX_V
456 elif [ "$os" = "UNIX_SV" ]
457 then
458 os=UX4800
460 elif [ "$arch" = "mips" ]
461 then
462 case $rel
464 4_*)
465 if [ `uname -v` = "UMIPS" ]
466 then
467 os=RISCos
468 fi;;
469 esac
472 # see if there is a "user suffix" specified
473 if [ "${SENDMAIL_SUFFIX-}x" = "x" ]
474 then
475 sfx=""
476 else
477 sfx=".${SENDMAIL_SUFFIX}"
480 if [ ! -n "$Mflag" -a ! -n "$Aflag" ]
481 then
482 echo "Configuration: pfx=$pfx, os=$os, rel=$rel, rbase=$rbase, rroot=$rroot, arch=$arch, sfx=$sfx, variant=$build_variant"
485 SMROOT=${SMROOT-`(cd ..;pwd)`}
486 BUILDTOOLS=${BUILDTOOLS-$SMROOT/devtools}
487 export SMROOT BUILDTOOLS
489 # see if we are in a Build-able directory
490 if [ ! -f Makefile.m4 -a ! -n "$Aflag" ]; then
491 echo "Makefile.m4 not found. Build can only be run from a source directory."
492 exit $EX_UNAVAILABLE
495 incdirs="$incdirs -I\${SRCDIR}/include"
497 if [ -z "$OBJ_ROOT" ]; then
498 OBJ_ROOT=${SMROOT}
501 if [ "${pfx}x" = "x" ]
502 then
503 prefix=""
504 else
505 prefix=".$pfx"
508 # Print out the architecture (to build up an obj dir path) and exit
509 if [ -n "$Aflag" ]
510 then
511 echo "$os.$rel.$arch$sfx"
512 exit $EX_OK
515 # now try to find a reasonable object directory
516 if [ -r ${OBJ_ROOT}/obj${prefix}.$os.$rel.$arch$sfx ]; then
517 abs_obj_dir=${OBJ_ROOT}/obj${prefix}.$os.$rel.$arch$sfx
518 elif [ -r ${OBJ_ROOT}/obj${prefix}.$os.$rroot.$arch$sfx ]; then
519 abs_obj_dir=${OBJ_ROOT}/obj${prefix}.$os.$rroot.$arch$sfx
520 elif [ -r ${OBJ_ROOT}/obj${prefix}.$os.$rbase.x.$arch$sfx ]; then
521 abs_obj_dir=${OBJ_ROOT}/obj${prefix}.$os.$rbase.x.$arch$sfx
522 elif [ -r ${OBJ_ROOT}/obj${prefix}.$os.$rel$sfx ]; then
523 abs_obj_dir=${OBJ_ROOT}/obj${prefix}.$os.$rel$sfx
524 elif [ -r ${OBJ_ROOT}/obj${prefix}.$os.$rbase.x$sfx ]; then
525 abs_obj_dir=${OBJ_ROOT}/obj${prefix}.$os.$rbase.x$sfx
526 elif [ -r ${OBJ_ROOT}/obj${prefix}.$os.$arch$sfx ]; then
527 abs_obj_dir=${OBJ_ROOT}/obj${prefix}.$os.$arch$sfx
528 elif [ -r ${OBJ_ROOT}/obj${prefix}.$rel.$arch$sfx ]; then
529 abs_obj_dir=${OBJ_ROOT}/obj${prefix}.$rel.$arch$sfx
530 elif [ -r ${OBJ_ROOT}/obj${prefix}.$rbase.x.$arch$sfx ]; then
531 abs_obj_dir=${OBJ_ROOT}/obj${prefix}.$rbase.x.$arch$sfx
532 elif [ -r ${OBJ_ROOT}/obj${prefix}.$os$sfx ]; then
533 abs_obj_dir=${OBJ_ROOT}/obj${prefix}.$os$sfx
534 elif [ -r ${OBJ_ROOT}/obj${prefix}.$arch$sfx ]; then
535 abs_obj_dir=${OBJ_ROOT}/obj${prefix}.$arch$sfx
536 elif [ -r ${OBJ_ROOT}/obj${prefix}.$rel$sfx ]; then
537 abs_obj_dir=${OBJ_ROOT}/obj${prefix}.$rel$sfx
538 elif [ -r ${OBJ_ROOT}/obj${prefix}.$sfx ]; then
539 abs_obj_dir=${OBJ_ROOT}/obj${prefix}.$sfx
542 if [ -n "$abs_obj_dir" ]
543 then
544 obj=${abs_obj_dir}/${src_dir}
547 # Print the directory which would be used for the build and exit
548 if [ -n "$Mflag" ]
549 then
550 if [ ! -n "$obj" ]
551 then
552 obj=${OBJ_ROOT}/obj.$os.$rel.$arch$sfx/${src_dir}
554 echo "$obj"
555 exit $EX_OK
558 # Check if trying to use -f with an existing obj directory
559 if [ -n "$siteconfig" -a -n "$obj" -a -d "$obj" -a -z "$cflag" ]
560 then
561 echo "Can not use Build's -f flag with an existing object tree."
562 echo "If you wish to change configuration information, use the -c flag to clear"
563 echo "the existing $obj tree."
564 exit $EX_USAGE
567 # Check if trying to use -Q with an existing obj directory
568 if [ -n "$pfx" -a -n "$obj" -a -d "$obj" -a -z "$cflag" ]
569 then
570 echo "Can not use Build's -Q flag with an existing object tree."
571 echo "If you wish to change configuration information, use the -c flag to clear"
572 echo "the existing $obj tree."
573 exit $EX_USAGE
577 # Clean out the directory before building.
578 if [ "$cflag" ]
579 then
580 if [ -n "$obj" ]
581 then
582 echo "Clearing out existing $obj tree"
583 rm -rf $obj
587 # If we didn't detect an existing obj directory, makeup a new obj name.
588 if [ -z "$obj" ]
589 then
590 abs_obj_dir=${OBJ_ROOT}/obj${prefix}.$os.$rel.$arch$sfx
591 obj=${abs_obj_dir}/${src_dir}
594 # Check if obj directory exists
595 if [ ! -r "$obj" ]
596 then
597 if [ -r $BUILDTOOLS/OS/$os.$rel.$arch$sfx ]; then
598 oscf=$os.$rel.$arch$sfx
599 elif [ -r $BUILDTOOLS/OS/$os.$rel.$arch ]; then
600 oscf=$os.$rel.$arch
601 elif [ -r $BUILDTOOLS/OS/$os.$rroot.$arch$sfx ]; then
602 oscf=$os.$rroot.$arch$sfx
603 elif [ -r $BUILDTOOLS/OS/$os.$rroot.$arch ]; then
604 oscf=$os.$rroot.$arch
605 elif [ -r $BUILDTOOLS/OS/$os.$rbase.x.$arch$sfx ]; then
606 oscf=$os.$rbase.x.$arch$sfx
607 elif [ -r $BUILDTOOLS/OS/$os.$rbase.x.$arch ]; then
608 oscf=$os.$rbase.x.$arch
609 elif [ -r $BUILDTOOLS/OS/$os.$rel$sfx ]; then
610 oscf=$os.$rel$sfx
611 elif [ -r $BUILDTOOLS/OS/$os.$rel ]; then
612 oscf=$os.$rel
613 elif [ -r $BUILDTOOLS/OS/$os.$rroot$sfx ]; then
614 oscf=$os.$rroot$sfx
615 elif [ -r $BUILDTOOLS/OS/$os.$rroot ]; then
616 oscf=$os.$rroot
617 elif [ -r $BUILDTOOLS/OS/$os.$rbase.x$sfx ]; then
618 oscf=$os.$rbase.x$sfx
619 elif [ -r $BUILDTOOLS/OS/$os.$rbase.x ]; then
620 oscf=$os.$rbase.x
621 elif [ -r $BUILDTOOLS/OS/$os.$arch$sfx ]; then
622 oscf=$os.$arch$sfx
623 elif [ -r $BUILDTOOLS/OS/$os.$arch ]; then
624 oscf=$os.$arch
625 elif [ -r $BUILDTOOLS/OS/$rel.$arch$sfx ]; then
626 oscf=$rel.$arch$sfx
627 elif [ -r $BUILDTOOLS/OS/$rel.$arch ]; then
628 oscf=$rel.$arch
629 elif [ -r $BUILDTOOLS/OS/$rroot.$arch$sfx ]; then
630 oscf=$rroot.$arch$sfx
631 elif [ -r $BUILDTOOLS/OS/$rroot.$arch ]; then
632 oscf=$rroot.$arch
633 elif [ -r $BUILDTOOLS/OS/$rbase.x.$arch$sfx ]; then
634 oscf=$rbase.x.$arch$sfx
635 elif [ -r $BUILDTOOLS/OS/$rbase.x.$arch ]; then
636 oscf=$rbase.x.$arch
637 elif [ -r $BUILDTOOLS/OS/$os$sfx ]; then
638 oscf=$os$sfx
639 elif [ -r $BUILDTOOLS/OS/$os ]; then
640 oscf=$os
641 elif [ -r $BUILDTOOLS/OS/$arch$sfx ]; then
642 oscf=$arch$sfx
643 elif [ -r $BUILDTOOLS/OS/$arch ]; then
644 oscf=$arch
645 elif [ -r $BUILDTOOLS/OS/$rel$sfx ]; then
646 oscf=$rel$sfx
647 elif [ -r $BUILDTOOLS/OS/$rel ]; then
648 oscf=$rel
649 elif [ -r $BUILDTOOLS/OS/$rel$sfx ]; then
650 oscf=$rel$sfx
651 else
652 echo "Cannot determine how to support $os.$rel.$arch" >&2
653 exit $EX_UNAVAILABLE
655 M4=`$SHELL $BUILDTOOLS/bin/find_m4.sh`
656 ret=$?
657 if [ $ret -ne 0 ]
658 then
659 exit $ret
661 echo "Using M4=$M4"
662 export M4
663 if [ "$mflag" ]
664 then
665 echo "Will run in virgin $obj using $BUILDTOOLS/OS/$oscf"
666 exit $EX_OK
669 echo "Creating $obj using $BUILDTOOLS/OS/$oscf"
670 ${mkdir} $obj
672 ln="ln -s"
673 (cd $obj
674 # This glob doesn't actually glob to something everywhere,
675 # thus the protective measures.
676 for i in ${obj_rel_base_dir}/${src_dir}/*.[chly13458]
678 if [ -f $i ]
679 then
680 $ln $i .
682 done
683 # This glob doesn't actually glob to something everywhere,
684 # thus the protective measures.
685 for i in ${obj_rel_base_dir}/${src_dir}/*.0
687 if [ -f $i ]
688 then
689 $ln $i `basename $i`.dist
691 done)
692 if [ -f helpfile ]
693 then
694 (cd $obj; $ln ${obj_rel_base_dir}/${src_dir}/helpfile .)
697 rm -f $obj/.settings$$
698 echo 'divert(-1)' > $obj/.settings$$
699 cat $BUILDTOOLS/M4/header.m4 >> $obj/.settings$$
700 echo "define(\`bldOS', \`\`$os'')" >> $obj/.settings$$
701 echo "define(\`bldREL', \`\`$rel'')" >> $obj/.settings$$
702 echo "define(\`bldARCH', \`\`$arch'')" >> $obj/.settings$$
703 cat $BUILDTOOLS/OS/$oscf >> $obj/.settings$$
705 cur_dir=`pwd`
706 cd $obj/..
707 absolute_obj_dir=`pwd`
710 cd $cur_dir
711 echo "ifdef(\`bldABS_OBJ_DIR',,\`define(\`bldABS_OBJ_DIR', \`$absolute_obj_dir')')" >> $obj/.settings$$
712 rel_src_dir="$obj_rel_base_dir/$src_dir"
713 echo "define(\`bldSRC_NAME', \`$src_dir')" >> $obj/.settings$$
714 echo "define(\`bldREL_SRC_DIR', \`$rel_src_dir')" >> $obj/.settings$$
716 if [ ! -z "$pfx" ]
717 then
718 # They gave us a specific prefix, let's try it out.
719 if [ -f $BUILDTOOLS/Site/$pfx.$oscf$sfx.m4 ]
720 then
721 siteconfig=$BUILDTOOLS/Site/$pfx.$oscf$sfx.m4
722 elif [ -f $BUILDTOOLS/Site/$pfx.$oscf.m4 ]
723 then
724 siteconfig=$BUILDTOOLS/Site/$pfx.$oscf.m4
726 if [ -f $BUILDTOOLS/Site/$pfx.config.m4 ]
727 then
728 siteconfig="$BUILDTOOLS/Site/$pfx.config.m4 $siteconfig"
730 elif [ -z "$siteconfig" ]
731 then
732 # none specified, use defaults
733 if [ -f $BUILDTOOLS/Site/site.$oscf$sfx.m4 ]
734 then
735 siteconfig=$BUILDTOOLS/Site/site.$oscf$sfx.m4
736 elif [ -f $BUILDTOOLS/Site/site.$oscf.m4 ]
737 then
738 siteconfig=$BUILDTOOLS/Site/site.$oscf.m4
740 if [ -f $BUILDTOOLS/Site/site.config.m4 ]
741 then
742 siteconfig="$BUILDTOOLS/Site/site.config.m4 $siteconfig"
744 if [ -f $BUILDTOOLS/Site/site.post.m4 ]
745 then
746 siteconfig="$siteconfig $BUILDTOOLS/Site/site.post.m4"
749 if [ ! -z "$siteconfig" ]
750 then
751 echo "Including $siteconfig"
752 cat $siteconfig >> $obj/.settings$$
754 if [ "$libdirs" ]
755 then
756 echo "define(\`confLIBDIRS', confLIBDIRS \`\`$libdirs'')" >> $obj/.settings$$
758 if [ "$incdirs" ]
759 then
760 echo "define(\`confINCDIRS', \`\`$incdirs'' confINCDIRS)" >> $obj/.settings$$
762 echo "define(\`_SRC_PATH_', \`\`$obj_rel_base_dir'')" >> $obj/.settings$$
763 echo "define(\`bldSRC_PATH', \`\`$obj_rel_base_dir'')" >> $obj/.settings$$
764 echo 'divert(0)dnl' >> $obj/.settings$$
765 libdirs=`(cat $obj/.settings$$; echo "_SRIDBIL_= confLIBDIRS" ) | \
766 sed -e 's/\(.\)include/\1_include_/g' -e 's/#define/#_define_/g' | \
767 ${M4} ${M4_BLDVARIANT_FLAGS} -DconfBUILDTOOLSDIR=$BUILDTOOLS - | \
768 grep "^_SRIDBIL_=" | \
769 sed -e 's/#_define_/#define/g' -e 's/_include_/include/g' -e "s/^_SRIDBIL_=//"`
770 libsrch=`(cat $obj/.settings$$; echo "_HCRSBIL_= confLIBSEARCH" ) | \
771 sed -e 's/\(.\)include/\1_include_/g' -e 's/#define/#_define_/g' | \
772 ${M4} ${M4_BLDVARIANT_FLAGS} -DconfBUILDTOOLSDIR=$BUILDTOOLS - | \
773 grep "^_HCRSBIL_=" | \
774 sed -e 's/#_define_/#define/g' -e 's/_include_/include/g' -e "s/^_HCRSBIL_=//"`
775 libpath=`(cat $obj/.settings$$; echo "_HCRSBIL_= confLIBSEARCHPATH" ) | \
776 sed -e 's/\(.\)include/\1_include_/g' -e 's/#define/#_define_/g' | \
777 ${M4} ${M4_BLDVARIANT_FLAGS} -DconfBUILDTOOLSDIR=$BUILDTOOLS - | \
778 grep "^_HCRSBIL_=" | \
779 sed -e 's/#_define_/#define/g' -e 's/_include_/include/g' -e "s/^_HCRSBIL_=//"`
780 echo 'divert(-1)' >> $obj/.settings$$
781 LIBDIRS="$libdirs" LIBSRCH="$libsrch" LIBPATH="$libpath" SITECONFIG="$siteconfig" $SHELL $BUILDTOOLS/bin/configure.sh $sflag $oscf >> $obj/.settings$$
782 echo 'divert(0)dnl' >> $obj/.settings$$
783 sed -e 's/\(.\)include/\1_include_/g' -e 's/#define/#_define_/g' -e 's/ //g' $obj/.settings$$ | \
784 ${M4} ${M4_BLDVARIANT_FLAGS} -DconfBUILDTOOLSDIR=$BUILDTOOLS - Makefile.m4 | \
785 sed -e 's/#_define_/#define/g' -e 's/_include_/include/g' -e 's/ //g' > $obj/Makefile
786 # That ^M up there was added by quoting it in emacs.
787 # Make has problems if lines end in ^M^M, but not in ^M apparently
788 if [ $? -ne 0 -o ! -s $obj/Makefile ]
789 then
790 echo "ERROR: ${M4} failed; You may need a newer version of M4, at least as new as System V or GNU" 1>&2
791 rm -rf $obj
792 exit $EX_UNAVAILABLE
794 rm -f $obj/.settings$$
795 echo "Making dependencies in $obj"
796 (cd $obj; ${MAKE-make} depend)
799 if [ "$mflag" ]
800 then
801 makefile=`ls -l $obj/Makefile | sed 's/.* //'`
802 if [ -z "$makefile" ]
803 then
804 echo "ERROR: $obj exists but has no Makefile" >&2
805 exit $EX_NOINPUT
807 echo "Will run in existing $obj using $makefile"
808 exit $EX_OK
811 echo "Making in $obj"
812 cd $obj
813 eval exec ${MAKE-make} SENDMAIL_BUILD_FLAGS=\"$SENDMAIL_BUILD_FLAGS\" $makeargs