build

来自「< linux网络编程工具>>配套源码」· 代码 · 共 794 行 · 第 1/2 页

TXT
794
字号
#!/bin/sh

# Copyright (c) 1998-2000 Sendmail, 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.155.4.3 2000/07/14 05:30:15 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".
#

trap "rm -f $obj/.settings$$; exit" 1 2 3 15

cflag=""
mflag=""
Mflag=""
Aflag=""
sflag=""
makeargs=""
libdirs=""
incdirs=""
libsrch=""
libpath=""
siteconfig=""
pfx=""
obj=""
oscf=""
arch=""
os=""
rel=""
mkdir="mkdir -p"
SENDMAIL_BUILD_FLAGS=""
EX_OK=0
EX_USAGE=64
EX_NOINPUT=66
EX_UNAVAILABLE=69

# 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
absolute_base_dir=`echo ${full_src_dir} | sed "s#${src_dir}\\$##"`
obj_rel_base_dir='../..'

while [ ! -z "$1" ]
do
	case $1
	in
	  -c)	# clean out existing $obj tree
		cflag=1
		SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS $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
		arg=`echo $1 | sed 's/^-E//'`
		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
			in
			  *=*)	# check format
				eval $arg
				export `echo $arg | sed 's;=.*;;'`
				SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS -E \"$arg\""
				;;
			  *)	# bad format
				echo "Bad format for -E argument ($arg)" >&2
				exit $EX_USAGE
				;;
			esac
			shift
		fi
		;;

	  -L*)	# set up LIBDIRS
		libdirs="$libdirs $1"
		SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS $1"
		shift
		;;

	  -I*)	# set up INCDIRS
		incdirs="$incdirs $1"
		SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS $1"
		shift
		;;

	  -f*)	# select site config file
		arg=`echo $1 | sed 's/^-f//'`
		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
			siteconfig=$arg
			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
				in
					/*)
					SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS -f \"$siteconfig\""
					;;
					*)
					SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS -f \"${full_src_dir}/$siteconfig\""
					;;
				esac
			fi
		fi
		;;

	  -O*) # Set object directory manually.
		arg="`echo $1 | sed 's/^-O//'`"
		if [ -z "$arg" ]
		then
		    shift   # move to argument
		    arg="$1"
		fi
		case $arg
		in
			/*)
			OBJ_ROOT="$arg"
			SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS -O \"$OBJ_ROOT\""
			obj_rel_base_dir=$absolute_base_dir
			;;
			*)
			echo "Absolute directory path required for -O flag" >&2
			exit $EX_USAGE
			;;
		esac
		shift
		;;

	  -S)	# skip auto-configure
		sflag="-s"
		SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS $1"
		shift
		;;

	  -Q*)	# Select a prefix for the Site/*.config.m4 file
		arg=`echo $1 | sed 's/^-Q//'`
		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
			pfx=$arg
			SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS -Q \"$pfx\""
		fi
		shift
		;;

  	  -v)	# Select a build variant: debug, optimized, purify, whatever.
		shift
		build_variant=$1
		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
		makeargs="$makeargs \"$1\""
		SENDMAIL_BUILD_FLAGS="$SENDMAIL_BUILD_FLAGS \"$1\""
		shift
		;;
	esac
done

# process selected build variant.
case $build_variant in
    debug)
	M4_BLDVARIANT_FLAGS="-DconfBLDVARIANT=DEBUG"
	;;
    optimized)
	M4_BLDVARIANT_FLAGS="-DconfBLDVARIANT=OPTIMIZED"
	;;
    purify)
	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
#
if [ -d /NextApps -a ! -f /bin/uname -a ! -f /usr/bin/uname ]
then
	# probably a NeXT box
	arch=`hostinfo | sed -n 's/.*Processor type: \([^ ]*\).*/\1/p'`
	os=NeXT
	rel=`hostinfo | sed -n 's/.*NeXT Mach \([0-9\.]*\).*/\1/p'`
elif [ -f /usr/sony/bin/machine -a -f /etc/osversion ]
then
	# probably a Sony NEWS 4.x
	os=NEWS-OS
	rel=`awk '{ print $3}' /etc/osversion`
	arch=`/usr/sony/bin/machine`
elif [ -d /usr/omron -a -f /bin/luna ]
then
	# probably a Omron LUNA
	os=LUNA
	if [ -f /bin/luna1 ] && /bin/luna1
	then
		rel=unios-b
		arch=luna1
	elif [ -f /bin/luna2 ] && /bin/luna2
	then
		rel=Mach
		arch=luna2
	elif [ -f /bin/luna88k ] && /bin/luna88k
	then
		rel=Mach
		arch=luna88k
	fi
elif [ -d /usr/apollo -a -d \`node_data ]
then
	# probably a Apollo/DOMAIN
	os=DomainOS
	arch=$ISP
	rel=`/usr/apollo/bin/bldt | grep Domain | awk '{ print $4 }' | sed -e 's/,//g'`
elif [ `uname` = "CYGWIN_NT-4.0" -o `uname` = "CYGWIN_NT-5.0" ]
then
	# Windows NT 4.0 or Windows 2000
	arch=`uname -m | sed -e 's/ //g' -e 's/\//-/g'`
	os=`uname -s | sed -e 's/CYG//g' -e 's/ //g' -e 's/_//g' -e 's/-/./g'`
	rel=`uname -r | sed -e 's/(/_/g' -e 's/)//g' -e 's/ //g' -e 's/\//-/g'` 
fi

if [ ! "$arch" -a ! "$os" -a ! "$rel" ]
then
	arch=`uname -m | sed -e 's/ //g' -e 's/\//-/g'`
	os=`uname -s | sed -e 's/\//-/g' -e 's/ //g'`
	rel=`uname -r | sed -e 's/(/-/g' -e 's/)//g' -e 's/ //g'`
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
in
  sun4*)	arch=sun4;;

  9000/*)	arch=`echo $arch | sed -e 's/9000.//' -e 's/..$/xx/'`;;

  DS/907000)	arch=ds90;;

  NILE*)	arch=NILE
		os=`uname -v`;;

  CRAYT3E|CRAYTS)
		os=$arch;;

esac

# tweak operating system type and release
node=`uname -n | sed -e 's/\//-/g' -e 's/ //g'`
if [ "$os" = "$node" -a "$arch" = "i386" -a "$rel" = 3.2 -a "`uname -v`" = 2 ]
then
	# old versions of SCO UNIX set uname -s the same as uname -n
	os=SCO_SV
fi
if [ "$rel" = 4.0 ]
then
	case $arch in
	  3[34]??|3[34]??,*|3[34]??[A-Z]|4[48]??|56??)
		if [ -d /usr/sadm/sysadm/add-ons/WIN-TCP ]
		then
			os=NCR.MP-RAS
			rel=2.x
			arch=i486
		elif [ -d /usr/sadm/sysadm/add-ons/inet ]
		then
			os=NCR.MP-RAS
			rel=3.x
			arch=i486
		fi
		;;
	esac
fi

case $os
in
  DYNIX-ptx)	os=PTX;;
  Paragon*)	os=Paragon;;
  HP-UX)	rel=`echo $rel | sed -e 's/^[^.]*\.0*//'`;;
  AIX)		rela=$rel
		rel=`uname -v`
		arch=PPC
		rel=$rel.$rela
		;;
  BSD-386)	os=BSD-OS;;
  SCO_SV)	os=SCO; rel=`uname -X | sed -n 's/Release = 3.2v//p'`;;
  UNIX_System_V) if [ "$arch" = "ds90" ]
		then
			os="UXPDS"
			rel=`uname -v | sed -e 's/\(V.*\)L.*/\1/'`
		fi;;
  ReliantUNIX-?|SINIX-?)	os=SINIX;;
  DomainOS)	case $rel in
		  10.4*)	rel=10.4;;
		esac
		;;
  IRIX*)	rel=`echo $rel | sed -e 's/-.*$//'`;;
  NeXT)		mkdir="mkdirs";;
esac

# get "base part" of operating system release
rroot=`echo $rel | sed -e 's/\.[^.]*$//'`
rbase=`echo $rel | sed -e 's/\..*//'`
if [ "$rroot" = "$rbase" ]
then
	rroot=$rel
fi

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?