aboutsummaryrefslogtreecommitdiffstats
path: root/lib/test_server/src/configure.in
blob: ff4ba1dfafed161b4f91eadd1359836c894f725c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
dnl Process this file with autoconf to produce a configure script for Erlang.
dnl
dnl %CopyrightBegin%
dnl 
dnl Copyright Ericsson AB 1997-2009. All Rights Reserved.
dnl 
dnl The contents of this file are subject to the Erlang Public License,
dnl Version 1.1, (the "License"); you may not use this file except in
dnl compliance with the License. You should have received a copy of the
dnl Erlang Public License along with this software. If not, it can be
dnl retrieved online at http://www.erlang.org/.
dnl 
dnl Software distributed under the License is distributed on an "AS IS"
dnl basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
dnl the License for the specific language governing rights and limitations
dnl under the License.
dnl 
dnl %CopyrightEnd%
dnl 

AC_INIT(conf_vars.in)

AC_CANONICAL_HOST

dnl Checks for programs.
AC_PROG_CC

DEBUG_FLAGS="-g -DDEBUG"
if test "$GCC" = yes; then
	DEBUG_FLAGS="$DEBUG_FLAGS -Wall $CFLAGS"
fi
AC_SUBST(DEBUG_FLAGS)

AC_ARG_ENABLE(debug-mode,
[  --enable-debug-mode           enable debug mode],
[ case "$enableval" in
    no) ;;
    *)  CFLAGS=$DEBUG_FLAGS ;;
  esac ], )

AC_CHECK_LIB(m, sin)

#--------------------------------------------------------------------
#	Interactive UNIX requires -linet instead of -lsocket, plus it
#	needs net/errno.h to define the socket-related error codes.
#--------------------------------------------------------------------

AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
AC_CHECK_HEADER(net/errno.h, AC_DEFINE(HAVE_NET_ERRNO_H))

#--------------------------------------------------------------------
# Linux/tcp.h may be needed for sockopt test in kernel
#--------------------------------------------------------------------

AC_CHECK_HEADER(linux/tcp.h, AC_DEFINE(HAVE_LINUX_TCP_H))
AC_MSG_CHECKING(for sane linux/tcp.h)
AC_TRY_COMPILE([#include <stdio.h>
		#include <stdlib.h>
		#include <string.h>
		#include <unistd.h>
		#include <stdarg.h>
		#include <sys/types.h>
		#include <sys/socket.h>
		#include <sys/wait.h>
		#include <linux/tcp.h>
		#include <netinet/in.h>
		#include <netdb.h>],
		[return 0;],	
		have_sane_linux_tcp_h=yes,
		have_sane_linux_tcp_h=no)

if test $have_sane_linux_tcp_h = yes; then
	AC_DEFINE(HAVE_SANE_LINUX_TCP_H,[1],
		  [Define if we have sane linux/tcp.h])
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi



#--------------------------------------------------------------------
#	Linux requires sys/socketio.h instead of sys/sockio.h
#--------------------------------------------------------------------
AC_CHECK_HEADER(sys/socketio.h, AC_DEFINE(HAVE_SOCKETIO_H))


#--------------------------------------------------------------------
#	Misc
#--------------------------------------------------------------------
AC_CHECK_HEADER(poll.h, AC_DEFINE(HAVE_POLL_H))

#--------------------------------------------------------------------
#	The statements below define a collection of symbols related to
#	dynamic loading and shared libraries:
#
#	SHLIB_CFLAGS -	Flags to pass to cc when compiling the components
#			of a shared library (may request position-independent
#			code, among other things).
#	SHLIB_LD -	Base command to use for combining object files
#			into a shared library.
#	SHLIB_SUFFIX -	Suffix to use for the names of dynamically loadable
#			extensions.  An empty string means we don't know how
#			to use shared libraries on this platform.
#--------------------------------------------------------------------

# Step 1: set the variable "system" to hold the name and version number
# for the system.

AC_MSG_CHECKING([system version (for dynamic loading)])
system=`uname -s`-`uname -r`
AC_MSG_RESULT($system)

# Step 2: check for existence of -ldl library.  This is needed because
# Linux can use either -ldl or -ldld for dynamic loading.

AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)

# Step 3: set configuration options based on system name and version.

SHLIB_LDLIBS=

fullSrcDir=`cd $srcdir; pwd`
case $system in
    Linux*)
	SHLIB_CFLAGS="-fPIC"
	SHLIB_SUFFIX=".so"
	if test "$have_dl" = yes; then
	    SHLIB_LD="${CC}"
	    SHLIB_LDFLAGS="$LDFLAGS -shared"
	    LD_FLAGS="-rdynamic"
	else
	    AC_CHECK_HEADER(dld.h, [
		SHLIB_LD="ld"
		SHLIB_LDFLAGS="-shared"])
	fi
	SHLIB_EXTRACT_ALL=""
	;;
    NetBSD-*|FreeBSD-*|OpenBSD-*|DragonFly*)
	# Not available on all versions:  check for include file.
	AC_CHECK_HEADER(dlfcn.h, [
	    SHLIB_CFLAGS="-fpic"
	    SHLIB_LD="ld"
	    SHLIB_LDFLAGS="$LDFLAGS -Bshareable -x"
	    SHLIB_SUFFIX=".so"
	], [
	    # No dynamic loading.
	    SHLIB_CFLAGS=""
	    SHLIB_LD="ld"
	    SHLIB_LDFLAGS="$LDFLAGS"
	    SHLIB_SUFFIX=""
	    AC_MSG_ERROR(don't know how to compile and link dynamic drivers)
	])
	SHLIB_EXTRACT_ALL=""
	;;
    SunOS-4*)
	SHLIB_CFLAGS="-PIC"
	SHLIB_LD="ld"
	SHLIB_LDFLAGS="$LDFLAGS"
	SHLIB_SUFFIX=".so"
	SHLIB_EXTRACT_ALL=""
	;;
    SunOS-5*|UNIX_SV-4.2*)
	SHLIB_CFLAGS="-KPIC"
	SHLIB_LD="/usr/ccs/bin/ld"
	SHLIB_LDFLAGS="$LDFLAGS -G -z text"
	SHLIB_SUFFIX=".so"
	SHLIB_EXTRACT_ALL="-z allextract"
	;;
    Darwin*)
	SHLIB_CFLAGS="-fno-common"
	SHLIB_LD="cc"
	SHLIB_LDFLAGS="$LDFLAGS -bundle -flat_namespace -undefined suppress"
	SHLIB_SUFFIX=".so"
	SHLIB_EXTRACT_ALL=""
	;;
    OSF1*)
	SHLIB_CFLAGS="-fPIC"
	SHLIB_LD="ld"
	SHLIB_LDFLAGS="$LDFLAGS -shared"
	SHLIB_SUFFIX=".so"
	SHLIB_EXTRACT_ALL=""
	;;
    *osf5*)
	SHLIB_CFLAGS="-fPIC"
	SHLIB_LD="${CC} -shared"
	SHLIB_LDFLAGS="$LDFLAGS"
	SHLIB_SUFFIX=".so"
	SHLIB_EXTRACT_ALL=""
	;;
    *)
	# No dynamic loading.
	SHLIB_CFLAGS=""
	SHLIB_LD="ld"
	SHLIB_LDFLAGS=""
	SHLIB_LDLIBS=""
	SHLIB_SUFFIX=""
	SHLIB_EXTRACT_ALL=""
	AC_MSG_ERROR(don't know how to compile and link dynamic drivers)
	;;
esac

# If we're running gcc, then change the C flags for compiling shared
# libraries to the right flags for gcc, instead of those for the
# standard manufacturer compiler.

if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
	case $system in
	    AIX-*)
		;;
	    BSD/OS*)
		;;
	    IRIX*)
		;;
	    NetBSD-*|FreeBSD-*|OpenBSD-*)
		;;
	    RISCos-*)
		;;
	    ULTRIX-4.*)
		;;
	    Darwin*)
		;;
	    *)
		SHLIB_CFLAGS="-fPIC"
		;;
	esac
fi

# Make it possible for erl_interface to use it's own compiler options
EI_CFLAGS="$CFLAGS"

# Add thread-safety flags if requested
AC_ARG_ENABLE(shlib-thread-safety,
[  --enable-shlib-thread-safety  enable thread safety for build shared libraries],
[ case "$enableval" in
    no) ;;
    *)  SHLIB_CFLAGS="$SHLIB_CFLAGS -D_THREAD_SAFE -D_REENTRANT"
	CFLAGS="$CFLAGS -D_THREAD_SAFE -D_REENTRANT"
	;;
  esac ], )

SHLIB_CFLAGS="$SHLIB_CFLAGS $CFLAGS"


AC_SUBST(CFLAGS)
AC_SUBST(SHLIB_LD)
AC_SUBST(SHLIB_LDFLAGS)
AC_SUBST(SHLIB_LDLIBS)
AC_SUBST(SHLIB_CFLAGS)
AC_SUBST(SHLIB_SUFFIX)
AC_SUBST(SHLIB_EXTRACT_ALL)
AC_SUBST(EI_CFLAGS)

#--------------------------------------------------------------------
#	Check for the existence of the -lsocket and -lnsl libraries.
#	The order here is important, so that they end up in the right
#	order in the command line generated by make.  Here are some
#	special considerations:
#	1. Use "connect" and "accept" to check for -lsocket, and
#	   "gethostbyname" to check for -lnsl.
#	2. Use each function name only once:  can't redo a check because
#	   autoconf caches the results of the last check and won't redo it.
#	3. Use -lnsl and -lsocket only if they supply procedures that
#	   aren't already present in the normal libraries.  This is because
#	   IRIX 5.2 has libraries, but they aren't needed and they're
#	   bogus:  they goof up name resolution if used.
#	4. On some SVR4 systems, can't use -lsocket without -lnsl too.
#	   To get around this problem, check for both libraries together
#	   if -lsocket doesn't work by itself.
#--------------------------------------------------------------------

erl_checkBoth=0
AC_CHECK_FUNC(connect, erl_checkSocket=0, erl_checkSocket=1)
if test "$erl_checkSocket" = 1; then
    AC_CHECK_LIB(socket, main, LIBS="$LIBS -lsocket", erl_checkBoth=1)
fi
if test "$erl_checkBoth" = 1; then
    tk_oldLibs=$LIBS
    LIBS="$LIBS -lsocket -lnsl"
    AC_CHECK_FUNC(accept, erl_checkNsl=0, [LIBS=$tk_oldLibs])
fi
AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"]))

dnl Checks for library functions.
AC_CHECK_FUNCS(strerror)
AC_CHECK_FUNCS(vsnprintf)

# First check if the library is available, then if we can choose between
# two versions of gethostbyname
AC_HAVE_LIBRARY(resolv)
AC_CHECK_LIB(resolv, res_gethostbyname,[DEFS="$DEFS -DHAVE_RES_GETHOSTBYNAME=1"])

#--------------------------------------------------------------------
# Emulator compatible flags (for drivers)
#--------------------------------------------------------------------

ERTS_CFLAGS=$CFLAGS
AC_SUBST(ERTS_CFLAGS)

ERTS_LIBS=$LIBS
AC_SUBST(ERTS_LIBS)

#--------------------------------------------------------------------
# Special compiler macro to handle cross compiling
# (HCC) is used to compile tools run in the HOST environment
#--------------------------------------------------------------------
HCC='$(CC)'
AC_SUBST(HCC)

#--------------------------------------------------------------------
# ld is used for linking on vxworks
#--------------------------------------------------------------------
LD='$(CC) $(CFLAGS)'
AC_SUBST(LD)

#--------------------------------------------------------------------
# object file suffix
#--------------------------------------------------------------------
obj='.o'
AC_SUBST(obj)

#--------------------------------------------------------------------
# executable file suffix
#--------------------------------------------------------------------
exe=''
AC_SUBST(exe)

#--------------------------------------------------------------------
# flags when linking for cross platform targets (yet 'tis useful with
# native builds)
#--------------------------------------------------------------------
CROSSLDFLAGS=''
AC_SUBST(CROSSLDFLAGS)

dnl
dnl SSL and CRYPTO needs the library openSSL/ssleay
dnl
dnl Check flags --with-ssl, --without-ssl --with-ssl=PATH.
dnl If no option is given or --with-ssl is set without a path then we
dnl search for SSL libraries and header files in the standard locations. 
dnl If set to --without-ssl we disable the use of SSL
dnl If set to --with-ssl=PATH we use that path as the prefix, i.e. we
dnl use "PATH/include" and "PATH/lib".

AC_SUBST(SSLEAY_ROOT)
TARGET=$host

# We search for SSL. First in the OTP team ClearCase standard location,
# then in the common OS standard locations
# No we do not.  
SSL_APP=ssl
CRYPTO_APP=crypto
SSLEAY_ROOT=$TARGET
#for dir in /usr /usr/pkg /usr/local /usr/local/ssl /usr/lib/ssl /usr/ssl; do
#         AC_CHECK_HEADER($dir/include/openssl/opensslv.h,
#		ac_cv_openssl=yes, ac_cv_openssl=no)
#	 if test $ac_cv_openssl = yes ; then
#                SSLEAY_ROOT="$dir"
#		ssl_found=yes
#		break
#	 fi
#done

# Find a usable java compiler
#
# WARNING this code is copied from ERTS configure.in, and should be
# updated if that code changes. I hate duplicating code, but what
# can I do.
#
dnl ERL_TRY_LINK_JAVA(CLASSES, FUNCTION-BODY
dnl                   [ACTION_IF_FOUND [, ACTION-IF-NOT-FOUND]])
dnl Freely inspired by AC_TRY_LINK. (Maybe better to create a 
dnl AC_LANG_JAVA instead...)
AC_DEFUN(ERL_TRY_LINK_JAVA,
[java_link='$JAVAC conftest.java 1>&AC_FD_CC'
changequote(�, �)dnl
cat > conftest.java <<EOF
�$1�
class conftest { public static void main(String[] args) {
   �$2�
   ; return; }}
EOF
changequote([, ])dnl
if AC_TRY_EVAL(java_link) && test -s conftest.class; then
   ifelse([$3], , :, [rm -rf conftest*
   $3])
else
   echo "configure: failed program was:" 1>&AC_FD_CC
   cat conftest.java 1>&AC_FD_CC
   echo "configure: PATH was $PATH" 1>&AC_FD_CC
ifelse([$4], , , [  rm -rf conftest*
  $4
])dnl
fi
rm -f conftest*])
dnl
AC_CHECK_PROGS(JAVAC, javac guavac gcj jikes bock)
if test -n "$JAVAC"; then
  dnl Make sure it's at least JDK 1.5
  AC_CACHE_CHECK(for JDK version 1.5, 
     ac_cv_prog_javac_ver_1_5,
     [ERL_TRY_LINK_JAVA([], [for (String i : args);],
        ac_cv_prog_javac_ver_1_5=yes, ac_cv_prog_javac_ver_1_5=no)])
  if test $ac_cv_prog_javac_ver_1_5 = no; then
    unset -v JAVAC
  fi
fi
if test -n "$JAVAC"; then
  AC_SUBST(JAVAC)
  :
fi

AC_CHECK_PROGS([make_command], [make gmake], [false])
AC_SUBST(make_command)

if test "$GCC" = yes; then
  test_c_compiler="{gnuc, undefined}"
else
  test_c_compiler="undefined"
fi
AC_SUBST(test_c_compiler)

AC_OUTPUT(conf_vars)