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