# Copyright (c) 1998-2002, 2008 Proofpoint, Inc. and its suppliers.
# All rights reserved.
# Copyright (c) 1993, 1996-1997 Eric P. Allman. All rights reserved.
# Copyright (c) 1993
# The Regents of the University of California. All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
#
# $Id: Build,v 8.189 2013-12-02 22:11:07 gshapiro Exp $
#
#
# A quick-and-dirty script to compile sendmail and related programs
# in the presence of multiple architectures. To use, just use
# "sh Build".
#
cflag=""
mflag=""
Mflag=""
Aflag=""
sflag=""
makeargs=""
libdirs=""
incdirs=""
libsrch=""
libpath=""
siteconfig=""
pfx=""
obj=""
oscf=""
arch=""
os=""
rel=""
mkdir="mkdir -p"
EX_OK=0
EX_USAGE=64
EX_NOINPUT=66
# default to a optimized build to behave like the old system.
build_variant="optimized"
full_src_dir=`pwd`
if [ -z "$src_dir" ]
then
src_dir=`basename ${full_src_dir}`
fi
obj_rel_base_dir='../..'
while [ ! -z "$1" ]
do
case $1
-src) # Specify pathname of source directory relative to
# root of cvs tree. This relative pathname may have
# be used to form the pathname of the object directory.
shift
arg=$1
if [ -z "$arg" ]
then
echo "Missing arg for -src" >&2
exit $EX_USAGE
fi
case $arg
/*) echo "Arg for -src must not begin with / ($arg)" >&2
exit $EX_USAGE
;;
esac
shift
;;
-c) # clean out existing $obj tree
cflag=1
shift
;;
-m) # show Makefile name only
mflag=1
shift
;;
-M) # show the name of the obj. directory
Mflag=1
shift
;;
-A) # show the name of the architecture
Aflag=1
shift
;;
-E*) # environment variables to pass into Build
if [ -z "$arg" ]
then
shift # move to argument
arg=$1
fi
if [ -z "$arg" ]
then
echo "Empty -E flag" >&2
exit $EX_USAGE
else
case $arg
*=*) # check format
eval $arg
;;
*) # bad format
echo "Bad format for -E argument ($arg)" >&2
exit $EX_USAGE
;;
esac
shift
fi
;;
-L*) # set up LIBDIRS
shift
;;
-I*) # set up INCDIRS
shift
;;
-f*) # select site config file
if [ -z "$arg" ]
then
shift # move to argument
arg=$1
fi
if [ "$pfx" ]
then
echo "May not use -f and -Q together"
exit $EX_USAGE
fi
if [ "$siteconfig" ]
then
echo "Only one -f flag allowed" >&2
exit $EX_USAGE
else
if [ -z "$siteconfig" ]
then
echo "Missing argument for -f flag" >&2
exit $EX_USAGE
elif [ ! -f "$siteconfig" ]
then
echo "${siteconfig}: File not found"
exit $EX_NOINPUT
else
shift # move past argument
case $arg
/*)
;;
*)
SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS -f \"${full_src_dir}/$siteconfig\""
;;
esac
fi
fi
;;
-O*) # Set object directory manually.
if [ -z "$arg" ]
then
shift # move to argument
arg="$1"
fi
case $arg
/*)
;;
*)
echo "Absolute directory path required for -O flag" >&2
exit $EX_USAGE
;;
esac
shift
;;
-S) # skip auto-configure
sflag="-s"
shift
;;
-Q*) # Select a prefix for the Site/*.config.m4 file
if [ -z "$arg" ]
then
shift # move to argument
arg=$1
fi
if [ -z "$arg" ]
then
echo "Empty -Q flag" >&2
exit $EX_USAGE
elif [ "$siteconfig" ]
then
echo "May not use -Q and -f together" >&2
exit $EX_USAGE
elif [ "$pfx" ]
then
echo "Only one -Q allowed" >&2
exit $EX_USAGE
else
fi
shift
;;
-v) # Select a build variant: debug, optimized, purify, whatever.
shift
if [ -z "$build_variant" ]
then
echo "Usage error with \"-v\" <build_variant>" >&2
echo "You must specify exactly one build variant of debug|optimized|purify" >&2
exit $EX_USAGE
fi
shift
;;
*) # pass argument to make
#SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS \"$1\""
shift
;;
esac
done
# process selected build variant.
case $build_variant in
M4_BLDVARIANT_FLAGS="-DconfBLDVARIANT=DEBUG"
;;
M4_BLDVARIANT_FLAGS="-DconfBLDVARIANT=OPTIMIZED"
;;
M4_BLDVARIANT_FLAGS="-DconfBLDVARIANT=PURIFY"
echo "Sorry, the purify build variant has not been plumbed yet. (Bummer.)" >&2
exit $EX_USAGE
;;
*)
exit $EX_USAGE
;;
esac
#
# Do heuristic guesses !ONLY! for machines that do not have uname
#
then
# probably a NeXT box
then
# probably a Sony NEWS 4.x
then
# probably a Omron LUNA
then
then
then
fi
then
fi
then
fi
#
# Tweak the values we have already got. PLEASE LIMIT THESE to
# tweaks that are absolutely necessary because your system uname
# routine doesn't return something sufficiently unique. Don't do
# it just because you don't like the name that is returned. You
# can combine the architecture name with the os name to create a
# unique Makefile name.
#
# tweak machine architecture
case $arch
esac
# tweak operating system type and release
then
# old versions of SCO UNIX set uname -s the same as uname -n
fi
if [ "$rel" = 4.0 ]
then
3[34]??|3[34]??,*|3[34]??[A-Z]|4[48]??|56??)
then
then
fi
;;
esac
fi
case $os
then
if [ $? = 0 -a -n "$osl" ]
then
else
# command failed; fall back to old method
osl=""
fi
fi
# check whether it worked
if [ -z "$osl" ]
then
fi
;;
if [ "$rel" = "5v6.0.0" ]
then
else
fi;;
then
os="UXPDS"
fi;;
esac
;;
esac
# get "base part" of operating system release
then
fi
# heuristic tweaks to clean up names -- PLEASE LIMIT THESE!
if [ "$os" = "unix" ]
then
# might be Altos System V
case $rel
esac
then
then
fi
then
# NEC machine -- what is it running?
if [ "$os" = "UNIX_System_V" ]
then
elif [ "$os" = "UNIX_SV" ]
then
fi
elif [ "$arch" = "mips" ]
then
case $rel
4_*)
if [ `uname -v` = "UMIPS" ]
then
fi;;
esac
fi
# see if there is a "user suffix" specified
if [ "${SENDMAIL_SUFFIX-}x" = "x" ]
then
sfx=""
else
sfx=".${SENDMAIL_SUFFIX}"
fi
then
echo "Configuration: pfx=$pfx, os=$os, rel=$rel, rbase=$rbase, rroot=$rroot, arch=$arch, sfx=$sfx, variant=$build_variant"
fi
export SMROOT BUILDTOOLS
# see if we are in a Build-able directory
echo "Makefile.m4 not found. Build can only be run from a source directory."
exit $EX_UNAVAILABLE
fi
if [ -z "$OBJ_ROOT" ]; then
fi
if [ "${pfx}x" = "x" ]
then
prefix=""
else
fi
# Print out the architecture (to build up an obj dir path) and exit
if [ -n "$Aflag" ]
then
exit $EX_OK
fi
# now try to find a reasonable object directory
fi
if [ -n "$abs_obj_dir" ]
then
fi
# Print the directory which would be used for the build and exit
if [ -n "$Mflag" ]
then
if [ ! -n "$obj" ]
then
fi
echo "$obj"
exit $EX_OK
fi
# Check if trying to use -f with an existing obj directory
then
echo "Can not use Build's -f flag with an existing object tree."
echo "If you wish to change configuration information, use the -c flag to clear"
echo "the existing $obj tree."
exit $EX_USAGE
fi
# Check if trying to use -Q with an existing obj directory
then
echo "Can not use Build's -Q flag with an existing object tree."
echo "If you wish to change configuration information, use the -c flag to clear"
echo "the existing $obj tree."
exit $EX_USAGE
fi
# Clean out the directory before building.
if [ "$cflag" ]
then
if [ -n "$obj" ]
then
echo "Clearing out existing $obj tree"
fi
fi
# If we didn't detect an existing obj directory, makeup a new obj name.
if [ -z "$obj" ]
then
fi
# Check if obj directory exists
if [ ! -r "$obj" ]
then
else
exit $EX_UNAVAILABLE
fi
ret=$?
then
exit $ret
fi
echo "Using M4=$M4"
export M4
if [ "$mflag" ]
then
echo "Will run in virgin $obj using $BUILDTOOLS/OS/$oscf"
exit $EX_OK
fi
echo "Creating $obj using $BUILDTOOLS/OS/$oscf"
ln="ln -s"
(cd $obj
# This glob doesn't actually glob to something everywhere,
# thus the protective measures.
for i in ${obj_rel_base_dir}/${src_dir}/*.[chly13458]
do
if [ -f $i ]
then
$ln $i .
fi
done
# This glob doesn't actually glob to something everywhere,
# thus the protective measures.
for i in ${obj_rel_base_dir}/${src_dir}/*.0
do
if [ -f $i ]
then
fi
done)
if [ -f helpfile ]
then
(cd $obj; $ln ${obj_rel_base_dir}/${src_dir}/helpfile .)
fi
cur_dir=`pwd`
cd $obj/..
absolute_obj_dir=`pwd`
cd $cur_dir
echo "ifdef(\`bldABS_OBJ_DIR',,\`define(\`bldABS_OBJ_DIR', \`$absolute_obj_dir')')" >> $obj/.settings$$
if [ ! -z "$pfx" ]
then
# They gave us a specific prefix, let's try it out.
then
then
fi
then
fi
elif [ -z "$siteconfig" ]
then
# none specified, use defaults
then
then
fi
then
fi
then
fi
fi
if [ ! -z "$siteconfig" ]
then
echo "Including $siteconfig"
fi
if [ "$libdirs" ]
then
fi
if [ "$incdirs" ]
then
fi
${M4} ${M4_BLDVARIANT_FLAGS} -DconfBUILDTOOLSDIR=$BUILDTOOLS - | \
${M4} ${M4_BLDVARIANT_FLAGS} -DconfBUILDTOOLSDIR=$BUILDTOOLS - | \
${M4} ${M4_BLDVARIANT_FLAGS} -DconfBUILDTOOLSDIR=$BUILDTOOLS - | \
${M4} ${M4_BLDVARIANT_FLAGS} -DconfBUILDTOOLSDIR=$BUILDTOOLS - | \
LIBDIRS="$libdirs" LIBSRCH="$libsrch" LIBPATH="$libpath" SITECONFIG="$siteconfig" SOEXT="$soext" $SHELL $BUILDTOOLS/bin/configure.sh $sflag $oscf >> $obj/.settings$$
# That ^M up there was added by quoting it in emacs.
# Make has problems if lines end in ^M^M, but not in ^M apparently
then
echo "ERROR: ${M4} failed; You may need a newer version of M4, at least as new as System V or GNU" 1>&2
exit $EX_UNAVAILABLE
fi
echo "Making dependencies in $obj"
fi
if [ "$mflag" ]
then
if [ -z "$makefile" ]
then
echo "ERROR: $obj exists but has no Makefile" >&2
exit $EX_NOINPUT
fi
exit $EX_OK
fi
echo "Making in $obj"
cd $obj