makedefs revision 1.1.1.1.2.2 1 1.1.1.1.2.2 snj #!/bin/sh
2 1.1.1.1.2.2 snj
3 1.1.1.1.2.2 snj #++
4 1.1.1.1.2.2 snj # NAME
5 1.1.1.1.2.2 snj # makedefs 1
6 1.1.1.1.2.2 snj # SUMMARY
7 1.1.1.1.2.2 snj # makefile configuration utility
8 1.1.1.1.2.2 snj # SYNOPSIS
9 1.1.1.1.2.2 snj # \fBmake makefiles \fIname=value...\fR
10 1.1.1.1.2.2 snj # DESCRIPTION
11 1.1.1.1.2.2 snj # The \fBmakedefs\fR command identifies the compilation
12 1.1.1.1.2.2 snj # environment, and emits macro definitions on the standard output
13 1.1.1.1.2.2 snj # stream that can be prepended to template Makefiles.
14 1.1.1.1.2.2 snj #
15 1.1.1.1.2.2 snj # Default settings can be overruled by specifying them as
16 1.1.1.1.2.2 snj # environment variables. Use quotes if variables contain
17 1.1.1.1.2.2 snj # whitespace or shell meta characters.
18 1.1.1.1.2.2 snj # .IP \fBAUXLIBS=\fIobject_library...\fR
19 1.1.1.1.2.2 snj # Specifies one or more non-default object libraries.
20 1.1.1.1.2.2 snj # .IP \fBCC=\fIcompiler_command\fR
21 1.1.1.1.2.2 snj # Specifies a non-default compiler. On many systems, the default
22 1.1.1.1.2.2 snj # is \fBgcc\fR.
23 1.1.1.1.2.2 snj # .IP \fBCCARGS=\fIcompiler_arguments\fR
24 1.1.1.1.2.2 snj # Specifies non-default compiler arguments, for example, a non-default
25 1.1.1.1.2.2 snj # \fIinclude\fR directory.
26 1.1.1.1.2.2 snj # The following directives are special:
27 1.1.1.1.2.2 snj # .RS
28 1.1.1.1.2.2 snj # .IP \fB-DNO_DEVPOLL\fR
29 1.1.1.1.2.2 snj # Do not build with Solaris /dev/poll support.
30 1.1.1.1.2.2 snj # By default, /dev/poll support is compiled in on platforms that
31 1.1.1.1.2.2 snj # are known to support it.
32 1.1.1.1.2.2 snj # .IP \fB-DNO_EPOLL\fR
33 1.1.1.1.2.2 snj # Do not build with Linux EPOLL support.
34 1.1.1.1.2.2 snj # By default, EPOLL support is compiled in on platforms that
35 1.1.1.1.2.2 snj # are known to support it.
36 1.1.1.1.2.2 snj # .IP \fB-DNO_IPV6\fR
37 1.1.1.1.2.2 snj # Do not build with IPv6 support.
38 1.1.1.1.2.2 snj # By default, IPv6 support is compiled in on platforms that
39 1.1.1.1.2.2 snj # are known to have IPv6 support.
40 1.1.1.1.2.2 snj #
41 1.1.1.1.2.2 snj # Note: this directive is for debugging and testing only. It
42 1.1.1.1.2.2 snj # is not guaranteed to work on all platforms.
43 1.1.1.1.2.2 snj # .IP \fB-DNO_KQUEUE\fR
44 1.1.1.1.2.2 snj # Do not build with FreeBSD/NetBSD/OpenBSD/MacOSX KQUEUE support.
45 1.1.1.1.2.2 snj # By default, KQUEUE support is compiled in on platforms that
46 1.1.1.1.2.2 snj # are known to support it.
47 1.1.1.1.2.2 snj # .IP \fB-DNO_PCRE\fR
48 1.1.1.1.2.2 snj # Do not build with PCRE support.
49 1.1.1.1.2.2 snj # By default, PCRE support is compiled in when the \fBpcre-config\fR
50 1.1.1.1.2.2 snj # utility is installed.
51 1.1.1.1.2.2 snj # .IP \fB-DNO_SIGSETJMP\fR
52 1.1.1.1.2.2 snj # Use setjmp()/longjmp() instead of sigsetjmp()/siglongjmp().
53 1.1.1.1.2.2 snj # By default, Postfix uses sigsetjmp()/siglongjmp() when they
54 1.1.1.1.2.2 snj # appear to work.
55 1.1.1.1.2.2 snj # .RE
56 1.1.1.1.2.2 snj # .IP \fBDEBUG=\fIdebug_level\fR
57 1.1.1.1.2.2 snj # Specifies a non-default debugging level. The default is \fB-g\fR.
58 1.1.1.1.2.2 snj # Specify \fBDEBUG=\fR to turn off debugging.
59 1.1.1.1.2.2 snj # .IP \fBOPT=\fIoptimization_level\fR
60 1.1.1.1.2.2 snj # Specifies a non-default optimization level. The default is \fB-O\fR.
61 1.1.1.1.2.2 snj # Specify \fBOPT=\fR to turn off optimization.
62 1.1.1.1.2.2 snj # .IP \fBWARN=\fIwarning_flags\fR
63 1.1.1.1.2.2 snj # Specifies non-default gcc compiler warning options for use when
64 1.1.1.1.2.2 snj # "make" is invoked in a source subdirectory only.
65 1.1.1.1.2.2 snj # LICENSE
66 1.1.1.1.2.2 snj # .ad
67 1.1.1.1.2.2 snj # .fi
68 1.1.1.1.2.2 snj # The Secure Mailer license must be distributed with this software.
69 1.1.1.1.2.2 snj # AUTHOR(S)
70 1.1.1.1.2.2 snj # Wietse Venema
71 1.1.1.1.2.2 snj # IBM T.J. Watson Research
72 1.1.1.1.2.2 snj # P.O. Box 704
73 1.1.1.1.2.2 snj # Yorktown Heights, NY 10598, USA
74 1.1.1.1.2.2 snj #--
75 1.1.1.1.2.2 snj
76 1.1.1.1.2.2 snj # Emit system-dependent Makefile macro definitions to standard output.
77 1.1.1.1.2.2 snj
78 1.1.1.1.2.2 snj # Defaults for most sane systems
79 1.1.1.1.2.2 snj
80 1.1.1.1.2.2 snj RANLIB=ranlib
81 1.1.1.1.2.2 snj SYSLIBS=
82 1.1.1.1.2.2 snj AR=ar
83 1.1.1.1.2.2 snj ARFL=rv
84 1.1.1.1.2.2 snj
85 1.1.1.1.2.2 snj # Ugly function to make our error message more visible among the
86 1.1.1.1.2.2 snj # garbage that is output by some versions of make(1).
87 1.1.1.1.2.2 snj
88 1.1.1.1.2.2 snj # By now all shells must have functions.
89 1.1.1.1.2.2 snj
90 1.1.1.1.2.2 snj error() {
91 1.1.1.1.2.2 snj # Alas, tput(1) is not portable so we can't use visual effects.
92 1.1.1.1.2.2 snj echo "ATTENTION:" 1>&2;
93 1.1.1.1.2.2 snj echo "ATTENTION:" $* 1>&2;
94 1.1.1.1.2.2 snj echo "ATTENTION:" 1>&2;
95 1.1.1.1.2.2 snj exit 1
96 1.1.1.1.2.2 snj }
97 1.1.1.1.2.2 snj
98 1.1.1.1.2.2 snj case $# in
99 1.1.1.1.2.2 snj # Officially supported usage.
100 1.1.1.1.2.2 snj 0) SYSTEM=`(uname -s) 2>/dev/null`
101 1.1.1.1.2.2 snj RELEASE=`(uname -r) 2>/dev/null`
102 1.1.1.1.2.2 snj VERSION=`(uname -v) 2>/dev/null`
103 1.1.1.1.2.2 snj case "$VERSION" in
104 1.1.1.1.2.2 snj dcosx*) SYSTEM=$VERSION;;
105 1.1.1.1.2.2 snj esac;;
106 1.1.1.1.2.2 snj # Unsupported debug-only mode. Not suitable for cross-platform tests.
107 1.1.1.1.2.2 snj 2) SYSTEM="$1"; RELEASE="$2";;
108 1.1.1.1.2.2 snj *) echo usage: $0 [system release] 1>&2; exit 1;;
109 1.1.1.1.2.2 snj esac
110 1.1.1.1.2.2 snj
111 1.1.1.1.2.2 snj case "$SYSTEM.$RELEASE" in
112 1.1.1.1.2.2 snj SCO_SV.3.2) SYSTYPE=SCO5
113 1.1.1.1.2.2 snj # Use the native compiler by default
114 1.1.1.1.2.2 snj : ${CC="/usr/bin/cc -b elf"}
115 1.1.1.1.2.2 snj CCARGS="$CCARGS -DPIPES_CANT_FIONREAD $CCARGS"
116 1.1.1.1.2.2 snj SYSLIBS="-lsocket -ldbm"
117 1.1.1.1.2.2 snj RANLIB=echo
118 1.1.1.1.2.2 snj ;;
119 1.1.1.1.2.2 snj UnixWare.5*) SYSTYPE=UW7
120 1.1.1.1.2.2 snj # Use the native compiler by default
121 1.1.1.1.2.2 snj : ${CC=/usr/bin/cc}
122 1.1.1.1.2.2 snj RANLIB=echo
123 1.1.1.1.2.2 snj SYSLIBS="-lresolv -lsocket -lnsl"
124 1.1.1.1.2.2 snj ;;
125 1.1.1.1.2.2 snj UNIX_SV.4.2*) case "`uname -v`" in
126 1.1.1.1.2.2 snj 2.1*) SYSTYPE=UW21
127 1.1.1.1.2.2 snj # Use the native compiler by default
128 1.1.1.1.2.2 snj : ${CC=/usr/bin/cc}
129 1.1.1.1.2.2 snj RANLIB=echo
130 1.1.1.1.2.2 snj SYSLIBS="-lresolv -lsocket -lnsl -lc -L/usr/ucblib -lucb"
131 1.1.1.1.2.2 snj ;;
132 1.1.1.1.2.2 snj *) error "Seems to be UnixWare`uname -v`. Untested.";;
133 1.1.1.1.2.2 snj esac
134 1.1.1.1.2.2 snj ;;
135 1.1.1.1.2.2 snj FreeBSD.2*) SYSTYPE=FREEBSD2
136 1.1.1.1.2.2 snj ;;
137 1.1.1.1.2.2 snj FreeBSD.3*) SYSTYPE=FREEBSD3
138 1.1.1.1.2.2 snj ;;
139 1.1.1.1.2.2 snj FreeBSD.4*) SYSTYPE=FREEBSD4
140 1.1.1.1.2.2 snj ;;
141 1.1.1.1.2.2 snj FreeBSD.5*) SYSTYPE=FREEBSD5
142 1.1.1.1.2.2 snj ;;
143 1.1.1.1.2.2 snj FreeBSD.6*) SYSTYPE=FREEBSD6
144 1.1.1.1.2.2 snj ;;
145 1.1.1.1.2.2 snj FreeBSD.7*) SYSTYPE=FREEBSD7
146 1.1.1.1.2.2 snj ;;
147 1.1.1.1.2.2 snj OpenBSD.2*) SYSTYPE=OPENBSD2
148 1.1.1.1.2.2 snj ;;
149 1.1.1.1.2.2 snj OpenBSD.3*) SYSTYPE=OPENBSD3
150 1.1.1.1.2.2 snj ;;
151 1.1.1.1.2.2 snj OpenBSD.4*) SYSTYPE=OPENBSD4
152 1.1.1.1.2.2 snj ;;
153 1.1.1.1.2.2 snj ekkoBSD.1*) SYSTYPE=EKKOBSD1
154 1.1.1.1.2.2 snj ;;
155 1.1.1.1.2.2 snj NetBSD.1*) SYSTYPE=NETBSD1
156 1.1.1.1.2.2 snj ;;
157 1.1.1.1.2.2 snj NetBSD.2*) SYSTYPE=NETBSD2
158 1.1.1.1.2.2 snj ;;
159 1.1.1.1.2.2 snj NetBSD.3*) SYSTYPE=NETBSD3
160 1.1.1.1.2.2 snj ;;
161 1.1.1.1.2.2 snj NetBSD.4*) SYSTYPE=NETBSD4
162 1.1.1.1.2.2 snj ;;
163 1.1.1.1.2.2 snj BSD/OS.2*) SYSTYPE=BSDI2
164 1.1.1.1.2.2 snj ;;
165 1.1.1.1.2.2 snj BSD/OS.3*) SYSTYPE=BSDI3
166 1.1.1.1.2.2 snj ;;
167 1.1.1.1.2.2 snj BSD/OS.4*) SYSTYPE=BSDI4
168 1.1.1.1.2.2 snj ;;
169 1.1.1.1.2.2 snj OSF1.V[3-5].*) SYSTYPE=OSF1
170 1.1.1.1.2.2 snj # Use the native compiler by default
171 1.1.1.1.2.2 snj : ${CC=cc}
172 1.1.1.1.2.2 snj : ${DEBUG="-g3"}
173 1.1.1.1.2.2 snj case $RELEASE in
174 1.1.1.1.2.2 snj V[0-4].*) CCARGS="$CCARGS -DNO_IPV6";;
175 1.1.1.1.2.2 snj esac
176 1.1.1.1.2.2 snj ;;
177 1.1.1.1.2.2 snj SunOS.4*) SYSTYPE=SUNOS4
178 1.1.1.1.2.2 snj SYSLIBS=-lresolv
179 1.1.1.1.2.2 snj ;;
180 1.1.1.1.2.2 snj SunOS.5*) SYSTYPE=SUNOS5
181 1.1.1.1.2.2 snj RANLIB=echo
182 1.1.1.1.2.2 snj SYSLIBS="-lresolv -lsocket -lnsl"
183 1.1.1.1.2.2 snj # Stock awk breaks with >10 files.
184 1.1.1.1.2.2 snj test -x /usr/xpg4/bin/awk && AWK=/usr/xpg4/bin/awk
185 1.1.1.1.2.2 snj # Solaris 2.5 added usleep() and POSIX regular expressions
186 1.1.1.1.2.2 snj case $RELEASE in
187 1.1.1.1.2.2 snj 5.[0-4]) CCARGS="$CCARGS -DMISSING_USLEEP -DNO_POSIX_REGEXP";;
188 1.1.1.1.2.2 snj esac
189 1.1.1.1.2.2 snj # Solaris 8 added IPv6 and /dev/poll
190 1.1.1.1.2.2 snj case $RELEASE in
191 1.1.1.1.2.2 snj 5.[0-7]|5.[0-7].*) CCARGS="$CCARGS -DNO_IPV6 -DNO_DEVPOLL";;
192 1.1.1.1.2.2 snj esac
193 1.1.1.1.2.2 snj # Solaris 9 added closefrom(), futimesat() and /dev/*random
194 1.1.1.1.2.2 snj case $RELEASE in
195 1.1.1.1.2.2 snj 5.[0-8]|5.[0-8].*) CCARGS="$CCARGS -DNO_CLOSEFROM -DNO_DEV_URANDOM -DNO_FUTIMESAT";;
196 1.1.1.1.2.2 snj esac
197 1.1.1.1.2.2 snj # Work around broken str*casecmp(). Do it all here instead
198 1.1.1.1.2.2 snj # of having half the solution in the sys_defs.h file.
199 1.1.1.1.2.2 snj CCARGS="$CCARGS -Dstrcasecmp=fix_strcasecmp \
200 1.1.1.1.2.2 snj -Dstrncasecmp=fix_strncasecmp"
201 1.1.1.1.2.2 snj STRCASE="strcasecmp.o"
202 1.1.1.1.2.2 snj # Avoid common types of braindamage
203 1.1.1.1.2.2 snj case "$LD_LIBRARY_PATH" in
204 1.1.1.1.2.2 snj ?*) error "Don't set LD_LIBRARY_PATH";;
205 1.1.1.1.2.2 snj esac
206 1.1.1.1.2.2 snj case "${CC}" in
207 1.1.1.1.2.2 snj *" "*) ;;
208 1.1.1.1.2.2 snj *ucb*) error "Don't use /usr/ucb/cc or ucblib";;
209 1.1.1.1.2.2 snj cc*) case `which ${CC}` in
210 1.1.1.1.2.2 snj *ucb*) error "Don't use /usr/ucb/cc or ucblib";;
211 1.1.1.1.2.2 snj esac;;
212 1.1.1.1.2.2 snj esac
213 1.1.1.1.2.2 snj ;;
214 1.1.1.1.2.2 snj ULTRIX.4*) SYSTYPE=ULTRIX4
215 1.1.1.1.2.2 snj if [ -f /usr/local/lib/libdb.a ]; then
216 1.1.1.1.2.2 snj SYSLIBS="$SYSLIBS -ldb"
217 1.1.1.1.2.2 snj CCARGS="$CCARGS -DHAS_DB"
218 1.1.1.1.2.2 snj if [ -d /usr/local/include/db ]; then
219 1.1.1.1.2.2 snj CCARGS="$CCARGS -I/usr/local/include/db"
220 1.1.1.1.2.2 snj fi
221 1.1.1.1.2.2 snj fi
222 1.1.1.1.2.2 snj for l in syslog resolv; do
223 1.1.1.1.2.2 snj if [ -f /usr/local/lib/lib$l.a ]; then
224 1.1.1.1.2.2 snj SYSLIBS="$SYSLIBS -l$l"
225 1.1.1.1.2.2 snj fi
226 1.1.1.1.2.2 snj done
227 1.1.1.1.2.2 snj ;;
228 1.1.1.1.2.2 snj AIX.*) case "`uname -v`" in
229 1.1.1.1.2.2 snj 5) SYSTYPE=AIX5
230 1.1.1.1.2.2 snj case "$CC" in
231 1.1.1.1.2.2 snj cc|*/cc|xlc|*/xlc) CCARGS="$CCARGS -w -blibpath:/usr/lib:/lib:/usr/local/lib";;
232 1.1.1.1.2.2 snj esac
233 1.1.1.1.2.2 snj CCARGS="$CCARGS -D_ALL_SOURCE -DHAS_POSIX_REGEXP"
234 1.1.1.1.2.2 snj ;;
235 1.1.1.1.2.2 snj 4) SYSTYPE=AIX4
236 1.1.1.1.2.2 snj # How embarrassing...
237 1.1.1.1.2.2 snj case "$CC" in
238 1.1.1.1.2.2 snj cc|*/cc|xlc|*/xlc) OPT=; CCARGS="$CCARGS -w -blibpath:/usr/lib:/lib:/usr/local/lib";;
239 1.1.1.1.2.2 snj esac
240 1.1.1.1.2.2 snj CCARGS="$CCARGS -D_ALL_SOURCE -DHAS_POSIX_REGEXP"
241 1.1.1.1.2.2 snj ;;
242 1.1.1.1.2.2 snj 3) SYSTYPE=AIX3
243 1.1.1.1.2.2 snj # How embarrassing...
244 1.1.1.1.2.2 snj case "$CC" in
245 1.1.1.1.2.2 snj cc|*/cc|xlc|*/xlc) OPT=; CCARGS="$CCARGS -w";;
246 1.1.1.1.2.2 snj esac
247 1.1.1.1.2.2 snj CCARGS="$CCARGS -D_ALL_SOURCE"
248 1.1.1.1.2.2 snj ;;
249 1.1.1.1.2.2 snj *) error "Unknown AIX version: `uname -v`.";;
250 1.1.1.1.2.2 snj esac;;
251 1.1.1.1.2.2 snj # Tested with RedHat 3.03 on 20020729.
252 1.1.1.1.2.2 snj Linux.1*) SYSTYPE=LINUX1
253 1.1.1.1.2.2 snj SYSLIBS="-ldb"
254 1.1.1.1.2.2 snj ;;
255 1.1.1.1.2.2 snj Linux.2*) SYSTYPE=LINUX2
256 1.1.1.1.2.2 snj # Postfix no longer needs DB 1.85 compatibility
257 1.1.1.1.2.2 snj if [ -f /usr/include/db.h ]
258 1.1.1.1.2.2 snj then
259 1.1.1.1.2.2 snj : we are all set
260 1.1.1.1.2.2 snj elif [ -f /usr/include/db/db.h ]
261 1.1.1.1.2.2 snj then
262 1.1.1.1.2.2 snj CCARGS="$CCARGS -I/usr/include/db"
263 1.1.1.1.2.2 snj else
264 1.1.1.1.2.2 snj # No, we're not going to try db1 db2 db3 etc.
265 1.1.1.1.2.2 snj # On a properly installed system, Postfix builds
266 1.1.1.1.2.2 snj # by including <db.h> and by linking with -ldb
267 1.1.1.1.2.2 snj echo "No <db.h> include file found." 1>&2
268 1.1.1.1.2.2 snj echo "Install the appropriate db*-devel package first." 1>&2
269 1.1.1.1.2.2 snj echo "See the RELEASE_NOTES file for more information." 1>&2
270 1.1.1.1.2.2 snj exit 1
271 1.1.1.1.2.2 snj fi
272 1.1.1.1.2.2 snj # GDBM locks the DBM .pag file after open. This breaks postmap.
273 1.1.1.1.2.2 snj # if [ -f /usr/include/gdbm-ndbm.h ]
274 1.1.1.1.2.2 snj # then
275 1.1.1.1.2.2 snj # CCARGS="$CCARGS -DHAS_DBM -DPATH_NDBM_H='<gdbm-ndbm.h>'"
276 1.1.1.1.2.2 snj # GDBM_LIBS=gdbm
277 1.1.1.1.2.2 snj # elif [ -f /usr/include/gdbm/ndbm.h ]
278 1.1.1.1.2.2 snj # then
279 1.1.1.1.2.2 snj # CCARGS="$CCARGS -DHAS_DBM -DPATH_NDBM_H='<gdbm/ndbm.h>'"
280 1.1.1.1.2.2 snj # GDBM_LIBS=gdbm
281 1.1.1.1.2.2 snj # fi
282 1.1.1.1.2.2 snj SYSLIBS="-ldb"
283 1.1.1.1.2.2 snj for name in nsl resolv $GDBM_LIBS
284 1.1.1.1.2.2 snj do
285 1.1.1.1.2.2 snj for lib in /usr/lib64 /lib64 /usr/lib /lib
286 1.1.1.1.2.2 snj do
287 1.1.1.1.2.2 snj test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
288 1.1.1.1.2.2 snj SYSLIBS="$SYSLIBS -l$name"
289 1.1.1.1.2.2 snj break
290 1.1.1.1.2.2 snj }
291 1.1.1.1.2.2 snj done
292 1.1.1.1.2.2 snj done
293 1.1.1.1.2.2 snj # Kernel 2.4 added IPv6
294 1.1.1.1.2.2 snj case "$RELEASE" in
295 1.1.1.1.2.2 snj 2.[0-3].*) CCARGS="$CCARGS -DNO_IPV6";;
296 1.1.1.1.2.2 snj esac
297 1.1.1.1.2.2 snj # Kernel 2.6 added EPOLL
298 1.1.1.1.2.2 snj case "$RELEASE" in
299 1.1.1.1.2.2 snj 2.[0-5].*) CCARGS="$CCARGS -DNO_EPOLL";;
300 1.1.1.1.2.2 snj # Workaround for retarded libc
301 1.1.1.1.2.2 snj 2.6.*) trap 'rm -f makedefs.test makedefs.test.[co]' 1 2 3 15
302 1.1.1.1.2.2 snj cat >makedefs.test.c <<'EOF'
303 1.1.1.1.2.2 snj #include <sys/types.h>
304 1.1.1.1.2.2 snj #include <sys/epoll.h>
305 1.1.1.1.2.2 snj #include <errno.h>
306 1.1.1.1.2.2 snj #include <stdio.h>
307 1.1.1.1.2.2 snj #include <stdlib.h>
308 1.1.1.1.2.2 snj
309 1.1.1.1.2.2 snj int main(int argc, char **argv)
310 1.1.1.1.2.2 snj {
311 1.1.1.1.2.2 snj int epoll_handle;
312 1.1.1.1.2.2 snj
313 1.1.1.1.2.2 snj if ((epoll_handle = epoll_create(1)) < 0) {
314 1.1.1.1.2.2 snj perror("epoll_create");
315 1.1.1.1.2.2 snj exit(1);
316 1.1.1.1.2.2 snj }
317 1.1.1.1.2.2 snj exit(0);
318 1.1.1.1.2.2 snj }
319 1.1.1.1.2.2 snj EOF
320 1.1.1.1.2.2 snj ${CC-gcc} -o makedefs.test makedefs.test.c || exit 1
321 1.1.1.1.2.2 snj ./makedefs.test 2>/dev/null ||
322 1.1.1.1.2.2 snj CCARGS="$CCARGS -DNO_EPOLL"
323 1.1.1.1.2.2 snj rm -f makedefs.test makedefs.test.[co];;
324 1.1.1.1.2.2 snj esac
325 1.1.1.1.2.2 snj ;;
326 1.1.1.1.2.2 snj GNU.0*|GNU/kFreeBSD.[567]*)
327 1.1.1.1.2.2 snj SYSTYPE=GNU0
328 1.1.1.1.2.2 snj # Postfix no longer needs DB 1.85 compatibility
329 1.1.1.1.2.2 snj if [ -f /usr/include/db.h ]
330 1.1.1.1.2.2 snj then
331 1.1.1.1.2.2 snj : we are all set
332 1.1.1.1.2.2 snj elif [ -f /usr/include/db/db.h ]
333 1.1.1.1.2.2 snj then
334 1.1.1.1.2.2 snj CCARGS="$CCARGS -I/usr/include/db"
335 1.1.1.1.2.2 snj else
336 1.1.1.1.2.2 snj # No, we're not going to try db1 db2 db3 etc.
337 1.1.1.1.2.2 snj # On a properly installed system, Postfix builds
338 1.1.1.1.2.2 snj # by including <db.h> and by linking with -ldb
339 1.1.1.1.2.2 snj echo "No <db.h> include file found." 1>&2
340 1.1.1.1.2.2 snj echo "Install the appropriate db*-devel package first." 1>&2
341 1.1.1.1.2.2 snj echo "See the RELEASE_NOTES file for more information." 1>&2
342 1.1.1.1.2.2 snj exit 1
343 1.1.1.1.2.2 snj fi
344 1.1.1.1.2.2 snj SYSLIBS="-ldb"
345 1.1.1.1.2.2 snj for name in nsl resolv
346 1.1.1.1.2.2 snj do
347 1.1.1.1.2.2 snj for lib in /usr/lib64 /lib64 /usr/lib /lib
348 1.1.1.1.2.2 snj do
349 1.1.1.1.2.2 snj test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
350 1.1.1.1.2.2 snj SYSLIBS="$SYSLIBS -l$name"
351 1.1.1.1.2.2 snj break
352 1.1.1.1.2.2 snj }
353 1.1.1.1.2.2 snj done
354 1.1.1.1.2.2 snj done
355 1.1.1.1.2.2 snj case "`uname -s`" in
356 1.1.1.1.2.2 snj GNU)
357 1.1.1.1.2.2 snj # currently no IPv6 support on Hurd
358 1.1.1.1.2.2 snj CCARGS="$CCARGS -DNO_IPV6"
359 1.1.1.1.2.2 snj ;;
360 1.1.1.1.2.2 snj esac
361 1.1.1.1.2.2 snj ;;
362 1.1.1.1.2.2 snj IRIX*.5.*) SYSTYPE=IRIX5
363 1.1.1.1.2.2 snj # Use the native compiler by default
364 1.1.1.1.2.2 snj : ${CC=cc} ${DEBUG="-g3"}
365 1.1.1.1.2.2 snj RANLIB=echo
366 1.1.1.1.2.2 snj ;;
367 1.1.1.1.2.2 snj IRIX*.6.*) SYSTYPE=IRIX6
368 1.1.1.1.2.2 snj # Use the native compiler by default, and allow nested comments.
369 1.1.1.1.2.2 snj : ${CC="cc -woff 1009,1116,1412"}
370 1.1.1.1.2.2 snj RANLIB=echo
371 1.1.1.1.2.2 snj ;;
372 1.1.1.1.2.2 snj HP-UX.A.09.*) SYSTYPE=HPUX9
373 1.1.1.1.2.2 snj SYSLIBS=-ldbm
374 1.1.1.1.2.2 snj CCARGS="$CCARGS -DMISSING_USLEEP"
375 1.1.1.1.2.2 snj if [ -f /usr/lib/libdb.a ]; then
376 1.1.1.1.2.2 snj CCARGS="$CCARGS -DHAS_DB"
377 1.1.1.1.2.2 snj SYSLIBS="$SYSLIBS -ldb"
378 1.1.1.1.2.2 snj fi
379 1.1.1.1.2.2 snj ;;
380 1.1.1.1.2.2 snj HP-UX.B.10.*) SYSTYPE=HPUX10
381 1.1.1.1.2.2 snj CCARGS="$CCARGS `nm /usr/lib/libc.a 2>/dev/null |
382 1.1.1.1.2.2 snj (grep usleep >/dev/null || echo '-DMISSING_USLEEP')`"
383 1.1.1.1.2.2 snj if [ -f /usr/lib/libdb.a ]; then
384 1.1.1.1.2.2 snj CCARGS="$CCARGS -DHAS_DB"
385 1.1.1.1.2.2 snj SYSLIBS=-ldb
386 1.1.1.1.2.2 snj fi
387 1.1.1.1.2.2 snj ;;
388 1.1.1.1.2.2 snj HP-UX.B.11.*) SYSTYPE=HPUX11
389 1.1.1.1.2.2 snj SYSLIBS=-lnsl
390 1.1.1.1.2.2 snj if [ -f /usr/lib/libdb.a ]; then
391 1.1.1.1.2.2 snj CCARGS="$CCARGS -DHAS_DB"
392 1.1.1.1.2.2 snj SYSLIBS="$SYSLIBS -ldb"
393 1.1.1.1.2.2 snj fi
394 1.1.1.1.2.2 snj ;;
395 1.1.1.1.2.2 snj ReliantUNIX-?.5.43) SYSTYPE=ReliantUnix543
396 1.1.1.1.2.2 snj RANLIB=echo
397 1.1.1.1.2.2 snj SYSLIBS="-lresolv -lsocket -lnsl"
398 1.1.1.1.2.2 snj ;;
399 1.1.1.1.2.2 snj Darwin.*) SYSTYPE=MACOSX
400 1.1.1.1.2.2 snj # Use the native compiler by default
401 1.1.1.1.2.2 snj : ${CC=cc}
402 1.1.1.1.2.2 snj # Darwin > 1.3 uses awk and flat_namespace
403 1.1.1.1.2.2 snj case $RELEASE in
404 1.1.1.1.2.2 snj 1.[0-3]) AWK=gawk;;
405 1.1.1.1.2.2 snj *) AWK=awk
406 1.1.1.1.2.2 snj SYSLIBS=-flat_namespace;;
407 1.1.1.1.2.2 snj esac
408 1.1.1.1.2.2 snj # Darwin 7 adds IPv6 support, BIND_8_COMPAT, NO_NETINFO
409 1.1.1.1.2.2 snj case $RELEASE in
410 1.1.1.1.2.2 snj [1-6].*) CCARGS="$CCARGS -DNO_IPV6";;
411 1.1.1.1.2.2 snj *) CCARGS="$CCARGS -DBIND_8_COMPAT -DNO_NETINFO";;
412 1.1.1.1.2.2 snj esac
413 1.1.1.1.2.2 snj # kqueue and/or poll are broken up to and including MacOS X 10.5
414 1.1.1.1.2.2 snj CCARGS="$CCARGS -DNO_KQUEUE"
415 1.1.1.1.2.2 snj # # Darwin 8.11.1 has kqueue support, but let's play safe
416 1.1.1.1.2.2 snj # case $RELEASE in
417 1.1.1.1.2.2 snj # [1-8].*) CCARGS="$CCARGS -DNO_KQUEUE";;
418 1.1.1.1.2.2 snj # *) trap 'rm -f makedefs.test makedefs.test.[co]' 1 2 3 15
419 1.1.1.1.2.2 snj # cat >makedefs.test.c <<'EOF'
420 1.1.1.1.2.2 snj #/* Adapted from libevent. */
421 1.1.1.1.2.2 snj #
422 1.1.1.1.2.2 snj ##include <sys/types.h>
423 1.1.1.1.2.2 snj ##include <sys/event.h>
424 1.1.1.1.2.2 snj ##include <sys/time.h>
425 1.1.1.1.2.2 snj ##include <string.h>
426 1.1.1.1.2.2 snj ##include <stdlib.h>
427 1.1.1.1.2.2 snj ##include <stdio.h>
428 1.1.1.1.2.2 snj #
429 1.1.1.1.2.2 snj ##ifndef EV_SET
430 1.1.1.1.2.2 snj ##define EV_SET(kp, id, fi, fl, ffl, da, ud) do { \
431 1.1.1.1.2.2 snj # struct kevent *__kp = (kp); \
432 1.1.1.1.2.2 snj # __kp->ident = (id); \
433 1.1.1.1.2.2 snj # __kp->filter = (fi); \
434 1.1.1.1.2.2 snj # __kp->flags = (fl); \
435 1.1.1.1.2.2 snj # __kp->fflags = (ffl); \
436 1.1.1.1.2.2 snj # __kp->data = (da); \
437 1.1.1.1.2.2 snj # __kp->udata = (ud); \
438 1.1.1.1.2.2 snj # } while(0)
439 1.1.1.1.2.2 snj ##endif
440 1.1.1.1.2.2 snj #
441 1.1.1.1.2.2 snj #int main(int argc, char **argv)
442 1.1.1.1.2.2 snj #{
443 1.1.1.1.2.2 snj # int kq;
444 1.1.1.1.2.2 snj # struct kevent test_change;
445 1.1.1.1.2.2 snj # struct kevent test_result;
446 1.1.1.1.2.2 snj #
447 1.1.1.1.2.2 snj # if ((kq = kqueue()) < 0) {
448 1.1.1.1.2.2 snj # perror("kqueue");
449 1.1.1.1.2.2 snj # exit(1);
450 1.1.1.1.2.2 snj # }
451 1.1.1.1.2.2 snj ##define TEST_FD (-1)
452 1.1.1.1.2.2 snj #
453 1.1.1.1.2.2 snj # EV_SET(&test_change, TEST_FD, EVFILT_READ, EV_ADD, 0, 0, 0);
454 1.1.1.1.2.2 snj # if (kevent(kq,
455 1.1.1.1.2.2 snj # &test_change, sizeof(test_change) / sizeof(struct kevent),
456 1.1.1.1.2.2 snj # &test_result, sizeof(test_result) / sizeof(struct kevent),
457 1.1.1.1.2.2 snj # (struct timespec *) 0) != 1 ||
458 1.1.1.1.2.2 snj # test_result.ident != TEST_FD ||
459 1.1.1.1.2.2 snj # test_result.flags != EV_ERROR) {
460 1.1.1.1.2.2 snj # fprintf(stderr, "Error: kevent reports errors incorrectly\n");
461 1.1.1.1.2.2 snj # exit(1);
462 1.1.1.1.2.2 snj # }
463 1.1.1.1.2.2 snj # exit(0);
464 1.1.1.1.2.2 snj #}
465 1.1.1.1.2.2 snj #EOF
466 1.1.1.1.2.2 snj # $CC -o makedefs.test makedefs.test.c || exit 1
467 1.1.1.1.2.2 snj # ./makedefs.test 2>/dev/null ||
468 1.1.1.1.2.2 snj # CCARGS="$CCARGS -DNO_KQUEUE"
469 1.1.1.1.2.2 snj # rm -f makedefs.test makedefs.test.[co];;
470 1.1.1.1.2.2 snj # esac
471 1.1.1.1.2.2 snj ;;
472 1.1.1.1.2.2 snj dcosx.1*) SYSTYPE=DCOSX1
473 1.1.1.1.2.2 snj RANLIB=echo
474 1.1.1.1.2.2 snj SYSLIBS="-lresolv -lsocket -lnsl -lc -lrpcsvc -L/usr/ucblib -lucb"
475 1.1.1.1.2.2 snj ;;
476 1.1.1.1.2.2 snj
477 1.1.1.1.2.2 snj ".") if [ -d /NextApps ]; then
478 1.1.1.1.2.2 snj SYSTYPE=`hostinfo | sed -n \
479 1.1.1.1.2.2 snj 's/^.*NeXT Mach 3.*$/NEXTSTEP3/;/NEXTSTEP3/{p;q;}'`
480 1.1.1.1.2.2 snj if [ "$SYSTYPE" = "" ]; then
481 1.1.1.1.2.2 snj SYSTYPE=`hostinfo | sed -n \
482 1.1.1.1.2.2 snj 's/^.*NeXT Mach 4.*$/OPENSTEP4/;/OPENSTEP4/{p;q;}'`
483 1.1.1.1.2.2 snj fi
484 1.1.1.1.2.2 snj : ${CC=cc}
485 1.1.1.1.2.2 snj RANLIB="sleep 5; ranlib"
486 1.1.1.1.2.2 snj else
487 1.1.1.1.2.2 snj error "Unable to determine your system type."
488 1.1.1.1.2.2 snj fi
489 1.1.1.1.2.2 snj ;;
490 1.1.1.1.2.2 snj *) error "Unknown system type: $SYSTEM $RELEASE";;
491 1.1.1.1.2.2 snj esac
492 1.1.1.1.2.2 snj
493 1.1.1.1.2.2 snj #
494 1.1.1.1.2.2 snj # sigsetjmp()/siglongjmp() can be "better" than setjmp()/longjmp()
495 1.1.1.1.2.2 snj # if used wisely (that is: almost never, just like signals).
496 1.1.1.1.2.2 snj # Unfortunately some implementations have been buggy in the past.
497 1.1.1.1.2.2 snj #
498 1.1.1.1.2.2 snj case "$CCARGS" in
499 1.1.1.1.2.2 snj *-DNO_SIGSETJMP*) ;;
500 1.1.1.1.2.2 snj *) trap 'rm -f makedefs.test makedefs.test.[co]' 1 2 3 15
501 1.1.1.1.2.2 snj cat >makedefs.test.c <<'EOF'
502 1.1.1.1.2.2 snj #include <setjmp.h>
503 1.1.1.1.2.2 snj #include <stdlib.h>
504 1.1.1.1.2.2 snj #include <stdio.h>
505 1.1.1.1.2.2 snj
506 1.1.1.1.2.2 snj static int count = 0;
507 1.1.1.1.2.2 snj
508 1.1.1.1.2.2 snj int main(int argc, char **argv)
509 1.1.1.1.2.2 snj {
510 1.1.1.1.2.2 snj sigjmp_buf env;
511 1.1.1.1.2.2 snj int retval;
512 1.1.1.1.2.2 snj
513 1.1.1.1.2.2 snj switch (retval = sigsetjmp(env, 1)) {
514 1.1.1.1.2.2 snj case 0:
515 1.1.1.1.2.2 snj siglongjmp(env, 12345);
516 1.1.1.1.2.2 snj case 12345:
517 1.1.1.1.2.2 snj break;
518 1.1.1.1.2.2 snj default:
519 1.1.1.1.2.2 snj fprintf(stderr, "Error: siglongjmp ignores second argument\n");
520 1.1.1.1.2.2 snj exit(1);
521 1.1.1.1.2.2 snj }
522 1.1.1.1.2.2 snj
523 1.1.1.1.2.2 snj switch (retval = sigsetjmp(env, 1)) {
524 1.1.1.1.2.2 snj case 0:
525 1.1.1.1.2.2 snj if (count++ > 0) {
526 1.1.1.1.2.2 snj fprintf(stderr, "Error: not overriding siglongjmp(env, 0)\n");
527 1.1.1.1.2.2 snj exit(1);
528 1.1.1.1.2.2 snj }
529 1.1.1.1.2.2 snj siglongjmp(env, 0);
530 1.1.1.1.2.2 snj case 1:
531 1.1.1.1.2.2 snj break;
532 1.1.1.1.2.2 snj default:
533 1.1.1.1.2.2 snj fprintf(stderr, "Error: overriding siglongjmp(env, 0) with %d\n",
534 1.1.1.1.2.2 snj retval);
535 1.1.1.1.2.2 snj exit(1);
536 1.1.1.1.2.2 snj }
537 1.1.1.1.2.2 snj exit(0);
538 1.1.1.1.2.2 snj }
539 1.1.1.1.2.2 snj EOF
540 1.1.1.1.2.2 snj ${CC-gcc} -o makedefs.test makedefs.test.c || exit 1
541 1.1.1.1.2.2 snj ./makedefs.test 2>/dev/null ||
542 1.1.1.1.2.2 snj CCARGS="$CCARGS -DNO_SIGSETJMP"
543 1.1.1.1.2.2 snj rm -f makedefs.test makedefs.test.[co]
544 1.1.1.1.2.2 snj esac
545 1.1.1.1.2.2 snj
546 1.1.1.1.2.2 snj #
547 1.1.1.1.2.2 snj # OpenSSL has no configuration query utility, but we don't try to
548 1.1.1.1.2.2 snj # guess. We assume includes in /usr/include/openssl and libraries in
549 1.1.1.1.2.2 snj # /usr/lib, or in their /usr/local equivalents. If the OpenSSL files
550 1.1.1.1.2.2 snj # are in a non-standard place, their locations need to be specified.
551 1.1.1.1.2.2 snj #
552 1.1.1.1.2.2 snj #case "$CCARGS" in
553 1.1.1.1.2.2 snj # *-DUSE_TLS*) ;;
554 1.1.1.1.2.2 snj # *-DNO_TLS*) ;;
555 1.1.1.1.2.2 snj # *) CCARGS="$CCARGS -DUSE_TLS"
556 1.1.1.1.2.2 snj # AUXLIBS="$AUXLIBS -lssl -lcrypto"
557 1.1.1.1.2.2 snj # ;;
558 1.1.1.1.2.2 snj #esac
559 1.1.1.1.2.2 snj
560 1.1.1.1.2.2 snj #
561 1.1.1.1.2.2 snj # PCRE 3.x has a pcre-config utility so we don't have to guess.
562 1.1.1.1.2.2 snj #
563 1.1.1.1.2.2 snj case "$CCARGS" in
564 1.1.1.1.2.2 snj *-DHAS_PCRE*) ;;
565 1.1.1.1.2.2 snj *-DNO_PCRE*) ;;
566 1.1.1.1.2.2 snj *) pcre_cflags=`(pcre-config --cflags) 2>/dev/null` &&
567 1.1.1.1.2.2 snj pcre_libs=`(pcre-config --libs) 2>/dev/null` && {
568 1.1.1.1.2.2 snj CCARGS="$CCARGS -DHAS_PCRE $pcre_cflags"
569 1.1.1.1.2.2 snj AUXLIBS="$AUXLIBS $pcre_libs"
570 1.1.1.1.2.2 snj }
571 1.1.1.1.2.2 snj ;;
572 1.1.1.1.2.2 snj esac
573 1.1.1.1.2.2 snj
574 1.1.1.1.2.2 snj # Defaults that can be overruled (make makefiles CC=cc OPT=-O6 DEBUG=)
575 1.1.1.1.2.2 snj # Disable optimizations by default when compiling for Purify. Disable
576 1.1.1.1.2.2 snj # optimizations by default with gcc 2.8, until the compiler is known to
577 1.1.1.1.2.2 snj # be OK. Those who dare can still overrule this (make makefiles OPT=-O).
578 1.1.1.1.2.2 snj
579 1.1.1.1.2.2 snj case "$CC" in
580 1.1.1.1.2.2 snj *purify*) : ${OPT=};;
581 1.1.1.1.2.2 snj */gcc|gcc) case `$CC -v` in
582 1.1.1.1.2.2 snj "gcc version 2.8"*) : ${OPT=};;
583 1.1.1.1.2.2 snj esac;;
584 1.1.1.1.2.2 snj *CC) error "Don't use CC. That's the C++ compiler";;
585 1.1.1.1.2.2 snj *) : ${OPT='-O'};;
586 1.1.1.1.2.2 snj esac
587 1.1.1.1.2.2 snj #
588 1.1.1.1.2.2 snj # "gcc -W" 3.4.2 no longer reports functions that fail to return a
589 1.1.1.1.2.2 snj # result. Use "gcc -Wall -Wno-comment" instead. We'll figure out
590 1.1.1.1.2.2 snj # later if the other -Wmumble options are really redundant. Having
591 1.1.1.1.2.2 snj # een burned once by a compiler that lies about what warnings it
592 1.1.1.1.2.2 snj # produces, not taking that chance again.
593 1.1.1.1.2.2 snj
594 1.1.1.1.2.2 snj : ${CC='gcc $(WARN)'} ${OPT='-O'} ${DEBUG='-g'} ${AWK=awk} \
595 1.1.1.1.2.2 snj ${WARN='-Wall -Wno-comment -Wformat -Wimplicit -Wmissing-prototypes \
596 1.1.1.1.2.2 snj -Wparentheses -Wstrict-prototypes -Wswitch -Wuninitialized \
597 1.1.1.1.2.2 snj -Wunused -Wno-missing-braces'}
598 1.1.1.1.2.2 snj
599 1.1.1.1.2.2 snj export SYSTYPE AR ARFL RANLIB SYSLIBS CC OPT DEBUG AWK OPTS
600 1.1.1.1.2.2 snj
601 1.1.1.1.2.2 snj # Snapshot only.
602 1.1.1.1.2.2 snj #CCARGS="$CCARGS -DSNAPSHOT"
603 1.1.1.1.2.2 snj
604 1.1.1.1.2.2 snj # Non-production: needs thorough testing, or major changes are still
605 1.1.1.1.2.2 snj # needed before the code stabilizes.
606 1.1.1.1.2.2 snj #CCARGS="$CCARGS -DNONPROD"
607 1.1.1.1.2.2 snj
608 1.1.1.1.2.2 snj sed 's/ / /g' <<EOF
609 1.1.1.1.2.2 snj SYSTYPE = $SYSTYPE
610 1.1.1.1.2.2 snj AR = $AR
611 1.1.1.1.2.2 snj ARFL = $ARFL
612 1.1.1.1.2.2 snj RANLIB = $RANLIB
613 1.1.1.1.2.2 snj SYSLIBS = $AUXLIBS $SYSLIBS
614 1.1.1.1.2.2 snj CC = $CC $CCARGS
615 1.1.1.1.2.2 snj OPT = $OPT
616 1.1.1.1.2.2 snj DEBUG = $DEBUG
617 1.1.1.1.2.2 snj AWK = $AWK
618 1.1.1.1.2.2 snj STRCASE = $STRCASE
619 1.1.1.1.2.2 snj EXPORT = AUXLIBS='$AUXLIBS' CCARGS='$CCARGS' OPT='$OPT' DEBUG='$DEBUG'
620 1.1.1.1.2.2 snj WARN = $WARN
621 1.1.1.1.2.2 snj EOF
622