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