build
来自「< linux网络编程工具>>配套源码」· 代码 · 共 794 行 · 第 1/2 页
TXT
794 行
# heuristic tweaks to clean up names -- PLEASE LIMIT THESE!
if [ "$os" = "unix" ]
then
# might be Altos System V
case $rel
in
5.3*) os=Altos;;
esac
elif [ -r /unix -a -r /usr/lib/libseq.a -a -r /lib/cpp ]
then
# might be a DYNIX/ptx 2.x system, which has a broken uname
if strings /lib/cpp | grep _SEQUENT_ > /dev/null
then
os=PTX
fi
elif [ -d /usr/nec ]
then
# NEC machine -- what is it running?
if [ "$os" = "UNIX_System_V" ]
then
os=EWS-UX_V
elif [ "$os" = "UNIX_SV" ]
then
os=UX4800
fi
elif [ "$arch" = "mips" ]
then
case $rel
in
4_*)
if [ `uname -v` = "UMIPS" ]
then
os=RISCos
fi;;
esac
fi
# see if there is a "user suffix" specified
if [ "${SENDMAIL_SUFFIX-}x" = "x" ]
then
sfx=""
else
sfx=".${SENDMAIL_SUFFIX}"
fi
if [ ! -n "$Mflag" -a ! -n "$Aflag" ]
then
echo "Configuration: pfx=$pfx, os=$os, rel=$rel, rbase=$rbase, rroot=$rroot, arch=$arch, sfx=$sfx, variant=$build_variant"
fi
SMROOT=${SMROOT-..}
BUILDTOOLS=${BUILDTOOLS-$SMROOT/devtools}
export SMROOT BUILDTOOLS
# see if we are in a Build-able directory
if [ ! -f Makefile.m4 -a ! -n "$Aflag" ]; then
echo "Makefile.m4 not found. Build can only be run from a source directory."
exit $EX_UNAVAILABLE
fi
incdirs="$incdirs -I\${SRCDIR}/include"
if [ -z "$OBJ_ROOT" ]; then
OBJ_ROOT=${SMROOT}
fi
if [ "${pfx}x" = "x" ]
then
prefix=""
else
prefix=".$pfx"
fi
# Print out the architecture (to build up an obj dir path) and exit
if [ -n "$Aflag" ]
then
echo "$os.$rel.$arch$sfx"
exit $EX_OK
fi
# now try to find a reasonable object directory
if [ -r ${OBJ_ROOT}/obj${prefix}.$os.$rel.$arch$sfx ]; then
obj=${OBJ_ROOT}/obj${prefix}.$os.$rel.$arch$sfx
elif [ -r ${OBJ_ROOT}/obj${prefix}.$os.$rroot.$arch$sfx ]; then
obj=${OBJ_ROOT}/obj${prefix}.$os.$rroot.$arch$sfx
elif [ -r ${OBJ_ROOT}/obj${prefix}.$os.$rbase.x.$arch$sfx ]; then
obj=${OBJ_ROOT}/obj${prefix}.$os.$rbase.x.$arch$sfx
elif [ -r ${OBJ_ROOT}/obj${prefix}.$os.$rel$sfx ]; then
obj=${OBJ_ROOT}/obj${prefix}.$os.$rel$sfx
elif [ -r ${OBJ_ROOT}/obj${prefix}.$os.$rbase.x$sfx ]; then
obj=${OBJ_ROOT}/obj${prefix}.$os.$rbase.x$sfx
elif [ -r ${OBJ_ROOT}/obj${prefix}.$os.$arch$sfx ]; then
obj=${OBJ_ROOT}/obj${prefix}.$os.$arch$sfx
elif [ -r ${OBJ_ROOT}/obj${prefix}.$rel.$arch$sfx ]; then
obj=${OBJ_ROOT}/obj${prefix}.$rel.$arch$sfx
elif [ -r ${OBJ_ROOT}/obj${prefix}.$rbase.x.$arch$sfx ]; then
obj=${OBJ_ROOT}/obj${prefix}.$rbase.x.$arch$sfx
elif [ -r ${OBJ_ROOT}/obj${prefix}.$os$sfx ]; then
obj=${OBJ_ROOT}/obj${prefix}.$os$sfx
elif [ -r ${OBJ_ROOT}/obj${prefix}.$arch$sfx ]; then
obj=${OBJ_ROOT}/obj${prefix}.$arch$sfx
elif [ -r ${OBJ_ROOT}/obj${prefix}.$rel$sfx ]; then
obj=${OBJ_ROOT}/obj${prefix}.$rel$sfx
elif [ -r ${OBJ_ROOT}/obj${prefix}.$sfx ]; then
obj=${OBJ_ROOT}/obj${prefix}.$sfx
fi
if [ -n "$obj" ]
then
obj=${obj}/${src_dir}
fi
# Print the directory which would be used for the build and exit
if [ -n "$Mflag" ]
then
if [ ! -n "$obj" ]
then
obj=${OBJ_ROOT}/obj.$os.$rel.$arch$sfx/${src_dir}
fi
echo "$obj"
exit $EX_OK
fi
# Check if trying to use -f with an existing obj directory
if [ -n "$siteconfig" -a -n "$obj" -a -d "$obj" -a -z "$cflag" ]
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
if [ -n "$pfx" -a -n "$obj" -a -d "$obj" -a -z "$cflag" ]
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"
rm -rf $obj
fi
fi
# If we didn't detect an existing obj directory, makeup a new obj name.
if [ -z "$obj" ]
then
obj=${OBJ_ROOT}/obj${prefix}.$os.$rel.$arch$sfx/${src_dir}
fi
# Check if obj directory exists
if [ ! -r "$obj" ]
then
if [ -r $BUILDTOOLS/OS/$os.$rel.$arch$sfx ]; then
oscf=$os.$rel.$arch$sfx
elif [ -r $BUILDTOOLS/OS/$os.$rel.$arch ]; then
oscf=$os.$rel.$arch
elif [ -r $BUILDTOOLS/OS/$os.$rroot.$arch$sfx ]; then
oscf=$os.$rroot.$arch$sfx
elif [ -r $BUILDTOOLS/OS/$os.$rroot.$arch ]; then
oscf=$os.$rroot.$arch
elif [ -r $BUILDTOOLS/OS/$os.$rbase.x.$arch$sfx ]; then
oscf=$os.$rbase.x.$arch$sfx
elif [ -r $BUILDTOOLS/OS/$os.$rbase.x.$arch ]; then
oscf=$os.$rbase.x.$arch
elif [ -r $BUILDTOOLS/OS/$os.$rel$sfx ]; then
oscf=$os.$rel$sfx
elif [ -r $BUILDTOOLS/OS/$os.$rel ]; then
oscf=$os.$rel
elif [ -r $BUILDTOOLS/OS/$os.$rroot$sfx ]; then
oscf=$os.$rroot$sfx
elif [ -r $BUILDTOOLS/OS/$os.$rroot ]; then
oscf=$os.$rroot
elif [ -r $BUILDTOOLS/OS/$os.$rbase.x$sfx ]; then
oscf=$os.$rbase.x$sfx
elif [ -r $BUILDTOOLS/OS/$os.$rbase.x ]; then
oscf=$os.$rbase.x
elif [ -r $BUILDTOOLS/OS/$os.$arch$sfx ]; then
oscf=$os.$arch$sfx
elif [ -r $BUILDTOOLS/OS/$os.$arch ]; then
oscf=$os.$arch
elif [ -r $BUILDTOOLS/OS/$rel.$arch$sfx ]; then
oscf=$rel.$arch$sfx
elif [ -r $BUILDTOOLS/OS/$rel.$arch ]; then
oscf=$rel.$arch
elif [ -r $BUILDTOOLS/OS/$rroot.$arch$sfx ]; then
oscf=$rroot.$arch$sfx
elif [ -r $BUILDTOOLS/OS/$rroot.$arch ]; then
oscf=$rroot.$arch
elif [ -r $BUILDTOOLS/OS/$rbase.x.$arch$sfx ]; then
oscf=$rbase.x.$arch$sfx
elif [ -r $BUILDTOOLS/OS/$rbase.x.$arch ]; then
oscf=$rbase.x.$arch
elif [ -r $BUILDTOOLS/OS/$os$sfx ]; then
oscf=$os$sfx
elif [ -r $BUILDTOOLS/OS/$os ]; then
oscf=$os
elif [ -r $BUILDTOOLS/OS/$arch$sfx ]; then
oscf=$arch$sfx
elif [ -r $BUILDTOOLS/OS/$arch ]; then
oscf=$arch
elif [ -r $BUILDTOOLS/OS/$rel$sfx ]; then
oscf=$rel$sfx
elif [ -r $BUILDTOOLS/OS/$rel ]; then
oscf=$rel
elif [ -r $BUILDTOOLS/OS/$rel$sfx ]; then
oscf=$rel$sfx
else
echo "Cannot determine how to support $arch.$os.$rel" >&2
exit $EX_UNAVAILABLE
fi
M4=`sh $BUILDTOOLS/bin/find_m4.sh`
ret=$?
if [ $ret -ne 0 ]
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"
${mkdir} $obj
# If this is WINNT then compile with relative paths
# (based on REL_SRC_DIR), so we don't need to do any "linking"
if [ ! $os = "WINNT.4.0" -a ! $os = "WINNT.5.0" -a ! $os = "WINNT" ]
then
ln="ln -s"
(cd $obj; $ln ${obj_rel_base_dir}/${src_dir}/*.[ch13458] .)
(cd $obj
# 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
$ln $i `basename $i`.dist
fi
done)
if [ -f helpfile ]
then
(cd $obj; $ln ${obj_rel_base_dir}/${src_dir}/helpfile .)
fi
fi
rm -f $obj/.settings$$
echo 'divert(-1)' > $obj/.settings$$
cat $BUILDTOOLS/M4/header.m4 >> $obj/.settings$$
echo "define(\`OS', \`\`$os'')" >> $obj/.settings$$
echo "define(\`REL', \`\`$rel'')" >> $obj/.settings$$
echo "define(\`ARCH', \`\`$arch'')" >> $obj/.settings$$
cat $BUILDTOOLS/OS/$oscf >> $obj/.settings$$
if [ $os = "WINNT.4.0" -o $os = "WINNT.5.0" -o $os = "WINNT" ]
then
# Append C: onto pwd's which don't have the preceding //
# so that we can compile on non-network drives.
# (Is there a way to get the real drive letter?)
dir_prefix=`echo $absolute_base_dir | sed 's#\(..\).*#\1#'`
if [ ! $dir_prefix = "//" ]
then
absolute_base_dir="//C$absolute_base_dir"
fi
# Convert sh's //X to X: drive letters to make make (and cl) happy
obj_rel_base_dir=`echo $absolute_base_dir | sed 's#^//\([a-zA-Z]\)#\1:#'`
cur_dir=`pwd`
cd $obj/..
absolute_obj_dir=`pwd | sed 's#/#\\\\\\\\#g'`
cd $cur_dir
echo "ifdef(\`bldABS_OBJ_DIR',,\`define(\`bldABS_OBJ_DIR', \`$absolute_obj_dir')')" >> $obj/.settings$$
rel_src_dir="$obj_rel_base_dir/$src_dir"
echo "define(\`bldREL_SRC_DIR', \`$rel_src_dir')" >> $obj/.settings$$
else
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$$
rel_src_dir="$obj_rel_base_dir/$src_dir"
echo "define(\`bldREL_SRC_DIR', \`$rel_src_dir')" >> $obj/.settings$$
fi
if [ ! -z "$pfx" ]
then
# They gave us a specific prefix, let's try it out.
if [ -f $BUILDTOOLS/Site/$pfx.$oscf$sfx.m4 ]
then
siteconfig=$BUILDTOOLS/Site/$pfx.$oscf$sfx.m4
elif [ -f $BUILDTOOLS/Site/$pfx.$oscf.m4 ]
then
siteconfig=$BUILDTOOLS/Site/$pfx.$oscf.m4
fi
if [ -f $BUILDTOOLS/Site/$pfx.config.m4 ]
then
siteconfig="$BUILDTOOLS/Site/$pfx.config.m4 $siteconfig"
fi
elif [ -z "$siteconfig" ]
then
# none specified, use defaults
if [ -f $BUILDTOOLS/Site/site.$oscf$sfx.m4 ]
then
siteconfig=$BUILDTOOLS/Site/site.$oscf$sfx.m4
elif [ -f $BUILDTOOLS/Site/site.$oscf.m4 ]
then
siteconfig=$BUILDTOOLS/Site/site.$oscf.m4
fi
if [ -f $BUILDTOOLS/Site/site.config.m4 ]
then
siteconfig="$BUILDTOOLS/Site/site.config.m4 $siteconfig"
fi
if [ -f $BUILDTOOLS/Site/site.post.m4 ]
then
siteconfig="$siteconfig $BUILDTOOLS/Site/site.post.m4"
fi
fi
if [ ! -z "$siteconfig" ]
then
echo "Including $siteconfig"
cat $siteconfig >> $obj/.settings$$
fi
if [ "$libdirs" ]
then
echo "define(\`confLIBDIRS', confLIBDIRS \`\`$libdirs'')" >> $obj/.settings$$
fi
if [ "$incdirs" ]
then
echo "define(\`confINCDIRS', \`\`$incdirs'' confINCDIRS)" >> $obj/.settings$$
fi
echo "define(\`_SRC_PATH_', \`\`$obj_rel_base_dir'')" >> $obj/.settings$$
echo 'divert(0)dnl' >> $obj/.settings$$
libdirs=`(cat $obj/.settings$$; echo "_SRIDBIL_= confLIBDIRS" ) | \
sed -e 's/\(.\)include/\1_include_/g' -e 's/#define/#_define_/g' | \
${M4} ${M4_BLDVARIANT_FLAGS} -DconfBUILDTOOLSDIR=$BUILDTOOLS - | \
grep "^_SRIDBIL_=" | \
sed -e 's/#_define_/#define/g' -e 's/_include_/include/g' -e "s/^_SRIDBIL_=//"`
libsrch=`(cat $obj/.settings$$; echo "_HCRSBIL_= confLIBSEARCH" ) | \
sed -e 's/\(.\)include/\1_include_/g' -e 's/#define/#_define_/g' | \
${M4} ${M4_BLDVARIANT_FLAGS} -DconfBUILDTOOLSDIR=$BUILDTOOLS - | \
grep "^_HCRSBIL_=" | \
sed -e 's/#_define_/#define/g' -e 's/_include_/include/g' -e "s/^_HCRSBIL_=//"`
libpath=`(cat $obj/.settings$$; echo "_HCRSBIL_= confLIBSEARCHPATH" ) | \
sed -e 's/\(.\)include/\1_include_/g' -e 's/#define/#_define_/g' | \
${M4} ${M4_BLDVARIANT_FLAGS} -DconfBUILDTOOLSDIR=$BUILDTOOLS - | \
grep "^_HCRSBIL_=" | \
sed -e 's/#_define_/#define/g' -e 's/_include_/include/g' -e "s/^_HCRSBIL_=//"`
echo 'divert(-1)' >> $obj/.settings$$
LIBDIRS="$libdirs" LIBSRCH="$libsrch" LIBPATH="$libpath" SITECONFIG="$siteconfig" sh $BUILDTOOLS/bin/configure.sh $sflag $oscf >> $obj/.settings$$
echo 'divert(0)dnl' >> $obj/.settings$$
sed -e 's/\(.\)include/\1_include_/g' -e 's/#define/#_define_/g' -e 's/
//g' $obj/.settings$$ | \
${M4} ${M4_BLDVARIANT_FLAGS} -DconfBUILDTOOLSDIR=$BUILDTOOLS - Makefile.m4 | \
sed -e 's/#_define_/#define/g' -e 's/_include_/include/g' -e 's/
//g' > $obj/Makefile
# 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
if [ $? -ne 0 -o ! -s $obj/Makefile ]
then
echo "ERROR: ${M4} failed; You may need a newer version of M4, at least as new as System V or GNU" 1>&2
rm -rf $obj
exit $EX_UNAVAILABLE
fi
rm -f $obj/.settings$$
echo "Making dependencies in $obj"
(cd $obj; ${MAKE-make} depend)
fi
if [ "$mflag" ]
then
makefile=`ls -l $obj/Makefile | sed 's/.* //'`
if [ -z "$makefile" ]
then
echo "ERROR: $obj exists but has no Makefile" >&2
exit $EX_NOINPUT
fi
echo "Will run in existing $obj using $makefile"
exit $EX_OK
fi
echo "Making in $obj"
cd $obj
eval exec ${MAKE-make} SENDMAIL_BUILD_FLAGS=\"$SENDMAIL_BUILD_FLAGS\" $makeargs
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?