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