1dnl Process this file with autoconf to produce a configure script. -*-m4-*-
2
3dnl %CopyrightBegin%
4dnl
5dnl Copyright Ericsson AB 2008-2016. All Rights Reserved.
6dnl
7dnl Licensed under the Apache License, Version 2.0 (the "License");
8dnl you may not use this file except in compliance with the License.
9dnl You may obtain a copy of the License at
10dnl
11dnl     http://www.apache.org/licenses/LICENSE-2.0
12dnl
13dnl Unless required by applicable law or agreed to in writing, software
14dnl distributed under the License is distributed on an "AS IS" BASIS,
15dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16dnl See the License for the specific language governing permissions and
17dnl limitations under the License.
18dnl
19dnl %CopyrightEnd%
20
21AC_INIT()
22
23AC_CONFIG_AUX_DIRS($srcdir/autoconf)
24
25AC_PREREQ(2.59)
26
27## Delete previous failed configure results
28if test -f ./CONF_INFO; then
29   rm ./CONF_INFO
30fi
31
32if test -z "$ERL_TOP" || test ! -d $ERL_TOP ; then
33  AC_MSG_ERROR([ERL_TOP is not set])
34else
35  erl_top=${ERL_TOP}
36  AC_CONFIG_AUX_DIRS($erl_top/erts/autoconf)
37  WX_BUILDING_INSIDE_ERLSRC=true
38fi
39
40if test "X$host" != "Xfree_source" -a "X$host" != "Xwin32"; then
41    AC_CANONICAL_HOST
42else
43    host_os=win32
44fi
45
46case $host_os in
47    mingw32)
48	if test "X$host" = "X"; then
49	   host=win32
50	fi
51	;;
52    *)
53	;;
54esac
55
56TARGET=$host
57AC_SUBST(TARGET)
58
59AC_PROG_CC
60AC_PROG_CXX
61AC_PROG_RANLIB
62AC_PROG_CPP
63
64AC_LANG_PUSH([C++])
65AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
66  [[#ifndef __cplusplus
67    #error "broken C++"
68    #endif]])],,
69  [CXX=;])
70AC_LANG_POP([C++])
71if test "X$CXX" = X ; then
72   echo "Can not find C++ compiler" >> ./CONF_INFO
73   WXERL_CAN_BUILD_DRIVER=false
74   AC_MSG_WARN([Can not find C++ compiler])
75fi
76WXERL_CAN_BUILD_DRIVER=false
77
78AC_MSG_NOTICE(Building for [$host_os])
79WXERL_CAN_BUILD_DRIVER=true
80
81LM_WINDOWS_ENVIRONMENT
82
83USER_CFLAGS=$CFLAGS
84
85if test  X"$MIXED_VC" = X"yes" ; then
86   CFLAGS="-Owx"
87fi
88
89AC_CHECK_SIZEOF(void *)
90
91PTHR_CFLAGS="-D_THREAD_SAFE -D_REENTRANT"
92
93OBJC_CC=$CC
94OBJC_CFLAGS=""
95CXXFLAGS=""
96dnl NOTE: CPPFLAGS will be included in CFLAGS at the end
97case $host_os in
98    darwin*)
99	AC_MSG_CHECKING([Checking wxWidgets for min version:])
100	WX_CC=`wx-config --cc`
101	MAC_MIN=`echo "$WX_CC" | sed 's/^[[^ ]]*\ *//'`
102	AC_MSG_RESULT([$MAC_MIN])
103
104	AC_MSG_CHECKING([if compiler accepts -ObjC])
105  	CFLAGS="$CFLAGS -ObjC"
106  	AC_TRY_COMPILE([],[;], accept_objc_flag=true, accept_objc_flag=false)
107  	if test "X$accept_objc_flag" = "Xtrue"; then
108	   AC_MSG_RESULT([yes])
109           C_ONLY_FLAGS="-ObjC"
110	else
111	   dnl We are probably trying to build with a non-Apple gcc,
112	   dnl which is good as long as we do not try to build Cocoa
113	   dnl code. We need an Apple compiler for just that (Objective C)
114	   AC_MSG_RESULT([no])
115	   AC_MSG_CHECKING([for a Cocoa compliant Objective C compiler])
116	   SEARCHFOR=""
117	   SEARCHFORXX=""
118	   save_IFS=$IFS
119	   IFS=:
120	   set $PATH
121	   IFS=$save_IFS
122	   while test X"$1" != X""; do
123	       dnl Add all possible paths to a real apple gcc
124	       SEARCHFOR="$1/gcc-apple-4.2 $SEARCHFOR"
125	       SEARCHFORXX="$1/g++-apple-4.2 $SEARCHFORXX"
126	       shift
127	   done
128	   dnl Add LLVM compilers, they will work in this case
129	   SEARCHFOR="/usr/bin/clang /usr/bin/gcc $SEARCHFOR"
130	   SEARCHFORXX="/usr/bin/clang /usr/bin/g++ $SEARCHFORXX"
131	   APPLE_CC=""
132	   APPLE_CXX=""
133	   dnl SEARCHFOR is reversed, so we want to find the last existing
134	   dnl executable in the list
135	   IFS=" "
136	   set $SEARCHFORXX
137	   for x in $SEARCHFOR; do
138	       if test -x $x; then
139	       	  APPLE_CC=$x
140	       fi
141	       if test -x "$1"; then
142	       	  APPLE_CXX="$1"
143	       fi
144	       shift
145	   done
146	   IFS=$save_IFS
147	   if test X$APPLE_CC = X -o X$APPLE_CXX = X; then
148	      AC_MSG_RESULT([no])
149	      dnl Complete failure, we cannot build Cocoa code
150	      echo "Can not find compiler to compile Cocoa applications" >> ./CONF_INFO
151	      WXERL_CAN_BUILD_DRIVER=false
152	      AC_MSG_WARN([Can not find compiler to compile Cocoa applications])
153	      WXERL_CAN_BUILD_DRIVER=false
154	   else
155	      dnl We think we found an Apple compiler and will add
156	      dnl Apple specific options
157	      AC_MSG_RESULT([$APPLE_CC ($APPLE_CXX)])
158	      dnl We should use this compiler for all of wx - hack...
159	      CC=$APPLE_CC
160	      CXX=$APPLE_CXX
161	      dnl Both clang and gcc accept these flags...
162	      #CXXFLAGS="-x c++ $CXXFLAGS"
163	      OBJC_CC=$APPLE_CC
164	      OBJC_CFLAGS="-ObjC"
165	   fi
166  	fi
167  	CFLAGS="$USER_CFLAGS $MAC_MIN -Wno-deprecated-declarations"
168	CPPFLAGS="$CPPFLAGS -D_MACOSX $PTHR_CFLAGS"
169	;;
170    mingw32)
171	CFLAGS="$CFLAGS -DWIN32 -DWINVER=0x0600 -D_WINDOWS -D_UNICODE -DUNICODE"
172	CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0600"
173	AC_MSG_WARN([Reverting to 32-bit time_t])
174	CPPFLAGS="$CPPFLAGS -D_USE_32BIT_TIME_T"
175	;;
176    win32)
177	CFLAGS="$CFLAGS -DWIN32 -DWINVER=0x0600 -D_WINDOWS -D_UNICODE -DUNICODE"
178	CPPFLAGS="$CPPFLAGS -D_WIN32_WINNT=0x0600"
179	;;
180    *)
181	CFLAGS="$CFLAGS -Wno-deprecated-declarations"
182	CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE $PTHR_CFLAGS"
183	;;
184esac
185
186AC_SUBST(OBJC_CC)
187AC_SUBST(OBJC_CFLAGS)
188
189case $host_os in
190    darwin*)
191	LDFLAGS="$MAC_MIN -bundle -flat_namespace -undefined warning -fPIC $LDFLAGS"
192	# Check sizof_void_p as future will hold 64bit MacOS wx
193	if test $ac_cv_sizeof_void_p = 4; then
194	    LDFLAGS="-m32 $LDFLAGS"
195	fi
196	GL_LIBS="-framework OpenGL"
197	;;
198    win32)
199        LDFLAGS="-dll $LDFLAGS"
200	GL_LIBS="-lglu32 -lOpengl32"
201	;;
202    mingw32)
203	LDFLAGS="-shared -fPIC $LDFLAGS"
204	GL_LIBS="-lglu32 -lOpengl32"
205	;;
206    *)
207	LDFLAGS="-shared -fPIC $LDFLAGS"
208	GL_LIBS="-lGL -lGLU"
209	;;
210esac
211
212dnl ----------------------------------------------------------------------
213dnl Include CPPFLAGS in CFLAGS
214dnl ----------------------------------------------------------------------
215
216case $host_os in
217    mingw32)
218	DEBUG_CFLAGS="-g -Wall -DDEBUG $CFLAGS"
219	CFLAGS="-g -Wall -O2 $CFLAGS -fomit-frame-pointer -fno-strict-aliasing"
220	;;
221    win32)
222	DEBUG_CFLAGS="-g -Wall $CFLAGS -DDEBUG"
223	CFLAGS="-g -Wall -O2 $CFLAGS"
224	;;
225    darwin*)
226	DEBUG_CFLAGS="-g -Wall -fPIC $CFLAGS -DDEBUG"
227	# omit-frame-pointer causes seg faults with 10.9 and clang
228	CFLAGS="-g -Wall -fPIC $CFLAGS -fno-strict-aliasing"
229	;;
230    *)
231	DEBUG_CFLAGS="-g -Wall -fPIC $CFLAGS -DDEBUG"
232	CFLAGS="-Wall -fPIC $CFLAGS -fomit-frame-pointer -fno-strict-aliasing"
233	;;
234esac
235
236dnl
237dnl  Use -O1 -fno-move-loop-invariants for wxe_funcs.cpp to reduce
238dnl  compilation time
239dnl
240
241if test "x$GCC" = xyes -a X"$host_os" != X"win32" ; then
242   CXXNOOPT="-O1"
243   LM_TRY_ENABLE_CFLAG([-fno-move-loop-invariants], [CXXNOOPT])
244fi
245
246dnl
247dnl  Opengl tests
248dnl
249
250if test X"$host_os" != X"win32" ; then
251    AC_CHECK_HEADERS([GL/gl.h], [],
252    	[AC_CHECK_HEADERS([OpenGL/gl.h])])
253    if test X"$ac_cv_header_GL_gl_h" != Xyes &&
254       	test X"$ac_cv_header_OpenGL_gl_h" != Xyes
255    then
256       	saved_CPPFLAGS="$CPPFLAGS"
257	AC_MSG_NOTICE(Checking for OpenGL headers in /usr/X11R6)
258       	CPPFLAGS="-isystem /usr/X11R6/include $CPPFLAGS"
259       	$as_unset ac_cv_header_GL_gl_h
260       	AC_CHECK_HEADERS([GL/gl.h])
261       	if test X"$ac_cv_header_GL_gl_h" != Xyes ; then
262	    AC_MSG_NOTICE(Checking for OpenGL headers in /usr/local)
263	    CPPFLAGS="-isystem /usr/local/include $saved_CPPFLAGS"
264	    $as_unset ac_cv_header_GL_gl_h
265	    AC_CHECK_HEADERS([GL/gl.h])
266	    if test X"$ac_cv_header_GL_gl_h" != Xyes ; then
267		AC_MSG_WARN([No OpenGL headers found, wx will NOT be usable])
268		echo "No OpenGL headers found, wx will NOT be usable" >> ./CONF_INFO
269		WXERL_CAN_BUILD_DRIVER=false
270		CPPFLAGS="$saved_CPPFLAGS"
271	    else
272	    	GL_LIBS="-L/usr/local/lib $GL_LIBS"
273	    fi
274	else
275    	    GL_LIBS="-L/usr/X11R6/lib $GL_LIBS"
276       	fi
277    fi
278else
279    AC_CHECK_HEADERS([gl/gl.h],[],[],[#include <windows.h>])
280fi
281
282if test X"$host_os" != X"win32" ; then
283    AC_CHECK_HEADERS([GL/glu.h], [],
284        [AC_CHECK_HEADERS([OpenGL/glu.h])])
285    if test X"$ac_cv_header_GL_glu_h" != Xyes &&
286        test X"$ac_cv_header_OpenGL_glu_h" != Xyes
287    then
288	AC_MSG_WARN([No GLU headers found, wx will NOT be usable])
289	echo "No GLU headers (glu.h) found, wx will NOT be usable" >> ./CONF_INFO
290	WXERL_CAN_BUILD_DRIVER=false
291    fi
292else
293    AC_CHECK_HEADERS([gl/glu.h],[],[],[#include <windows.h>])
294fi
295
296AC_SUBST(GL_LIBS)
297
298DEBUG_CXXFLAGS="$CXXFLAGS $DEBUG_CFLAGS $CPPFLAGS"
299DEBUG_CFLAGS="$DEBUG_CFLAGS $CPPFLAGS $C_ONLY_FLAGS"
300
301CXXNOOPTFLAGS="$CXXFLAGS $CFLAGS $CPPFLAGS $CXXNOOPT"
302CXXFLAGS="$CXXFLAGS $CFLAGS $CPPFLAGS"
303CFLAGS="$CFLAGS $CPPFLAGS $C_ONLY_FLAGS"
304
305AC_SUBST(DEBUG_CFLAGS)
306AC_SUBST(DEBUG_CXXFLAGS)
307
308ERLC=erlc
309ERL=erl
310ERLANG_ROOT_DIR=$ERL_TOP
311AC_SUBST(ERLC)
312
313AC_SUBST(WX_BUILDING_INSIDE_ERLSRC)
314AC_SUBST(ERLANG_ROOT_DIR)
315
316dnl
317dnl  Check for wxwidgets
318dnl
319if test "$cross_compiling" = "yes"; then
320    echo "Cross compilation of the wx driver is not supported yet, wx will NOT be usable" >> ./CONF_INFO
321    WXERL_CAN_BUILD_DRIVER=false
322elif test  X"$MIXED_VC" = X"no"; then
323    WX_VERSION=`wx-config --version`
324    case $WX_VERSION in
325         2.8.*)
326		m4_include(wxwin-2.8.m4)
327		;;
328	 *)
329		m4_include(wxwin-2.9.m4)
330		;;
331    esac
332
333    AM_OPTIONS_WXCONFIG
334    reqwx=2.8.4
335    # Try to find debug libs first
336    # wxelibs=core,base,gl,aui,adv
337
338    AC_MSG_CHECKING(for debug build of wxWidgets)
339
340    AM_PATH_WXCONFIG($reqwx, wxWinWithGLDBG=1, wxWinWithGLDBG=0, [stc,xrc,html,adv,xml,core,base,gl,aui], [--unicode --debug=yes])
341    DEBUG_WX_CFLAGS=$WX_CFLAGS
342    DEBUG_WX_CXXFLAGS=$WX_CXXFLAGS
343    DEBUG_WX_LIBS=$WX_LIBS
344    DEBUG_WX_LIBS_STATIC=$WX_LIBS_STATIC
345    AC_SUBST(DEBUG_WX_CFLAGS)
346    AC_SUBST(DEBUG_WX_CXXFLAGS)
347    AC_SUBST(DEBUG_WX_LIBS)
348    AC_SUBST(DEBUG_WX_LIBS_STATIC)
349
350    AC_MSG_CHECKING(for standard build of wxWidgets)
351    AM_PATH_WXCONFIG($reqwx, wxWinWithGL=1, wxWinWithGL=0, [stc,xrc,html,adv,xml,core,base,gl,aui], [--unicode --debug=no])
352
353    if test "x$WX_LIBS_STATIC" = "x"; then
354       WX_HAVE_STATIC_LIBS=false
355    else
356       WX_HAVE_STATIC_LIBS=true
357    fi
358
359    wxWin=0
360
361    if test "$wxWinWithGLDBG" = 1; then
362        if test "$wxWinWithGL" = 1; then
363    	   wxWin=1
364	   FORCED_DEBUG_BUILD=false
365    	else
366    	   wxWin=1
367	   FORCED_DEBUG_BUILD=debug
368	   WX_CFLAGS=$DEBUG_WX_CFLAGS
369	   WX_CXXFLAGS=$DEBUG_WX_CXXFLAGS
370	   WX_LIBS=$DEBUG_WX_LIBS
371	   WX_LIBS_STATIC=$DEBUG_WX_LIBS_STATIC
372	fi
373    elif test "$wxWinWithGL" = 1; then
374    	wxWin=1
375	FORCED_DEBUG_BUILD=false
376    fi
377    AC_SUBST(FORCED_DEBUG_BUILD)
378    RC_FILE_TYPE=o
379define(wx_warn_text,[
380                wxWidgets must be installed on your system.
381
382		Please check that wx-config is in path, the directory
383		where wxWidgets libraries are installed (returned by
384		'wx-config --libs' or 'wx-config --static --libs' command)
385		is in LD_LIBRARY_PATH or equivalent variable and
386		wxWidgets version is $reqwx or above.])
387
388    if test "$wxWin" != 1; then
389       echo "wxWidgets not found, wx will NOT be usable" >> ./CONF_INFO
390       WXERL_CAN_BUILD_DRIVER=false
391       AC_MSG_WARN([wx_warn_text])
392    fi
393else
394    AC_MSG_CHECKING(for wxWidgets in standard locations)
395    echo
396    # Check whether --with-wxdir was given.
397    AC_MSG_NOTICE(OptionCheck: [$with_wxdir $with_wx_prefix])
398
399    if test "${with_wxdir+set}" = set; then :
400      withval=$with_wxdir;  CWXWIN0=$withval
401    else
402      # Check whether --with-wx-prefix was given.
403      if test "${with_wx_prefix+set}" = set; then :
404        withval=$with_wx_prefix; CWXWIN0=$withval
405      else
406        CWXWIN0=""
407      fi
408    fi
409
410    CWXWIN_CONFIG=`win32_path.sh -u $wx_config_name 2>/dev/null`
411    CWXWIN1=`dirname $CWXWIN_CONFIG 2>/dev/null`
412    CWXWIN2=`dirname $CWXWIN1 2>/dev/null`
413
414    if test -z "$PROGRAMFILES" ; then
415       PROGRAMFILES="c:/Program Files"
416    fi
417
418    CWXWIN_PROG=`win32_path.sh -u "$PROGRAMFILES" 2>/dev/null`
419
420    CWXWIN3="$CWXWIN_PROG/wxWidgets-3.*.* $CWXWIN_PROG/wxWidgets-2.*.*"
421    CWXWIN4="$CWXWIN_PROG/wxMSW-3.*.* $CWXWIN_PROG/wxMSW-2.*.*"
422
423    DOC_OPT1=/opt/local/pgm
424    DOC_OPT2=/mnt/c/opt/local/pgm
425    CWX_DOCUMENTED="$DOC_OPT1/wxWidgets-3.*.* $DOC_OPT1/wxMSW-3.*.*"
426    CWX_DOCUMENTED="$DOC_OPT2/wxWidgets-3.*.* $DOC_OPT2/wxMSW-3.*.* $CWX_DOCUMENTED"
427
428    case $ac_cv_sizeof_void_p in
429    	 8)
430		DOC_OPT64_1=/opt/local64/pgm
431		DOC_OPT64_2=/mnt/c/opt/local64/pgm
432		CWX_DOCUMENTED="$DOC_OPT64_1/wxWidgets-3.*.* $DOC_OPT64_1/wxMSW-3.*.* $CWX_DOCUMENTED"
433		CWX_DOCUMENTED="$DOC_OPT64_2/wxWidgets-3.*.* $DOC_OPT64_2/wxMSW-3.*.* $CWX_DOCUMENTED"
434		;;
435         *)
436		DOC_OPT3=/opt/local32/pgm
437		DOC_OPT4=/mnt/c/opt/local32/pgm
438		CWX_DOCUMENTED="$DOC_OPT3/wxWidgets-3.*.* $DOC_OPT3/wxMSW-3.*.* $CWX_DOCUMENTED"
439		CWX_DOCUMENTED="$DOC_OPT4/wxWidgets-3.*.* $DOC_OPT4/wxMSW-3.*.* $CWX_DOCUMENTED"
440		;;
441    esac
442
443    CWXPATH="$CWXWIN0 $CWXWIN1 $CWXWIN2 $CWX_DOCUMENTED $CWXWIN3 $CWXWIN4"
444
445    for dir in $CWXPATH; do
446        AC_MSG_NOTICE(Checking: [$dir])
447	if test -f $dir/include/wx/wx.h; then
448	    WXINCLUDE_MSVC=$dir/include/msvc
449	    WXINCLUDE_PLAIN=$dir/include
450	    WXINCLUDE_CONTRIB=$dir/contrib/include
451	    WX_CFLAGS="-EHsc -D_UNICODE -DUNICODE -I$WXINCLUDE_MSVC -I$WXINCLUDE_PLAIN -I$WXINCLUDE_CONTRIB -D__WXMSW__"
452	    WX_CXXFLAGS="-TP $WX_CFLAGS"
453	    WX_LIBDIR=$dir/lib/vc_lib
454	    WX_LIBDIR64=$dir/lib/vc_x64_lib
455	    WX_RESCOMP="rc.sh -I$WXINCLUDE_PLAIN -D __WIN32__"
456	    RC_FILE_TYPE=res
457	    for lib in $WX_LIBDIR $WX_LIBDIR64; do
458		maybe=`ls $lib/wxbase*.lib 2> /dev/null | egrep 'wxbase[[0-9]]*u\.lib'`
459		if test '!' -z "$maybe"; then
460		   corelib_number=`echo $maybe | sed 's,.*\([[0-9]].\)u\.lib,\1,'`
461		   WX_LIBDIR=$lib
462		   break
463		fi
464	    done
465	    if test '!' -z "$corelib_number"; then
466		WXLIBNO=$corelib_number
467		WX_LIBS0="wxmsw${WXLIBNO}u_stc wxmsw${WXLIBNO}u_xrc wxmsw${WXLIBNO}u_html"
468		WX_LIBS1="wxmsw${WXLIBNO}u_adv wxbase${WXLIBNO}u_xml wxmsw${WXLIBNO}u_core"
469		WX_LIBS2="wxbase${WXLIBNO}u wxmsw${WXLIBNO}u_gl wxmsw${WXLIBNO}u_aui"
470		WX_LIBS3="wxregexu wxexpat wxtiff wxjpeg wxpng wxzlib"
471		WX_SYSLIBS="winspool winmm oleaut32 ole32 gdiplus"
472		WX_LIBS_STATIC="-L$WX_LIBDIR"
473		for lib in $WX_LIBS0 $WX_LIBS1 $WX_LIBS2 $WX_LIBS3 $WX_SYSLIBS; do
474		   WX_LIBS_STATIC="$WX_LIBS_STATIC -l$lib"
475		done
476		AC_MSG_RESULT([$dir])
477		break
478	    fi
479	fi
480    done
481
482    if test -z "$WX_LIBS_STATIC"; then
483	AC_MSG_RESULT([failed])
484	echo "No usable wxWidgets not found, wx will not be useable" >> ./CONF_INFO
485	WXERL_CAN_BUILD_DRIVER=false
486	AC_MSG_WARN([Cannot find core lib version for wxWidgets])
487    fi
488    WX_HAVE_STATIC_LIBS=true
489    AC_SUBST(WX_CFLAGS)
490    AC_SUBST(WX_CXXFLAGS)
491    AC_SUBST(WX_LIBS_STATIC)
492    AC_SUBST(WX_RESCOMP)
493fi
494
495if test "$WXERL_CAN_BUILD_DRIVER" != "false"; then
496
497AC_SUBST(WX_HAVE_STATIC_LIBS)
498AC_SUBST(RC_FILE_TYPE)
499
500AC_MSG_CHECKING(for wxwidgets 2.8 compatibility )
501AC_LANG_PUSH(C++)
502saved_CXXFLAGS=$CXXFLAGS
503CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS"
504
505AC_COMPILE_IFELSE(
506 [AC_LANG_PROGRAM([[
507  #ifdef WIN32
508  # include <windows.h>
509  #endif
510  #include "wx/wx.h"
511  ]], [[
512  #if wxMAJOR_VERSION > 2 && WXWIN_COMPATIBILITY_2_8 == 1
513  ;
514  #else
515  #error barf
516  #endif
517  ]])],
518  HAVE_COMPAT28_SUPPORT=yes, HAVE_COMPAT28_SUPPORT=no)
519
520CXXFLAGS=$saved_CXXFLAGS
521AC_LANG_POP(C++)
522AC_MSG_RESULT($HAVE_COMPAT28_SUPPORT)
523
524if test X"$HAVE_COMPAT28_SUPPORT" != X"yes" ; then
525   echo "wxWidgets was not compiled with --enable-compat28, wx will NOT be useable" >> ./CONF_INFO
526   WXERL_CAN_BUILD_DRIVER=false
527fi
528
529AC_MSG_CHECKING(for wxwidgets opengl support)
530AC_LANG_PUSH(C++)
531saved_CXXFLAGS=$CXXFLAGS
532CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS"
533
534AC_COMPILE_IFELSE(
535 [AC_LANG_PROGRAM([[
536  #ifdef WIN32
537  # include <windows.h>
538  #endif
539  #include "wx/wx.h"
540  ]], [[
541  #if wxUSE_GLCANVAS
542  ;
543  #else
544  #error barf
545  #endif
546  ]])],
547[HAVE_GL_SUPPORT=yes
548 AC_DEFINE(HAVE_GL_SUPPORT, [1], [Define if wxwidgets have gl support])],
549 HAVE_GL_SUPPORT=no)
550
551CXXFLAGS=$saved_CXXFLAGS
552AC_LANG_POP(C++)
553AC_MSG_RESULT($HAVE_GL_SUPPORT)
554AC_SUBST(HAVE_GL_SUPPORT)
555
556if test X"$HAVE_GL_SUPPORT" != X"yes" ; then
557   echo "wxWidgets don't have gl support, wx will NOT be useable" >> ./CONF_INFO
558   WXERL_CAN_BUILD_DRIVER=false
559fi
560
561dnl Check for GLintptr
562dnl We define the types glext.h so we don't depend on glext.h is updated
563dnl to the latest version, but some systems defined them in gl.h
564dnl i.e Darwin and Solaris.
565
566AC_CHECK_TYPES([GLintptr, GLintptrARB, GLchar,
567                GLcharARB, GLhalfARB, GLint64EXT],
568	       [], [],
569	       [#ifdef WIN32
570		# include <windows.h>
571	        # include <gl/gl.h>
572	        #elif defined(HAVE_GL_GL_H)
573	        # include <GL/gl.h>
574                #elif defined(HAVE_OPENGL_GL_H)
575		# include <OpenGL/gl.h>
576		#endif
577		])
578
579dnl
580
581AC_MSG_CHECKING(GLU Callbacks uses Tiger Style)
582AC_LANG_PUSH(C++)
583saved_CXXFLAGS=$CXXFLAGS
584CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS"
585
586AC_TRY_COMPILE([
587                #ifdef WIN32
588		# include <windows.h>
589	        # include <gl/glu.h>
590	        #elif defined(HAVE_GL_GL_H)
591	        # include <GL/glu.h>
592                #elif defined(HAVE_OPENGL_GL_H)
593		# include <OpenGL/glu.h>
594		#endif
595		#ifndef CALLBACK
596		# define CALLBACK
597		#endif
598		void CALLBACK foo() {};
599	       ],
600		[
601		   GLUtesselator* tess;
602		   gluTessCallback(tess,GLU_TESS_VERTEX,(GLvoid (*)(...)) foo);
603		],
604		[TESS_CB_TIGER_STYLE=yes
605		 AC_DEFINE(TESS_CB_TIGER_STYLE, [1], [GLU Callbacks are Tiger style])],
606		TESS_CB_TIGER_STYLE=no)
607AC_MSG_RESULT($TESS_CB_TIGER_STYLE)
608AC_SUBST(TESS_CB_TIGER_STYLE)
609
610dnl
611dnl Check that we wx have stc (wxStyledTextControl) headers
612dnl
613
614AC_CHECK_HEADERS([wx/stc/stc.h],
615        [],
616    	[WXERL_CAN_BUILD_DRIVER=false
617	 echo "wxWidgets don't have wxStyledTextControl (stc.h), wx will NOT be useable" >> ./CONF_INFO
618     	 AC_MSG_WARN([Can not find wx/stc/stc.h $CXXFLAGS])
619     	],
620	[#ifdef WIN32
621	 # include <windows.h>
622         #endif
623         #include "wx/wx.h"])
624
625dnl
626dnl Check that we can link all the libraries
627dnl
628
629AC_MSG_CHECKING(if we can link wxwidgets programs)
630saved_LIBS=$LIBS
631
632if test X"$WX_HAVE_STATIC_LIBS" = X"true" ; then
633   LIBS=$WX_LIBS_STATIC
634fi
635
636AC_LINK_IFELSE([AC_LANG_SOURCE([
637		#ifdef WIN32
638		# include <windows.h>
639	        # include <gl/gl.h>
640	        #elif defined(HAVE_GL_GL_H)
641	        # include <GL/gl.h>
642                #elif defined(HAVE_OPENGL_GL_H)
643		# include <OpenGL/gl.h>
644		#endif
645                #include "wx/wx.h"
646		#include "wx/stc/stc.h"
647		#include "wx/glcanvas.h"
648		])
649
650		class MyApp : public wxApp
651		{
652		   virtual bool OnInit() {
653		   	   // Test that we have a FromUTF8
654			   // it isn't in too old wxWidgets versions
655		   	   wxString test = wxString::FromUTF8((const char *)"foo");
656		   	   wxStyledTextCtrl * foo = new wxStyledTextCtrl();
657		   	   wxGLCanvas * bar = new wxGLCanvas((wxWindow *) NULL, -1,
658			   	      wxDefaultPosition,wxDefaultSize,0);
659			   return true;
660                  };
661		};
662		IMPLEMENT_APP(MyApp)
663	       ],
664	       [
665		CAN_LINK_WX=yes
666	       ],
667	       [
668		CAN_LINK_WX=no
669	       ])
670
671CXXFLAGS=$saved_CXXFLAGS
672LIBS=$saved_LIBS
673AC_LANG_POP(C++)
674AC_MSG_RESULT($CAN_LINK_WX)
675
676if test X"$CAN_LINK_WX" != X"yes" ; then
677   echo "Can not link the wx driver, wx will NOT be useable" >> ./CONF_INFO
678   WXERL_CAN_BUILD_DRIVER=false
679   AC_MSG_WARN([Can not link wx program are all developer packages installed?])
680fi
681
682fi dnl - if test "$WXERL_CAN_BUILD_DRIVER" != "false"
683
684AC_SUBST(WXERL_CAN_BUILD_DRIVER)
685
686if test "x$GCC" = xyes; then
687    # Treat certain GCC warnings as errors
688    LM_TRY_ENABLE_CFLAG([-Werror=return-type], [CFLAGS])
689    LM_TRY_ENABLE_CFLAG([-Werror=return-type], [CXXFLAGS])
690fi
691
692dnl ----------------------------------------------------------------------
693dnl Enable -fsanitize= flags.
694dnl ----------------------------------------------------------------------
695
696m4_define(DEFAULT_SANITIZERS, [address,undefined])
697AC_ARG_ENABLE(
698    sanitizers,
699    AS_HELP_STRING(
700        [--enable-sanitizers@<:@=comma-separated list of sanitizers@:>@],
701	    [Default=DEFAULT_SANITIZERS]),
702[
703case "$enableval" in
704    no) sanitizers= ;;
705    yes) sanitizers="-fsanitize=DEFAULT_SANITIZERS" ;;
706    *) sanitizers="-fsanitize=$enableval" ;;
707esac
708CFLAGS="$CFLAGS $sanitizers"
709CXXFLAGS="$CXXFLAGS $sanitizers"
710LDFLAGS="$LDFLAGS $sanitizers"
711])
712
713#############################################################################
714
715dnl
716
717case $host_os in
718    mingw32|win32)
719	RUN_ERL=werl
720	SO_EXT=.dll;;
721    *)
722	RUN_ERL=erl
723	SO_EXT=.so;;
724esac
725
726AC_SUBST(SO_EXT)
727AC_SUBST(RUN_ERL)
728AC_SUBST(CXXNOOPTFLAGS)
729
730
731if test X"$WX_BUILDING_INSIDE_ERLSRC" != X"true" ; then
732    dnl  Find driver directory name according to erlang
733    WXERL_SYS_TYPE=`erl -noshell -eval 'io:format("~s~n",[[erlang:system_info(system_architecture)]])' -s erlang halt`
734else
735    WXERL_SYS_TYPE=$TARGET
736fi
737
738AC_SUBST(WXERL_SYS_TYPE)
739
740mkdir -p $WXERL_SYS_TYPE
741CONFIG_STATUS=$WXERL_SYS_TYPE/config.status
742
743dnl
744
745AC_CONFIG_FILES([
746	config.mk
747	c_src/Makefile
748        ])
749
750AC_OUTPUT
751
752CORES=`ls core* 2>/dev/null`
753if test X"$CORES" != X"" ; then
754   echo "Configure dumped core files" > ignore_core_files
755fi
756
757
758
759