Home | History | Annotate | Line # | Download | only in dist
makedefs revision 1.11.4.1
      1 #!/bin/sh
      2 
      3 #++
      4 # NAME
      5 #	makedefs 1
      6 # SUMMARY
      7 #	Postfix makefile configuration utility
      8 # SYNOPSIS
      9 #	\fBmake makefiles \fIname=value...\fR
     10 # DESCRIPTION
     11 #	The \fBmakedefs\fR command identifies the compilation
     12 #	environment, and emits macro definitions on the standard
     13 #	output stream that can be prepended to template Makefiles.
     14 #	These macros implement an internal interface and are subject
     15 #	to change without notice.
     16 #
     17 #	Default settings can be overruled by specifying them as
     18 #	environment variables (or as name=value pairs on the "make"
     19 #	command line). Use quotes if variables contain whitespace
     20 #	or shell meta characters.
     21 #
     22 #	The command "make makefiles name=value..." will replace the
     23 #	string MAIL_VERSION at the end of a parameter value with
     24 #	the Postfix release version. Do not try to specify something
     25 #	like $mail_version on this command line. This produces
     26 #	inconsistent results with different versions of the make(1)
     27 #	command.
     28 # .IP \fBAUXLIBS=\fIobject_library...\fR
     29 #	Specifies one or more non-default object libraries. Postfix
     30 #	2,12 and later specify some of their database library
     31 #	dependencies with AUXLIBS_CDB, AUXLIBS_LDAP, AUXLIBS_LMDB,
     32 #	AUXLIBS_MYSQL, AUXLIBS_PCRE, AUXLIBS_PGSQL, AUXLIBS_SDBM,
     33 #	and AUXLIBS_SQLITE, respectively.
     34 # .IP \fBCC=\fIcompiler_command\fR
     35 #	Specifies a non-default compiler. On many systems, the default
     36 #	is \fBgcc\fR.
     37 # .IP \fBCCARGS=\fIcompiler_arguments\fR
     38 #	Specifies non-default compiler arguments, for example, a non-default
     39 #	\fIinclude\fR directory.
     40 #	The following directives are special:
     41 # .RS
     42 # .IP \fB-DNO_DB\fR
     43 #	Do not build with Berkeley DB support.
     44 # .IP \fB-DNO_DEVPOLL\fR
     45 #	Do not build with Solaris /dev/poll support.
     46 #	By default, /dev/poll support is compiled in on platforms that
     47 #	are known to support it.
     48 # .IP \fB-DNO_DNSSEC\fR
     49 #	Do not build with DNSSEC support, even if the resolver
     50 #	library appears to support it.
     51 # .IP \fB-DNO_EPOLL\fR
     52 #	Do not build with Linux EPOLL support.
     53 #	By default, EPOLL support is compiled in on platforms that
     54 #	are known to support it.
     55 # .IP \fB-DNO_EAI\fR
     56 #	Do not build with EAI (SMTPUTF8) support. By default, EAI
     57 #	support is compiled in when the "icuuc" library and header
     58 #	files are found.
     59 # .IP \fB-DNO_INLINE\fR
     60 #	Do not require support for C99 "inline" functions. Instead,
     61 #	implement argument typechecks for non-printf/scanf-like
     62 #	functions with ternary operators and unreachable code.
     63 # .IP \fB-DNO_IPV6\fR
     64 #	Do not build with IPv6 support.
     65 #	By default, IPv6 support is compiled in on platforms that
     66 #	are known to have IPv6 support.
     67 #
     68 #	Note: this directive is for debugging and testing only. It
     69 #	is not guaranteed to work on all platforms.
     70 # .IP \fB-DNO_KQUEUE\fR
     71 #	Do not build with FreeBSD/NetBSD/OpenBSD/MacOSX KQUEUE support.
     72 #	By default, KQUEUE support is compiled in on platforms that
     73 #	are known to support it.
     74 # .IP \fB-DNO_NIS\fR
     75 #	Do not build with NIS or NISPLUS support. Support for NIS
     76 #	is unavailable on some recent Linux distributions.
     77 # .IP \fB-DNO_NISPLUS\fR
     78 #	Do not build with NISPLUS support. Support for NISPLUS
     79 #	is unavailable on some recent Solaris distributions.
     80 # .IP \fB-DNO_PCRE\fR
     81 #	Do not build with PCRE support.
     82 #	By default, PCRE support is compiled in when the \fBpcre-config\fR
     83 #	utility is installed.
     84 # .IP \fB-DNO_POSIX_GETPW_R\fR
     85 #	Disable support for POSIX getpwnam_r/getpwuid_r.
     86 # .IP \fB-DNO_SIGSETJMP\fR
     87 #	Use setjmp()/longjmp() instead of sigsetjmp()/siglongjmp().
     88 #	By default, Postfix uses sigsetjmp()/siglongjmp() when they
     89 #	appear to work.
     90 # .RE
     91 # .IP \fBDEBUG=\fIdebug_level\fR
     92 #	Specifies a non-default debugging level. The default is \fB-g\fR.
     93 #	Specify \fBDEBUG=\fR to turn off debugging.
     94 # .IP \fBOPT=\fIoptimization_level\fR
     95 #	Specifies a non-default optimization level. The default is \fB-O\fR.
     96 #	Specify \fBOPT=\fR to turn off optimization.
     97 # .IP \fBSHLIB_CFLAGS=\fIflags\fR
     98 #	Override the compiler flags (typically, "-fPIC") for Postfix
     99 #	dynamically-linked libraries and database plugins.
    100 #
    101 #	This feature was introduced with Postfix 3.0.
    102 # .IP \fBSHLIB_RPATH=\fIrpath\fR
    103 #	Override the runpath (typically, "'-Wl,-rpath,${SHLIB_DIR}'")
    104 #	for Postfix dynamically-linked libraries.
    105 #
    106 #	This feature was introduced with Postfix 3.0.
    107 # .IP \fBSHLIB_SUFFIX=\fIsuffix\fR
    108 #	Override the filename suffix (typically, ".so") for Postfix
    109 #	dynamically-linked libraries and database plugins.
    110 #
    111 #	This feature was introduced with Postfix 3.0.
    112 # .IP \fBshared=yes\fR
    113 # .IP \fBshared=no\fR
    114 #	Enable (disable) Postfix builds with dynamically-linked
    115 #	libraries typically named $shlib_directory/libpostfix-*.so.*.
    116 #
    117 #	This feature was introduced with Postfix 3.0.
    118 # .IP \fBdynamicmaps=yes\fR
    119 # .IP \fBdynamicmaps=no\fR
    120 #	Enable (disable) Postfix builds with the configuration file
    121 #	$meta_directory/dynamicmaps.cf and dynamically-loadable
    122 #	database plugins typically named postfix-*.so.*.  The setting
    123 #	"dynamicmaps=yes" implicitly enables Postfix dynamically-linked
    124 #	libraries.
    125 #
    126 #	This feature was introduced with Postfix 3.0.
    127 # .IP \fBpie=yes\fR
    128 # .IP \fBpie=no\fR
    129 #
    130 #	Enable (disable) Postfix builds with position-independent
    131 #	executables, on platforms where this is supported.
    132 #
    133 #	This feature was introduced with Postfix 3.0.
    134 # .IP \fIinstallation_parameter\fB=\fIvalue\fR...
    135 #	Override the compiled-in default value of the specified
    136 #	installation parameter(s). The following parameters are
    137 #	supported in this context:
    138 #
    139 #	command_directory config_directory daemon_directory
    140 #	data_directory default_database_type html_directory
    141 #	mail_spool_directory mailq_path manpage_directory meta_directory
    142 #	newaliases_path queue_directory readme_directory sendmail_path
    143 #	shlib_directory openssl_path
    144 #
    145 #	See the postconf(5) manpage for a description of these
    146 #	parameters.
    147 #
    148 #	This feature was introduced with Postfix 3.0.
    149 # .IP \fBWARN=\fIwarning_flags\fR
    150 #	Specifies non-default gcc compiler warning options for use when
    151 #	"make" is invoked in a source subdirectory only.
    152 # LICENSE
    153 # .ad
    154 # .fi
    155 #	The Secure Mailer license must be distributed with this software.
    156 # AUTHOR(S)
    157 #	Wietse Venema
    158 #	IBM T.J. Watson Research
    159 #	P.O. Box 704
    160 #	Yorktown Heights, NY 10598, USA
    161 #
    162 #	Wietse Venema
    163 #	Google, Inc.
    164 #	111 8th Avenue
    165 #	New York, NY 10011, USA
    166 #--
    167 
    168 # Emit system-dependent Makefile macro definitions to standard output.
    169 
    170 echo "#----------------------------------------------------------------"
    171 echo "# Start of summary of user-configurable 'make makefiles' options."
    172 echo "# CCARGS=$CCARGS"
    173 echo "# AUXLIBS=$AUXLIBS"
    174 env | grep '^AUXLIBS_' | sed 's/^/# /'
    175 echo "# shared=$shared"
    176 echo "# dynamicmaps=$dynamicmaps"
    177 echo "# pie=$pie"
    178 
    179 # Defaults for most sane systems
    180 
    181 RANLIB=ranlib
    182 SYSLIBS=
    183 AR=ar
    184 ARFL=rv
    185 
    186 # Ugly function to make our error message more visible among the
    187 # garbage that is output by some versions of make(1).
    188 
    189 # By now all shells must have functions.
    190 
    191 error() {
    192    # Alas, tput(1) is not portable so we can't use visual effects.
    193    echo "ATTENTION:" 1>&2;
    194    echo "ATTENTION:" $* 1>&2;
    195    echo "ATTENTION:" 1>&2;
    196    exit 1
    197 }
    198 
    199 case $# in
    200  # Officially supported usage.
    201  0) SYSTEM=`(uname -s) 2>/dev/null`
    202     RELEASE=`(uname -r) 2>/dev/null`
    203     # No ${x%%y} support in Solaris 11 /bin/sh
    204     RELEASE_MAJOR=`expr "$RELEASE" : '\([0-9]*\)'` || exit 1
    205     VERSION=`(uname -v) 2>/dev/null`
    206     case "$VERSION" in
    207      dcosx*) SYSTEM=$VERSION;;
    208     esac;;
    209  # Unsupported debug-only mode. Not suitable for cross-platform tests.
    210  2) SYSTEM="$1"; RELEASE="$2";;
    211  *) echo usage: $0 [system release] 1>&2; exit 1;;
    212 esac
    213 
    214 case "$SYSTEM.$RELEASE" in
    215    SCO_SV.3.2)	SYSTYPE=SCO5
    216 		# Use the native compiler by default
    217 		: ${CC="/usr/bin/cc -b elf"}
    218 		CCARGS="$CCARGS -DPIPES_CANT_FIONREAD $CCARGS"
    219 		SYSLIBS="-lsocket -ldbm"
    220 		RANLIB=echo
    221 		;;
    222   UnixWare.5*)	SYSTYPE=UW7
    223 		# Use the native compiler by default
    224 		: ${CC=/usr/bin/cc}
    225 		RANLIB=echo
    226 		SYSLIBS="-lresolv -lsocket -lnsl"
    227 		;;
    228   UNIX_SV.4.2*)	case "`uname -v`" in
    229 	      2.1*) SYSTYPE=UW21
    230 		    # Use the native compiler by default
    231 		    : ${CC=/usr/bin/cc}
    232 		    RANLIB=echo
    233 		    SYSLIBS="-lresolv -lsocket -lnsl -lc -L/usr/ucblib -lucb"
    234 		    ;;
    235 	      *) error "Seems to be UnixWare`uname -v`. Untested.";;
    236 		esac
    237 		;;
    238   FreeBSD.2*)	SYSTYPE=FREEBSD2
    239 		;;
    240   FreeBSD.3*)	SYSTYPE=FREEBSD3
    241 		;;
    242   FreeBSD.4*)	SYSTYPE=FREEBSD4
    243 		;;
    244   FreeBSD.5*)	SYSTYPE=FREEBSD5
    245 		;;
    246   FreeBSD.6*)	SYSTYPE=FREEBSD6
    247 		;;
    248   FreeBSD.7*)	SYSTYPE=FREEBSD7
    249 		;;
    250   FreeBSD.8*)	SYSTYPE=FREEBSD8
    251 		: ${SHLIB_SUFFIX=.so}
    252 		: ${SHLIB_CFLAGS=-fPIC}
    253 		: ${SHLIB_LD="${CC-gcc} -shared"' -Wl,-soname,${LIB}'}
    254 		: ${SHLIB_RPATH='-Wl,-rpath,${SHLIB_DIR}'}
    255 		: ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
    256 		: ${PLUGIN_LD="${CC-gcc} -shared"}
    257 		;;
    258   FreeBSD.9*)	SYSTYPE=FREEBSD9
    259 		: ${SHLIB_SUFFIX=.so}
    260 		: ${SHLIB_CFLAGS=-fPIC}
    261 		: ${SHLIB_LD="${CC-gcc} -shared"' -Wl,-soname,${LIB}'}
    262 		: ${SHLIB_RPATH='-Wl,-rpath,${SHLIB_DIR}'}
    263 		: ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
    264 		: ${PLUGIN_LD="${CC-gcc} -shared"}
    265 		;;
    266   FreeBSD.10*)	SYSTYPE=FREEBSD10
    267 		: ${CC=cc}
    268 		: ${SHLIB_SUFFIX=.so}
    269 		: ${SHLIB_CFLAGS=-fPIC}
    270 		: ${SHLIB_LD="${CC} -shared"' -Wl,-soname,${LIB}'}
    271 		: ${SHLIB_RPATH='-Wl,-rpath,${SHLIB_DIR}'}
    272 		: ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
    273 		: ${PLUGIN_LD="${CC} -shared"}
    274 		;;
    275  DragonFly.*)	SYSTYPE=DRAGONFLY
    276 		;;
    277   OpenBSD.2*)	SYSTYPE=OPENBSD2
    278 		;;
    279   OpenBSD.3*)	SYSTYPE=OPENBSD3
    280 		;;
    281   OpenBSD.4*)	SYSTYPE=OPENBSD4
    282 		;;
    283   OpenBSD.5*)	SYSTYPE=OPENBSD5
    284 		: ${CC=cc}
    285 		: ${SHLIB_SUFFIX=.so.1.0}
    286 		: ${SHLIB_CFLAGS=-fPIC}
    287 		: ${SHLIB_LD="${CC} -shared"' -Wl,-soname,${LIB}'}
    288 		: ${SHLIB_RPATH='-Wl,-rpath,${SHLIB_DIR}'}
    289 		: ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
    290 		: ${PLUGIN_LD="${CC} -shared"}
    291 		;;
    292   OpenBSD.6*)	SYSTYPE=OPENBSD6
    293 		: ${CC=cc}
    294 		: ${SHLIB_SUFFIX=.so.1.0}
    295 		: ${SHLIB_CFLAGS=-fPIC}
    296 		: ${SHLIB_LD="${CC} -shared"' -Wl,-soname,${LIB}'}
    297 		: ${SHLIB_RPATH='-Wl,-rpath,${SHLIB_DIR}'}
    298 		: ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
    299 		: ${PLUGIN_LD="${CC} -shared"}
    300 		;;
    301   ekkoBSD.1*)	SYSTYPE=EKKOBSD1
    302 		;;
    303    NetBSD.1*)	SYSTYPE=NETBSD1
    304 		;;
    305    NetBSD.2*)	SYSTYPE=NETBSD2
    306 		;;
    307    NetBSD.3*)	SYSTYPE=NETBSD3
    308 		;;
    309    NetBSD.4*)	SYSTYPE=NETBSD4
    310 		;;
    311    NetBSD.5*)	SYSTYPE=NETBSD5
    312 		;;
    313    NetBSD.6*)	SYSTYPE=NETBSD6
    314 		: ${SHLIB_SUFFIX=.so}
    315 		: ${SHLIB_CFLAGS=-fPIC}
    316 		: ${SHLIB_LD="${CC-gcc} -shared"' -Wl,-soname,${LIB}'}
    317 		: ${SHLIB_RPATH='-Wl,-rpath,${SHLIB_DIR}'}
    318 		: ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
    319 		: ${PLUGIN_LD="${CC-gcc} -shared"}
    320                ;;
    321    NetBSD.7*)  SYSTYPE=NETBSD7
    322 		: ${SHLIB_SUFFIX=.so}
    323 		: ${SHLIB_CFLAGS=-fPIC}
    324 		: ${SHLIB_LD="${CC-gcc} -shared"' -Wl,-soname,${LIB}'}
    325 		: ${SHLIB_RPATH='-Wl,-rpath,${SHLIB_DIR}'}
    326 		: ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
    327 		: ${PLUGIN_LD="${CC-gcc} -shared"}
    328 		;;
    329    BSD/OS.2*)	SYSTYPE=BSDI2
    330 		;;
    331    BSD/OS.3*)	SYSTYPE=BSDI3
    332 		;;
    333    BSD/OS.4*)	SYSTYPE=BSDI4
    334 		;;
    335  OSF1.V[3-5].*)	SYSTYPE=OSF1
    336 		# Use the native compiler by default
    337 		: ${CC=cc}
    338 		: ${DEBUG="-g3"}
    339 		case $RELEASE in
    340 		V[0-4].*) CCARGS="$CCARGS -DNO_IPV6";;
    341 		esac
    342 		;;
    343     SunOS.4*)	SYSTYPE=SUNOS4
    344 		SYSLIBS=-lresolv
    345 		;;
    346     SunOS.5*)	SYSTYPE=SUNOS5
    347 		RANLIB=echo
    348 		SYSLIBS="-lresolv -lsocket -lnsl -ldl"
    349 		: ${SHLIB_SUFFIX=.so}
    350 		: ${SHLIB_CFLAGS=-fPIC}
    351 		: ${SHLIB_LD="${CC-gcc} -shared"' -Wl,-h,${LIB}'}
    352 		: ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
    353 		: ${SHLIB_RPATH='-Wl,-R,${SHLIB_DIR}'}
    354 		: ${PLUGIN_LD="${CC-gcc} -shared"}
    355 		# Stock awk breaks with >10 files.
    356 		test -x /usr/xpg4/bin/awk && AWK=/usr/xpg4/bin/awk
    357 		# Solaris 2.5 added usleep(), POSIX regexp, POSIX getpwnam/uid_r
    358 		case $RELEASE in
    359 		    5.[0-4]) CCARGS="$CCARGS -DMISSING_USLEEP -DNO_POSIX_REGEXP -DNO_POSIX_GETPW_R";;
    360 		esac
    361 		# Solaris 8 added IPv6 and /dev/poll
    362 		case $RELEASE in
    363 		    5.[0-7]|5.[0-7].*) CCARGS="$CCARGS -DNO_IPV6 -DNO_DEVPOLL";;
    364 		esac
    365 		# Solaris 9 added closefrom(), futimesat() and /dev/*random
    366 		# and appears to have solid UNIX-domain sockets.
    367 		case $RELEASE in
    368 		    5.[0-8]|5.[0-8].*) CCARGS="$CCARGS -DNO_CLOSEFROM -DNO_DEV_URANDOM -DNO_FUTIMESAT -DSTREAM_CONNECTIONS";;
    369 		esac
    370 		# Somewhere NISPLUS went away.
    371 		case $RELEASE in
    372 		    5.[0-9][0-9]*) CCARGS="$CCARGS -DNO_NISPLUS";;
    373 		esac
    374 		# Work around broken str*casecmp(). Do it all here instead
    375 		# of having half the solution in the sys_defs.h file.
    376 		CCARGS="$CCARGS -Dstrcasecmp=fix_strcasecmp \
    377 		    -Dstrncasecmp=fix_strncasecmp"
    378 		STRCASE="strcasecmp.o"
    379 		# Avoid common types of braindamage
    380 		case "$LD_LIBRARY_PATH" in
    381 		?*) error "Don't set LD_LIBRARY_PATH";;
    382 		esac
    383 		case "${CC}" in
    384 		*" "*) ;;
    385 		*ucb*) error "Don't use /usr/ucb/cc or ucblib";;
    386 		  cc*) case `which ${CC}` in
    387 		*ucb*) error "Don't use /usr/ucb/cc or ucblib";;
    388 		  esac;;
    389 		esac
    390 		;;
    391    ULTRIX.4*)	SYSTYPE=ULTRIX4
    392 		if [ -f /usr/local/lib/libdb.a ]; then
    393 		    SYSLIBS="$SYSLIBS -ldb"
    394 		    CCARGS="$CCARGS -DHAS_DB"
    395 		    if [ -d /usr/local/include/db ]; then
    396 			CCARGS="$CCARGS -I/usr/local/include/db"
    397 		    fi
    398 		fi
    399 		for l in syslog resolv; do
    400 		    if [ -f /usr/local/lib/lib$l.a ]; then
    401 			SYSLIBS="$SYSLIBS -l$l"
    402 		    fi
    403 		done
    404 		;;
    405        AIX.*)	case "`uname -v`" in
    406 		6)	SYSTYPE=AIX6
    407 			CCARGS="$CCARGS -DNO_DNSSEC"
    408 			case "$CC" in
    409 			cc|*/cc|xlc|*/xlc) CCARGS="$CCARGS -w -blibpath:/usr/lib:/lib:/usr/local/lib";;
    410 			esac
    411 			CCARGS="$CCARGS -D_ALL_SOURCE -DHAS_POSIX_REGEXP"
    412 			;;
    413 		5)	SYSTYPE=AIX5
    414 			CCARGS="$CCARGS -DNO_DNSSEC"
    415 			case "$CC" in
    416 			cc|*/cc|xlc|*/xlc) CCARGS="$CCARGS -w -blibpath:/usr/lib:/lib:/usr/local/lib";;
    417 			esac
    418 			CCARGS="$CCARGS -D_ALL_SOURCE -DHAS_POSIX_REGEXP"
    419 			;;
    420 		4)	SYSTYPE=AIX4
    421 			CCARGS="$CCARGS -DNO_DNSSEC"
    422 			# How embarrassing...
    423 			case "$CC" in
    424 			cc|*/cc|xlc|*/xlc) OPT=; CCARGS="$CCARGS -w -blibpath:/usr/lib:/lib:/usr/local/lib";;
    425 			esac
    426 			CCARGS="$CCARGS -D_ALL_SOURCE -DHAS_POSIX_REGEXP"
    427 			;;
    428 		3)	SYSTYPE=AIX3
    429 			CCARGS="$CCARGS -DNO_DNSSEC"
    430 			# How embarrassing...
    431 			case "$CC" in
    432 			cc|*/cc|xlc|*/xlc) OPT=; CCARGS="$CCARGS -w";;
    433 			esac
    434 			CCARGS="$CCARGS -D_ALL_SOURCE"
    435 			;;
    436 		*)	error "Unknown AIX version: `uname -v`.";;
    437 		esac;;
    438 		# Tested with RedHat 3.03 on 20020729.
    439     Linux.1*)	SYSTYPE=LINUX1
    440 		case "$CCARGS" in
    441 		 *-DNO_DB*) ;;
    442 		 *-DHAS_DB*) ;;
    443 		 *) SYSLIBS="-ldb";;
    444 		esac
    445 		;;
    446     Linux.2*)	SYSTYPE=LINUX2
    447 		case "$CCARGS" in
    448 		 *-DNO_DB*) ;;
    449 		 *-DHAS_DB*) ;;
    450 		 *) if [ -f /usr/include/db.h ]
    451 		    then
    452 			: we are all set
    453 		    elif [ -f /usr/include/db/db.h ]
    454 		    then
    455 			CCARGS="$CCARGS -I/usr/include/db"
    456 		    else
    457 			# No, we're not going to try db1 db2 db3 etc.
    458 			# On a properly installed system, Postfix builds
    459 			# by including <db.h> and by linking with -ldb
    460 			echo "No <db.h> include file found." 1>&2
    461 			echo "Install the appropriate db*-devel package first." 1>&2
    462 			exit 1
    463 		    fi
    464 		    SYSLIBS="-ldb"
    465 		    ;;
    466 		esac
    467 		for name in nsl resolv $GDBM_LIBS
    468 		do
    469 		    for lib in /usr/lib64 /lib64 /usr/lib /lib
    470 		    do
    471 			test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
    472 			    SYSLIBS="$SYSLIBS -l$name"
    473 			    break
    474 			}
    475 		    done
    476 		done
    477 		# Kernel 2.4 added IPv6
    478 		case "$RELEASE" in
    479 		2.[0-3].*) CCARGS="$CCARGS -DNO_IPV6";;
    480 		esac
    481 		# Kernel 2.6 added EPOLL
    482 		case "$RELEASE" in
    483 		2.[0-5].*) CCARGS="$CCARGS -DNO_EPOLL";;
    484 		    # Workaround for retarded libc 
    485 		    2.6.*)
    486 		       if [ `expr "X$CCARGS" : "X.*-DNO_EPOLL"` -gt 0 ]
    487 		       then
    488 			   :
    489 		       elif [ ! -e /usr/include/sys/epoll.h ]
    490 		       then
    491 			   echo CCARGS="$CCARGS -DNO_EPOLL"
    492 		       else
    493 			   trap 'rm -f makedefs.test makedefs.test.[co]' 1 2 3 15
    494 			   cat >makedefs.test.c <<'EOF'
    495 #include <sys/types.h>
    496 #include <sys/epoll.h>
    497 #include <errno.h>
    498 #include <stdio.h>
    499 #include <stdlib.h>
    500 
    501 int     main(int argc, char **argv)
    502 {
    503     int     epoll_handle;
    504 
    505     if ((epoll_handle = epoll_create(1)) < 0) {
    506 	perror("epoll_create");
    507 	exit(1);
    508     }
    509     exit(0);
    510 }
    511 EOF
    512 			   ${CC-gcc} -o makedefs.test makedefs.test.c || exit 1
    513 			   ./makedefs.test 2>/dev/null ||
    514 				CCARGS="$CCARGS -DNO_EPOLL"
    515 			   rm -f makedefs.test makedefs.test.[co]
    516 		       fi;;
    517 		esac
    518 		SYSLIBS="$SYSLIBS -ldl"
    519 		: ${SHLIB_SUFFIX=.so}
    520 		: ${SHLIB_CFLAGS=-fPIC}
    521 		: ${SHLIB_LD="${CC-gcc} -shared"' -Wl,-soname,${LIB}'}
    522 		: ${SHLIB_RPATH='-Wl,--enable-new-dtags -Wl,-rpath,${SHLIB_DIR}'}
    523 		: ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
    524 		: ${PLUGIN_LD="${CC-gcc} -shared"}
    525 		;;
    526   Linux.[34].*)	SYSTYPE=LINUX$RELEASE_MAJOR
    527 		case "$CCARGS" in
    528 		 *-DNO_DB*) ;;
    529 		 *-DHAS_DB*) ;;
    530 		 *) if [ -f /usr/include/db.h ]
    531 		    then
    532 			: we are all set
    533 		    elif [ -f /usr/include/db/db.h ]
    534 		    then
    535 			CCARGS="$CCARGS -I/usr/include/db"
    536 		    else
    537 			# On a properly installed system, Postfix builds
    538 			# by including <db.h> and by linking with -ldb
    539 			echo "No <db.h> include file found." 1>&2
    540 			echo "Install the appropriate db*-devel package first." 1>&2
    541 			exit 1
    542 		    fi
    543 		    SYSLIBS="-ldb"
    544 		    ;;
    545 		esac
    546 		for name in nsl resolv
    547 		do
    548 		    for lib in /usr/lib64 /lib64 /usr/lib /usr/lib/* /lib /lib/*
    549 		    do
    550 			test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
    551 			    SYSLIBS="$SYSLIBS -l$name"
    552 			    break
    553 			}
    554 		    done
    555 		done
    556 		SYSLIBS="$SYSLIBS -ldl"
    557 		: ${SHLIB_SUFFIX=.so}
    558 		: ${SHLIB_CFLAGS=-fPIC}
    559 		: ${SHLIB_LD="${CC-gcc} -shared"' -Wl,-soname,${LIB}'}
    560 		: ${SHLIB_RPATH='-Wl,--enable-new-dtags -Wl,-rpath,${SHLIB_DIR}'}
    561 		: ${SHLIB_ENV="LD_LIBRARY_PATH=`pwd`/lib"}
    562 		: ${PLUGIN_LD="${CC-gcc} -shared"}
    563 		;;
    564      GNU.0*|GNU/kFreeBSD.[567]*)
    565 		SYSTYPE=GNU0
    566 		case "$CCARGS" in
    567 		 *-DNO_DB*) ;;
    568 		 *) if [ -f /usr/include/db.h ]
    569 		    then
    570 			: we are all set
    571 		    elif [ -f /usr/include/db/db.h ]
    572 		    then
    573 			CCARGS="$CCARGS -I/usr/include/db"
    574 		    else
    575 			# On a properly installed system, Postfix builds
    576 			# by including <db.h> and by linking with -ldb
    577 			echo "No <db.h> include file found." 1>&2
    578 			echo "Install the appropriate db*-devel package first." 1>&2
    579 			exit 1
    580 		    fi
    581 		    SYSLIBS="-ldb"
    582 		    ;;
    583 		esac
    584 		for name in nsl resolv
    585 		do
    586 		    for lib in /usr/lib64 /lib64 /usr/lib /lib
    587 		    do
    588 			test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
    589 			    SYSLIBS="$SYSLIBS -l$name"
    590 			    break
    591 			}
    592 		    done
    593 		done
    594 		case "`uname -s`" in
    595 		GNU)
    596 			# currently no IPv6 support on Hurd
    597 			CCARGS="$CCARGS -DNO_IPV6"
    598 			;;
    599 		esac
    600 		;;
    601      IRIX*.5.*)	SYSTYPE=IRIX5
    602 		# Use the native compiler by default
    603 		: ${CC=cc} ${DEBUG="-g3"}
    604 		RANLIB=echo
    605 		;;
    606      IRIX*.6.*)	SYSTYPE=IRIX6
    607 		# Use the native compiler by default, and allow nested comments.
    608 		: ${CC="cc -woff 1009,1116,1412"}
    609 		RANLIB=echo
    610 		;;
    611 HP-UX.A.09.*)	SYSTYPE=HPUX9
    612 		SYSLIBS=-ldbm
    613 		CCARGS="$CCARGS -DMISSING_USLEEP"
    614 		if [ -f /usr/lib/libdb.a ]; then
    615 		    CCARGS="$CCARGS -DHAS_DB"
    616 		    SYSLIBS="$SYSLIBS -ldb"
    617 		fi
    618 		;;
    619 HP-UX.B.10.*)	SYSTYPE=HPUX10
    620 		CCARGS="$CCARGS `nm /usr/lib/libc.a 2>/dev/null |
    621 		    (grep usleep >/dev/null || echo '-DMISSING_USLEEP')`"
    622 		if [ -f /usr/lib/libdb.a ]; then
    623 		    CCARGS="$CCARGS -DHAS_DB"
    624 		    SYSLIBS=-ldb
    625 		fi
    626 		;;
    627 HP-UX.B.11.*)	SYSTYPE=HPUX11
    628 		SYSLIBS=-lnsl
    629 		if [ -f /usr/lib/libdb.a ]; then
    630 		    CCARGS="$CCARGS -DHAS_DB"
    631 		    SYSLIBS="$SYSLIBS -ldb"
    632 		fi
    633 		;;
    634 ReliantUNIX-?.5.43) SYSTYPE=ReliantUnix543
    635 		RANLIB=echo
    636 		SYSLIBS="-lresolv -lsocket -lnsl"
    637 		;;
    638     Darwin.*)   SYSTYPE=MACOSX
    639 		# Use the native compiler by default
    640 		: ${CC=cc}
    641 		CCARGS="$CCARGS"
    642 		# Darwin > 1.3 uses awk and flat_namespace
    643 		case $RELEASE in
    644 		 1.[0-3]) AWK=gawk;;
    645 		       *) AWK=awk
    646 			  SYSLIBS="$SYSLIBS -flat_namespace";;
    647 		esac
    648 		# Darwin 7 adds IPv6 support, BIND_8_COMPAT, NO_NETINFO
    649 		case $RELEASE in
    650 		 [1-6].*) CCARGS="$CCARGS -DNO_IPV6";;
    651 		       *) CCARGS="$CCARGS -DBIND_8_COMPAT -DNO_NETINFO";;
    652 		esac
    653 		# Darwin 9.0 (MacOS X 10.5) adds POSIX getpwnam_r/getpwuid_r
    654 		case $RELEASE in
    655 		 [1-8].*) CCARGS="$CCARGS -DNO_POSIX_GETPW_R";;
    656 		esac
    657 		# Darwin 10.3.0 no longer has <nameser8_compat.h>.
    658 		case $RELEASE in
    659 		     ?.*) CCARGS="$CCARGS -DRESOLVE_H_NEEDS_NAMESER8_COMPAT_H";;
    660 		       *) CCARGS="$CCARGS -DRESOLVE_H_NEEDS_ARPA_NAMESER_COMPAT_H";;
    661 		esac
    662 		# Darwin 11.x (MacOS X 10.7.x), maybe earlier, needs libresolv.
    663 		case $RELEASE in
    664 		?.*|10.*) ;;
    665 		       *) SYSLIBS="$SYSLIBS -lresolv";;
    666 		esac
    667 		# kqueue and/or poll are broken in MacOS X 10.5 (Darwin 9).
    668 		# kqueue works in Mac OS X 10.8 (Darwin 12).
    669 		case $RELEASE in
    670 	    ?.*|1[0-1].*) CCARGS="$CCARGS -DNO_KQUEUE";;
    671 		esac
    672 		: ${SHLIB_CFLAGS=-fPIC}
    673 		: ${SHLIB_SUFFIX=.dylib}
    674 		: ${SHLIB_LD='cc -shared -Wl,-flat_namespace -Wl,-undefined,dynamic_lookup -Wl,-install_name,@rpath/${LIB}'}
    675 		: ${SHLIB_RPATH='-Wl,-rpath,${SHLIB_DIR}'}
    676                 # In MacOS/X 10.11.x /bin/sh unsets DYLD_LIBRARY_PATH, so we
    677                 # have export it into postfix-install indirectly!
    678 		: ${SHLIB_ENV="DYLD_LIBRARY_PATH=`pwd`/lib SHLIB_ENV_VAR=DYLD_LIBRARY_PATH SHLIB_ENV_VAL=`pwd`/lib"}
    679 		: ${PLUGIN_LD='cc -shared -Wl,-flat_namespace -Wl,-undefined,dynamic_lookup'}
    680 		;;
    681     dcosx.1*)	SYSTYPE=DCOSX1
    682 		RANLIB=echo
    683 		SYSLIBS="-lresolv -lsocket -lnsl -lc -lrpcsvc -L/usr/ucblib -lucb"
    684 		;;
    685 
    686 	 ".")	if [ -d /NextApps ]; then
    687 		    SYSTYPE=`hostinfo | sed -n \
    688 			's/^.*NeXT Mach 3.*$/NEXTSTEP3/;/NEXTSTEP3/{p;q;}'`
    689 		    if [ "$SYSTYPE" = "" ]; then
    690 			SYSTYPE=`hostinfo | sed -n \
    691 			    's/^.*NeXT Mach 4.*$/OPENSTEP4/;/OPENSTEP4/{p;q;}'`
    692 		    fi
    693 		    : ${CC=cc}
    694 		    RANLIB="sleep 5; ranlib"
    695 		else
    696 		    error "Unable to determine your system type."
    697 		fi
    698 		;;
    699 	   *)	error "Unknown system type: $SYSTEM $RELEASE";;
    700 esac
    701 
    702 #
    703 # sigsetjmp()/siglongjmp() can be "better" than setjmp()/longjmp()
    704 # if used wisely (that is: almost never, just like signals).
    705 # Unfortunately some implementations have been buggy in the past.
    706 #
    707 case "$CCARGS" in
    708  *-DNO_SIGSETJMP*) ;;
    709 		*) trap 'rm -f makedefs.test makedefs.test.[co]' 1 2 3 15
    710 		   cat >makedefs.test.c <<'EOF'
    711 #include <setjmp.h>
    712 #include <stdlib.h>
    713 #include <stdio.h>
    714 
    715 static int count = 0;
    716 
    717 int     main(int argc, char **argv)
    718 {
    719     sigjmp_buf env;
    720     int     retval;
    721 
    722     switch (retval = sigsetjmp(env, 1)) {
    723     case 0:
    724 	siglongjmp(env, 12345);
    725     case 12345:
    726 	break;
    727     default:
    728 	fprintf(stderr, "Error: siglongjmp ignores second argument\n");
    729 	exit(1);
    730     }
    731 
    732     switch (retval = sigsetjmp(env, 1)) {
    733     case 0:
    734 	if (count++ > 0) {
    735 	    fprintf(stderr, "Error: not overriding siglongjmp(env, 0)\n");
    736 	    exit(1);
    737 	}
    738 	siglongjmp(env, 0);
    739     case 1:
    740 	break;
    741     default:
    742 	fprintf(stderr, "Error: overriding siglongjmp(env, 0) with %d\n",
    743 		retval);
    744 	exit(1);
    745     }
    746     exit(0);
    747 }
    748 EOF
    749 		   ${CC-gcc} -o makedefs.test makedefs.test.c || exit 1
    750 		   ./makedefs.test 2>/dev/null ||
    751 			CCARGS="$CCARGS -DNO_SIGSETJMP"
    752 		   rm -f makedefs.test makedefs.test.[co]
    753 esac
    754 
    755 #
    756 # Look for the ICU library and enable unicode email if available.
    757 #
    758 case "$CCARGS" in
    759 *-DNO_EAI*) ;;
    760 	 *) icu_cppflags=`(icu-config --cppflags) 2>/dev/null` && {
    761 		icu_ldflags=`(icu-config --ldflags) 2>/dev/null` && {
    762 		    trap 'rm -f makedefs.test makedefs.test.[co]' 1 2 3 15
    763 		    cat >makedefs.test.c <<'EOF'
    764 #include <unicode/uidna.h>
    765 #include <stdlib.h>
    766 
    767 int main(int argc, char **argv)
    768 {
    769     char    buf[1024];
    770     UErrorCode error = U_ZERO_ERROR;
    771     UIDNAInfo info = UIDNA_INFO_INITIALIZER;
    772     UIDNA  *idna = uidna_openUTS46(UIDNA_DEFAULT, &error);
    773 
    774     exit(uidna_labelToUnicodeUTF8(idna,
    775 				  "xn--lgbbat1ad8j",	/* an arabic TLD */
    776 				  15,
    777 				  buf,
    778 				  sizeof(buf),
    779 				  &info,
    780 				  &error) != 14);
    781 }
    782 EOF
    783 		    ${CC-gcc} -o makedefs.test makedefs.test.c $icu_cppflags \
    784 			$icu_ldflags >/dev/null 2>&1
    785 		    if ./makedefs.test 2>/dev/null ; then
    786 			CCARGS="$CCARGS $icu_cppflags"
    787 			SYSLIBS="$SYSLIBS $icu_ldflags"
    788 		    else
    789 			CCARGS="$CCARGS -DNO_EAI"
    790 		    fi
    791 		    rm -f makedefs.test makedefs.test.[co]
    792 		}
    793 	    } || CCARGS="$CCARGS -DNO_EAI"
    794 esac
    795 
    796 #
    797 # OpenSSL has no configuration query utility, but we don't try to
    798 # guess. We assume includes in /usr/include/openssl and libraries in
    799 # /usr/lib, or in their /usr/local equivalents. If the OpenSSL files
    800 # are in a non-standard place, their locations need to be specified.
    801 #
    802 #case "$CCARGS" in
    803 # *-DUSE_TLS*)	;;
    804 #  *-DNO_TLS*)	;;
    805 #           *)	CCARGS="$CCARGS -DUSE_TLS"
    806 #		AUXLIBS="$AUXLIBS -lssl -lcrypto"
    807 #		;;
    808 #esac
    809 
    810 #
    811 # We don't know all systems that have /dev/urandom, so we probe.
    812 #
    813 test -r /dev/urandom && CCARGS="$CCARGS -DHAS_DEV_URANDOM"
    814 
    815 #
    816 # PCRE 3.x has a pcre-config utility so we don't have to guess.
    817 #
    818 case "$CCARGS" in
    819 *-DHAS_PCRE*)	;;
    820  *-DNO_PCRE*)	;;
    821 	   *)	pcre_cflags=`(pcre-config --cflags) 2>/dev/null` &&
    822 		    pcre_libs=`(pcre-config --libs) 2>/dev/null` && {
    823 			CCARGS="$CCARGS -DHAS_PCRE $pcre_cflags"
    824 			AUXLIBS_PCRE="$pcre_libs"
    825 		}
    826 		;;
    827 esac
    828 
    829 # Defaults that can be overruled (make makefiles CC=cc OPT=-O6 DEBUG=)
    830 # Disable optimizations by default when compiling for Purify. Disable
    831 # optimizations by default with gcc 2.8, until the compiler is known to
    832 # be OK. Those who dare can still overrule this (make makefiles OPT=-O).
    833 
    834 case "$CC" in
    835  *purify*) : ${OPT=};;
    836 */gcc|gcc) case `$CC -v` in
    837 	   "gcc version 2.8"*) : ${OPT=};;
    838 	   esac;;
    839       *CC) error "Don't use CC. That's the C++ compiler";;
    840 	*) : ${OPT='-O'};;
    841 esac
    842 
    843 # Snapshot only.
    844 #CCARGS="$CCARGS -DSNAPSHOT"
    845 
    846 # Non-production: needs thorough testing, or major changes are still
    847 # needed before the code stabilizes.
    848 #CCARGS="$CCARGS -DNONPROD"
    849 
    850 # Workaround: prepend Postfix include files before other include files.
    851 CCARGS="-I. -I../../include $CCARGS"
    852 
    853 # Portability and usability considerations.
    854 #
    855 # In an ideal world we would be able to provide the option to say
    856 # "make makefiles shlib_directory=/some/where/'$mail_version'".  This
    857 # would allow a running system to be upggraded without worries about
    858 # tempororary program-library ABI incompatibilities (the Postfix
    859 # library API changes incompatibly from one version to the next).
    860 #
    861 # Unfortunately, gmake performs macro expansion on values in name=value
    862 # command-line arguments. In the specific example above, gmake would
    863 # eat up the "$" and "m" before it even invokes makedefs, and it
    864 # ould replace "'${mail_version}'" and "'$(mail_version)'" with
    865 # nothing.
    866 #
    867 # Requiring people to specify $$ is not a good option. Instead we
    868 # replace the string MAIL_VERSION at the end of parameter values in
    869 # "make makefiles name=value...". The replacement depends on usage
    870 # context: the expanded release version in actual pathnames, or the
    871 # unexpanded ${mail_version} in configuration parameter values (both
    872 # main.cf and and built-in defaults).
    873 
    874 # Helper function to determine DEF_MAIL_VERSION.
    875 
    876 def_mail_version()
    877 {
    878     trap 'rm -f makedefs.test makedefs.test.[co]' 1 2 3 15
    879     cat > makedefs.test.c <<'EOF'
    880 #include <stdlib.h>
    881 #include <stdio.h>
    882 EOF
    883         # Avoid "nested comment" warnings. Top-of-file comments start in
    884         # column 1 and have no code after "*/", not even in header files.
    885         # If this is insufficient, kill the problem with #ifndef MAKEDEFS.
    886         sed '/^\/\*/,/\*\//d' src/global/mail_version.h >>makedefs.test.c
    887         cat >>makedefs.test.c <<EOF
    888 #include <stdlib.h>
    889 #include <stdio.h>
    890 #include <string.h>
    891 int     main(void)
    892 {
    893     printf("%s\n", DEF_MAIL_VERSION);
    894     fflush(stdout);
    895     exit(ferror(stdout) ? 1 : 0);
    896 }
    897 EOF
    898     eval ${CC-gcc} ${CCARGS} -o makedefs.test makedefs.test.c || exit 1
    899     ./makedefs.test || exit 1
    900     rm -f makedefs.test makedefs.test.[co]
    901 }
    902 
    903 # Helper to expand MAIL_VERSION at the end of a command-line parameter value.
    904 
    905 # Note that MAIL_VERSION) does not anchor the match at the end.
    906 
    907 process_input_parameter()
    908 {
    909     echo "#" $parm_name=$parm_val
    910     case "$parm_val" in
    911     *MAIL_VERSION*)
    912 	cparm_val=`echo "$parm_val" | \
    913 	    sed 's/MAIL_VERSION$/\\\\$${mail_version}/g'`|| exit 1
    914 	case "$mail_version" in
    915 	"") mail_version=`def_mail_version` || exit 1
    916 	esac
    917 	parm_val=`echo "$parm_val" | sed 's/MAIL_VERSION$/'"$mail_version/g"` ||
    918 	    exit 1
    919 	case "$parm_val" in
    920 	*MAIL_VERSION*)
    921 	    error "MAIL_VERSION not at end of parameter value: $parm_val"
    922 	esac
    923 	eval ${parm_name}=\""\$parm_val"\";;
    924      *) cparm_val="$parm_val";;
    925     esac
    926     CCARGS="$CCARGS -D$parm_macro=\\\"$cparm_val\\\""
    927 }
    928 
    929 # Optionally override installation-parameter default settings.
    930 
    931 command_directory_macro=DEF_COMMAND_DIR
    932 config_directory_macro=DEF_CONFIG_DIR
    933 daemon_directory_macro=DEF_DAEMON_DIR
    934 data_directory_macro=DEF_DATA_DIR
    935 mail_spool_directory_macro=DEF_MAIL_SPOOL_DIR
    936 mailq_path_macro=DEF_MAILQ_PATH
    937 meta_directory_macro=DEF_META_DIR
    938 newaliases_path_macro=DEF_NEWALIAS_PATH
    939 queue_directory_macro=DEF_QUEUE_DIR
    940 sendmail_path_macro=DEF_SENDMAIL_PATH
    941 shlib_directory_macro=DEF_SHLIB_DIR
    942 openssl_path_macro=DEF_OPENSSL_PATH
    943 
    944 # shlib_directory is checked here because "no" is not a good answer.
    945 # Instead, build with "dynamicmaps=no" and "shared=no" as appropriate.
    946 
    947 for parm_name in command_directory config_directory daemon_directory \
    948 	data_directory mail_spool_directory mailq_path meta_directory \
    949 	newaliases_path queue_directory sendmail_path shlib_directory \
    950 	openssl_path
    951 do
    952     eval parm_val=\"\$$parm_name\"
    953     eval parm_macro=\"\$${parm_name}_macro\"
    954     case "$parm_val" in
    955     "") ;;
    956     /*) process_input_parameter;;
    957      *) error "$parm_name must specify an absolute path name";;
    958     esac
    959 done
    960 
    961 html_directory_macro=DEF_HTML_DIR
    962 manpage_directory_macro=DEF_MANPAGE_DIR
    963 readme_directory_macro=DEF_README_DIR
    964 
    965 for parm_name in html_directory manpage_directory readme_directory
    966 do
    967     eval parm_val=\"\$$parm_name\"
    968     eval parm_macro=\"\$${parm_name}_macro\"
    969     case "$parm_val" in
    970     "") ;;
    971  /*|no) process_input_parameter;;
    972      *) error "$parm_name must specify \"no\" or an absolute path name";;
    973     esac
    974 done
    975 
    976 default_database_type_macro=DEF_DB_TYPE
    977 
    978 for parm_name in default_database_type
    979 do
    980     eval parm_val=\"\$$parm_name\"
    981     eval parm_macro=\"\$${parm_name}_macro\"
    982     case "$parm_val" in
    983     "") ;;
    984      *) process_input_parameter;;
    985     esac
    986 done
    987 
    988 echo "# End of summary of user-configurable 'make makefiles' options."
    989 echo "#--------------------------------------------------------------"
    990 
    991 # The following are for non-shared libsasl and libmilter builds.
    992 
    993 _AR=$AR
    994 _RANLIB=$RANLIB
    995 
    996 # Choose between dynamic and static library builds.
    997 
    998 case "$dynamicmaps" in
    999   yes) shared=yes;;
   1000 ""|no) ;;
   1001     *) error "Specify \"dynamicmaps=yes\" or \"dynamicmaps=no\"";;
   1002 esac
   1003 
   1004 case "$shared" in
   1005 yes)
   1006     if [ -z "$SHLIB_SUFFIX" ]
   1007     then 
   1008 	error "Shared libraries are requested, but not supported on this platform"
   1009     fi
   1010     AR=:
   1011     RANLIB=:
   1012     CCARGS="$CCARGS -DUSE_DYNAMIC_LIBS"
   1013     case "$dynamicmaps" in
   1014     yes) NON_PLUGIN_MAP_OBJ=
   1015 	 PLUGIN_MAP_OBJ='$(MAP_OBJ)'
   1016 	 PLUGIN_MAP_OBJ_UPDATE=plugin_map_obj_update
   1017 	 PLUGIN_MAP_SO_MAKE=plugin_map_so_make
   1018 	 PLUGIN_MAP_SO_UPDATE=plugin_map_so_update
   1019 	 CCARGS="$CCARGS -DUSE_DYNAMIC_MAPS"
   1020 	 ;;
   1021       *) NON_PLUGIN_MAP_OBJ='$(MAP_OBJ)'
   1022 	 PLUGIN_MAP_OBJ=
   1023 	 PLUGIN_MAP_OBJ_UPDATE=
   1024 	 PLUGIN_MAP_SO_MAKE=
   1025 	 PLUGIN_MAP_SO_UPDATE=
   1026 	 PLUGIN_LD=
   1027 	 CCARGS="$CCARGS -UUSE_DYNAMIC_MAPS"
   1028 	 ;;
   1029     esac
   1030 
   1031     # Determine the dynamically-linked library and plugin installation
   1032     # directory.
   1033 
   1034     parm_name=shlib_directory
   1035     eval parm_val=\"\$$parm_name\"
   1036     eval parm_macro=\"\$${parm_name}_macro\"
   1037     case "$parm_val" in
   1038     /*|no) # CCARGS was already updated above.
   1039 	;;
   1040     "") trap 'rm -f makedefs.test makedefs.test.[co]' 1 2 3 15
   1041 	sed -n '
   1042 	    /_SHLIB_DIR/,/^$/p
   1043 	' src/global/mail_params.h >makedefs.test.c
   1044 	cat >>makedefs.test.c <<EOF
   1045 #include <stdlib.h>
   1046 #include <stdio.h>
   1047 int     main(void)
   1048 {
   1049     printf("%s\n", $parm_macro);
   1050     fflush(stdout);
   1051     exit(ferror(stdout) ? 1 : 0);
   1052 }
   1053 EOF
   1054 	eval ${CC-gcc} ${CCARGS} -o makedefs.test makedefs.test.c || exit 1
   1055 	parm_val=`./makedefs.test` || exit 1
   1056 	rm -f makedefs.test makedefs.test.[co]
   1057 	eval ${parm_name}=\""\$parm_val"\"
   1058 	#CCARGS="$CCARGS -D$parm_macro=\\\"$parm_val\\\""
   1059 	;;
   1060      *) # this parameter was already checked above.
   1061 	error "Can't happen in $0 - $parm_val is not an absolute path"
   1062 	;;
   1063     esac
   1064 
   1065     LIB_PREFIX=postfix-
   1066     LIB_SUFFIX=${SHLIB_SUFFIX}
   1067     ;;
   1068 
   1069 no|"")
   1070     shlib_directory=no
   1071     CCARGS="$CCARGS -UUSE_DYNAMIC_LIBS -DDEF_SHLIB_DIR=\\\"no\\\""
   1072     CCARGS="$CCARGS -UUSE_DYNAMIC_MAPS"
   1073     SHLIB_CFLAGS=
   1074     SHLIB_SUFFIX=
   1075     SHLIB_LD=:
   1076     SHLIB_SYSLIBS=
   1077     SHLIB_RPATH=
   1078     SHLIB_ENV=
   1079     LIB_PREFIX=
   1080     LIB_SUFFIX=.a
   1081     NON_PLUGIN_MAP_OBJ='$(MAP_OBJ)'
   1082     PLUGIN_MAP_OBJ=
   1083     PLUGIN_MAP_OBJ_UPDATE=
   1084     PLUGIN_MAP_SO_MAKE=
   1085     PLUGIN_MAP_SO_UPDATE=
   1086     PLUGIN_LD=
   1087     ;;
   1088 
   1089 *)  error "Specify \"shared=yes\" or \"shared=no\""
   1090     ;;
   1091 esac
   1092 
   1093 # "gcc -W" 3.4.2 no longer reports functions that fail to return a
   1094 # result.  Use "gcc -Wall -Wno-comment" instead. We'll figure out
   1095 # later if the other -Wmumble options are really redundant. Having
   1096 # een burned once by a compiler that lies about what warnings it
   1097 # produces, not taking that chance again.
   1098 
   1099 : ${CC=gcc} ${OPT='-O'} ${DEBUG='-g'} ${AWK=awk} \
   1100 ${WARN='-Wall -Wno-comment -Wformat -Wimplicit -Wmissing-prototypes \
   1101 	-Wparentheses -Wstrict-prototypes -Wswitch -Wuninitialized \
   1102 	-Wunused -Wno-missing-braces'}
   1103 
   1104 # Extract map type names from -DHAS_XXX compiler options.  We avoid
   1105 # problems with tr(1) range syntax by using enumerations instead,
   1106 # and we don't try to figure out which awk versions have tolower().
   1107 # The following was validated in 2014 on FreeBSD/Linux and Solaris 9.
   1108 
   1109 DEFINED_MAP_TYPES=`
   1110     echo $CCARGS | tr -cd '\- _ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' | 
   1111 	tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | ${AWK} '
   1112 	{ for (n = 1; n <= NF; n++)
   1113 	      if ($n ~ /^-dhas_/)
   1114 		  if (seen[name = substr($n, 7)]++ == 0)
   1115 		      printf(" %s", name) }
   1116 '`
   1117 
   1118 # Propagate AUXLIBS_FOO or merge them into global AUXLIBS (i.e. SYSLIBS).
   1119 
   1120 PLUGGABLE_MAPS="CDB LDAP LMDB MYSQL PCRE PGSQL SDBM SQLITE"
   1121 
   1122 case "$dynamicmaps" in
   1123 yes) for name in $PLUGGABLE_MAPS
   1124      do
   1125 	 eval test -n "\"\$AUXLIBS_$name\"" && 
   1126 	     eval PLUGIN_AUXLIBS="\"\$PLUGIN_AUXLIBS
   1127 AUXLIBS_$name = \$AUXLIBS_$name\""
   1128      done;;
   1129   *) for name in $PLUGGABLE_MAPS
   1130      do
   1131 	 eval AUXLIBS="\"\$AUXLIBS \$AUXLIBS_$name\""
   1132      done;;
   1133 esac
   1134 
   1135 # Remove static libraries from SYSLIBS when building shared objects,
   1136 # Can't use the shell "case" patterns to detect names ending in *.a.
   1137 
   1138 case "$shared" in
   1139 yes) SHLIB_SYSLIBS=`${AWK} '
   1140      BEGIN { wc = split("'"$AUXLIBS $SYSLIBS"'", words) 
   1141 	 for (n = 1; n <= wc; n++)
   1142 	     if (words[n] !~ /\.a$/)
   1143 		 printf(" %s", words[n])
   1144      }
   1145      '`
   1146 esac
   1147 
   1148 # Choose between PIE and non-PIE builds.
   1149 
   1150 case "$pie" in
   1151   yes) case "$shared" in
   1152         yes) CCARGS_PIE="-fPIC";;
   1153           *) CCARGS_PIE="-fPIE";;
   1154        esac
   1155        case " $CCARGS " in
   1156          *" $CCARGS_PIE "*) CCARGS_PIE=;;
   1157        esac
   1158        SYSLIBS_PIE="-pie";;
   1159 ""|no) ;;
   1160     *) error "Specify \"pie=yes\" or \"pie=no\"";;
   1161 esac
   1162 
   1163 # Finally...
   1164 
   1165 sed 's/   */ /g' <<EOF
   1166 # System-dependent settings and compiler/linker overrides.
   1167 SYSTYPE	= $SYSTYPE
   1168 _AR	= $_AR
   1169 ARFL	= $ARFL
   1170 _RANLIB	= $_RANLIB
   1171 SYSLIBS	= $SYSLIBS_PIE $AUXLIBS $SYSLIBS $PLUGIN_AUXLIBS
   1172 CC	= $CC $CCARGS_PIE $CCARGS \$(WARN)
   1173 OPT	= $OPT
   1174 DEBUG	= $DEBUG
   1175 AWK	= $AWK
   1176 STRCASE = $STRCASE
   1177 EXPORT	= CCARGS='$CCARGS' OPT='$OPT' DEBUG='$DEBUG'
   1178 WARN	= $WARN
   1179 DEFINED_MAP_TYPES = $DEFINED_MAP_TYPES
   1180 MAKE_FIX = $MAKE_FIX
   1181 # Switch between Postfix static and dynamically-linked libraries.
   1182 AR	= $AR
   1183 RANLIB	= $RANLIB
   1184 LIB_PREFIX = $LIB_PREFIX
   1185 LIB_SUFFIX = $LIB_SUFFIX
   1186 SHLIB_CFLAGS = $SHLIB_CFLAGS
   1187 SHLIB_DIR = $shlib_directory
   1188 SHLIB_ENV = $SHLIB_ENV
   1189 SHLIB_LD = $SHLIB_LD
   1190 SHLIB_SYSLIBS = $SHLIB_SYSLIBS
   1191 SHLIB_RPATH = $SHLIB_RPATH
   1192 # Switch between dynamicmaps.cf plugins and hard-linked databases.
   1193 NON_PLUGIN_MAP_OBJ = $NON_PLUGIN_MAP_OBJ
   1194 PLUGIN_MAP_OBJ = $PLUGIN_MAP_OBJ
   1195 PLUGIN_MAP_OBJ_UPDATE = $PLUGIN_MAP_OBJ_UPDATE
   1196 PLUGIN_MAP_SO_MAKE = $PLUGIN_MAP_SO_MAKE
   1197 PLUGIN_MAP_SO_UPDATE = $PLUGIN_MAP_SO_UPDATE
   1198 PLUGIN_LD = $PLUGIN_LD
   1199 # Application-specific rules.
   1200 EOF
   1201