summaryrefslogtreecommitdiff
path: root/lib/megaco/configure.in
blob: 64daa959b57b2884149616e721000dbfc23abd76 (plain)
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
dnl Process this file with autoconf to produce a configure script. -*-m4-*-
dnl
dnl %CopyrightBegin%
dnl
dnl Copyright Ericsson AB 2001-2013. 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

dnl define([AC_CACHE_LOAD], )dnl
dnl define([AC_CACHE_SAVE], )dnl

if test "x$no_recursion" != "xyes" -a "x$OVERRIDE_CONFIG_CACHE" = "x"; then
    # We do not want to use a common cache!
    cache_file=/dev/null
fi

AC_INIT(vsn.mk)

if test -z "$ERL_TOP" || test ! -d $ERL_TOP ; then
  AC_CONFIG_AUX_DIRS(autoconf)
else
  erl_top=${ERL_TOP}
  AC_CONFIG_AUX_DIRS($erl_top/erts/autoconf)
fi

if test "X$host" != "Xfree_source" -a "X$host" != "Xwin32"; then
    AC_CANONICAL_HOST
else
    host_os=win32
fi


dnl ----------------------------------------------------------------------
dnl Checks for programs.
dnl ----------------------------------------------------------------------

AC_DEFUN(ERL_REENTRANT_FLEX,
[flex_compile='$LEX -R -Pconftest -oconftest.c conftest.flex 1>&AC_FD_CC'
changequote(253, 273)dnl
cat > conftest.flex <<EOF
/*
 * This (reentrant) example code comes from the flex manual
 */

%option reentrant stack noyywrap
%x COMMENT

%%

"//"                 yy_push_state( COMMENT, yyscanner);
.|\n

<COMMENT>\n          yy_pop_state( yyscanner );
<COMMENT>[^\n]+      fprintf( yyout, "%s\n", yytext);

%%

int main ( int argc, char * argv[] )
{
  yyscan_t scanner;

  yylex_init ( &scanner );
  yylex ( scanner );
  yylex_destroy ( scanner );
  return 0;
}
EOF
changequote([, ])dnl
AC_MSG_CHECKING(for reentrant capable flex)
if AC_TRY_EVAL(flex_compile) && test -s conftest.c; then
   ifelse([$1], , :, [
   $1])
   AC_MSG_RESULT([yes])
else
   echo "configure: failed program was:" 1>&AC_FD_CC
   cat conftest.flex 1>&AC_FD_CC
   echo "configure: PATH was $PATH" 1>&AC_FD_CC
ifelse([$2], , , [
  $2
])dnl
   AC_MSG_RESULT([no])
fi
])


dnl
dnl Shall we attempt to use reentrant flex scanner or not
dnl
AC_ARG_ENABLE(megaco_reentrant_flex_scanner,
[  --enable-megaco-reentrant-flex-scanner  enable reentrant megaco flex scanner
  --disable-megaco-reentrant-flex-scanner  disable reentrant megaco flex scanner],
  if test x${enable_megaco_reentrant_flex_scanner} = xno ; then
    ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=false
  else
    ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=true
  fi, 
  ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=true)


dnl
dnl flex is needed by megaco. lex wont do!
dnl

AC_PROG_LEX
if test "$LEX" != flex; then
  ENABLE_MEGACO_FLEX_SCANNER=false
else
  ENABLE_MEGACO_FLEX_SCANNER=true
  dnl Check if we can generate a reentrant scanner
  dnl ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=true
  if ${ENABLE_REENTRANT_MEGACO_FLEX_SCANNER} = true ; then
    ERL_REENTRANT_FLEX(ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=true,
                       ENABLE_REENTRANT_MEGACO_FLEX_SCANNER=false)
  fi
fi
AC_SUBST(ENABLE_MEGACO_FLEX_SCANNER)
AC_SUBST(ENABLE_REENTRANT_MEGACO_FLEX_SCANNER)



dnl
dnl For increased performance it is possible to disable lineno
dnl
AC_ARG_ENABLE(megaco_flex_scanner_lineno,
[  --enable-megaco-flex-scanner-lineno  enable megaco flex scanner lineno 
  --disable-megaco-flex-scanner-lineno  disable megaco flex scanner lineno],
  if test x${enable_megaco_flex_scanner_lineno} = xno ; then
    ENABLE_MEGACO_FLEX_SCANNER_LINENO=false
  else
    ENABLE_MEGACO_FLEX_SCANNER_LINENO=true
  fi, 
  ENABLE_MEGACO_FLEX_SCANNER_LINENO=true)
AC_SUBST(ENABLE_MEGACO_FLEX_SCANNER_LINENO)


dnl This is the os flavour, should be unix or win32
if test "X$host" = "Xwin32"; then
	ERLANG_OSTYPE=win32
else
	ERLANG_OSTYPE=unix
fi

AC_SUBST(ERLANG_OSTYPE)

dnl Magic test for clearcase.
if test -d ../../system; then
	OTP_EXTRA_FLAGS=-DOTP_RELEASE
else
	OTP_EXTRA_FLAGS=
fi
AC_SUBST(OTP_EXTRA_FLAGS)

if test "x$GCC" = xyes; then
  # Treat certain GCC warnings as errors
  LM_TRY_ENABLE_CFLAG([-Werror=return-type], [CFLAGS])
fi

dnl
dnl If ${ERL_TOP}/make/otp_ded.mk.in exists and contains DED_MK_VSN > 0,
dnl every thing releted to compiling Dynamic Erlang Drivers can be found
dnl in $(ERL_TOP)/make/$(TARGET)/ded.mk at compile time. If not, try to
dnl figure these things out.
dnl

AC_MSG_CHECKING([for usable Dynamic Erlang Driver configuration])
[
  ded_mk_in="${ERL_TOP}/make/otp_ded.mk.in"
  ded_mk_vsn=
  test -r "$ded_mk_in" &&
    ded_mk_vsn=`sed -n "s/^DED_MK_VSN[	 ]*=[	 ]*\(.*\)/\1/p" < "$ded_mk_in"`
  test "$ded_mk_vsn" != "" || ded_mk_vsn=0
]

if test $ded_mk_vsn -gt 0; then

HAVE_USABLE_OTP_DED_MK=yes
AC_MSG_RESULT([yes])

CC=false
AC_SUBST(CC)
DED_LD=false
AC_SUBST(DED_LD)

else dnl --- begin no usable otp_ded.mk.in ---

HAVE_USABLE_OTP_DED_MK=no
AC_MSG_RESULT([no])

dnl
dnl C compiler (related) defs
dnl

AC_PROG_CC

dnl
dnl Flags to the C compiler
dnl

if test "X$host" = "Xwin32"; then
  DED_CFLAGS="$CFLAGS"
else
  case $host_os in
    darwin*)
	CFLAGS="$CFLAGS -fno-common"
	;;
  esac

  if test "x$GCC" = xyes; then
	DED_CFLAGS="$CFLAGS -fPIC $DED_CFLAGS"
  else
	DED_CFLAGS="$CFLAGS $DED_CFLAGS"
  fi
fi

dnl emulator includes needed
DED_INCLUDES="-I${ERL_TOP}/erts/emulator/beam -I${ERL_TOP}/erts/include -I${ERL_TOP}/erts/include/$host -I${ERL_TOP}/erts/include/internal -I${ERL_TOP}/erts/include/internal/$host -I${ERL_TOP}/erts/emulator/sys/$ERLANG_OSTYPE"

DED_THR_DEFS="-D_THREAD_SAFE -D_REENTRANT"

case $host_os in
	win32)
		DED_LDFLAGS="-dll"
	;;
	solaris2*|sysv4*)
		DED_LDFLAGS="-G"
	;;
	aix4*)
		DED_LDFLAGS="-G -bnoentry -bexpall"
	;;
	freebsd2*)
		# Non-ELF GNU linker
		DED_LDFLAGS="-Bshareable"
	;;
	darwin*)
		# Mach-O linker, a shared lib and a loadable
		# object file is not the same thing.
		DED_LDFLAGS="-bundle -flat_namespace -undefined suppress"
		DED_LD="$CC"
	;;
	*)
		# assume GNU linker and ELF
		DED_LDFLAGS="-shared"
	;;
esac

AC_CHECK_PROGS(DED_LD, [$LD ld.sh])
AC_CHECK_TOOL(DED_LD, ld, no_ld)
if test "$DED_LD" = no_ld; then
  AC_MSG_ERROR([ld is required to build the flex scanner!])
fi

AC_MSG_CHECKING(for linker flags for loadable drivers)
DED_LDFLAGS="$LDFLAGS $DED_LDFLAGS"
AC_MSG_RESULT([$DED_LDFLAGS])

fi dnl --- end no usable otp_ded.mk.in ---

AC_SUBST(HAVE_USABLE_OTP_DED_MK)
AC_SUBST(DED_CFLAGS)
AC_SUBST(DED_INCLUDES)
AC_SUBST(DED_THR_DEFS)
AC_SUBST(DED_LDFLAGS)

AC_CHECK_PROG(PERL, perl, perl, no_perl)
if test "$PERL" = no_perl; then
  AC_MSG_ERROR([Perl is required to build the flex scanner!])
fi

AC_OUTPUT(examples/meas/Makefile:examples/meas/Makefile.in)
AC_OUTPUT(src/flex/$host/Makefile:src/flex/Makefile.in)