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