Fix plugins with MSVC, thanks to Gulam Faruque.
[syx.git] / configure.ac
blob64246034fadac7689a976bca6255f2624b2ed63e
1 dnl configure.ac
2 dnl
3 dnl syx - Smalltalk YX programming language
4 dnl
6 dnl version info
7 m4_define([syx_version], [0.1.7])
9 dnl init autoconf
10 AC_INIT([syx], [syx_version], [lethalman88@gmail.com])
11 AC_PREREQ([2.59])
13 dnl set $target
14 AC_CANONICAL_TARGET
16 dnl init automake
17 AM_INIT_AUTOMAKE([syx], [syx_version()])
18 AM_CONFIG_HEADER(syx/syx-config.h)
19 AM_MAINTAINER_MODE
21 CFLAGS="$CFLAGS -Wall -Wno-strict-aliasing -DROOT_PATH=$datadir/syx -DIMAGE_PATH=$datadir/syx/default.sim -DPLUGIN_PATH=$libdir/syx"
23 dnl check for basic programs
24 AC_PROG_CC
25 AC_PROG_CC_STDC
26 AC_PROG_INSTALL
27 AC_PROG_LIBTOOL
28 PKG_PROG_PKG_CONFIG
30 dnl check for standard header files
31 AC_HEADER_STDC
33 AC_CHECK_HEADERS([string.h sys/stat.h time.h stdio.h assert.h fcntl.h],,
34                 AC_MSG_ERROR(cannot build Syx without $ac_header header))
35 AC_CHECK_HEADERS([stdarg.h byteswap.h errno.h unistd.h stdint.h sys/time.h])
37 AC_CHECK_FUNCS([strtol strtod],,
38                 AC_MSG_ERROR(cannot build Syx without $ac_func function))
39 AC_CHECK_FUNCS([fstat access getenv perror signal select])
41 AC_CHECK_TYPES(int64_t)
43 dnl check C Compiler characteristics
44 AC_C_INLINE
45 if test "$ac_cv_c_inline" != no; then
46    AC_DEFINE(HAVE_INLINE, 1, [Define to 1 if you have 'inline'.])
48 AC_C_BIGENDIAN
50 dnl target specific
52 native_win32=no 
54 case "$target" in 
55 *-darwin*) 
56         CFLAGS="$CFLAGS -no-cpp-precomp -fno-common"
57         ;;
58 *-wince*)
59         native_win32=yes
60         target_wince=yes
61         CFLAGS="$CFLAGS -DWINCE"
62         ;;
63 *-*-mingw*)
64         native_win32=yes
65         ;;
66 esac
68 AM_CONDITIONAL(WIN32, test "$native_win32" != no)
70 dnl default final output
71 build_gmp="no"
72 build_plugins="no"
73 build_gtk="no"
74 build_x11="no"
75 build_readline="no"
76 build_wingui="no"
78 dnl debug level
79 AC_MSG_CHECKING([the build debug level])
80 AC_ARG_ENABLE(debug,
81         AC_HELP_STRING([--enable-debug],
82                        [debug level (no, normal, info, full) [default=normal]]),
83                        [],[enable_debug="normal"])
84 AC_MSG_RESULT([$enable_debug])
86 dnl gmp support
87 AC_MSG_CHECKING([whether to build with big numbers support])
88 AC_ARG_WITH(gmp,
89         AC_HELP_STRING([--without-gmp],
90                        [do not support big numbers [default=yes]]),
91                        [],[with_gmp="yes"])
92 AC_MSG_RESULT([$with_gmp])
94 dnl plugins support
95 AC_MSG_CHECKING([whether to build with plugins support])
96 AC_ARG_WITH(plugins,
97         AC_HELP_STRING([--without-plugins],
98                        [do not support plugins [default=yes]]),
99                        [],[with_plugins="yes"])
100 AC_MSG_RESULT([$with_plugins])
102 dnl gprof profiling
103 AC_MSG_CHECKING([whether to compile and link with -pg])
104 AC_ARG_ENABLE(profile,
105         AC_HELP_STRING([--enable-profile],
106                        [compile and link with -pg [default=no]]),
107                        [],[enable_profile="no"])
108 AC_MSG_RESULT([$enable_profile])
110 dnl internal profiling
111 AC_MSG_CHECKING([whether to enable internal profiling])
112 AC_ARG_ENABLE(iprofile,
113         AC_HELP_STRING([--enable-iprofile],
114                        [enable internal profiling [default=no]]),
115                        [],[enable_iprofile="no"])
116 AC_MSG_RESULT([$enable_iprofile])
118 dnl gtk
119 AC_MSG_CHECKING([whether to build the GTK+ plugin])
120 AC_ARG_ENABLE(gtk,
121         AC_HELP_STRING([--disable-gtk],
122                        [enable build the GTK+ plugin [default=yes]]),
123                        [],[enable_gtk="yes"])
124 AC_MSG_RESULT([$enable_gtk])
126 dnl x11
127 AC_MSG_CHECKING([whether to build the X11 plugin])
128 AC_ARG_ENABLE(x11,
129         AC_HELP_STRING([--disable-x11],
130                        [enable build the X11 plugin [default=yes]]),
131                        [],[enable_x11="yes"])
132 AC_MSG_RESULT([$enable_x11])
134 dnl readline
135 AC_MSG_CHECKING([whether to build the Readline plugin])
136 AC_ARG_ENABLE(readline,
137         AC_HELP_STRING([--disable-readline],
138                        [enable build the Readline plugin [default=yes]]),
139                        [],[enable_readline="yes"])
140 AC_MSG_RESULT([$enable_readline])
142 dnl wingui
143 AC_MSG_CHECKING([whether to build the WinGui plugin])
144 AC_ARG_ENABLE(wingui,
145         AC_HELP_STRING([--enable-wingui],
146                        [enable build the WinGui plugin]),
147                        [],[enable_wingui=$native_win32])
148 AC_MSG_RESULT([$enable_wingui])
150 dnl check for debug level
151 case "$enable_debug" in
153    CFLAGS="$CFLAGS -O3"
154    ;;
155 normal)
156    CFLAGS="$CFLAGS -g -O2"
157    ;;
158 info)
159    CFLAGS="$CFLAGS -g3 -O -DSYX_DEBUG_INFO"
160    ;;
161 full)
162    CFLAGS="$CFLAGS -g3 -O -DSYX_DEBUG_INFO -DSYX_DEBUG_FULL"
163    ;;
164 esac
166 dnl win32 specific
167 if test "$native_win32" == yes; then
168    SYX_OTHER_CFLAGS="$SYX_OTHER_CFLAGS -DWINDOWS -D_DLL"
169    SYX_OTHER_LIBS="$SYX_OTHER_LIBS -lwsock32"
172 dnl check for profile
173 if test "$enable_profile" == yes; then
174    SYX_OTHER_CFLAGS="$SYX_OTHER_CFLAGS -pg"
175    SYX_OTHER_LIBS="$SYX_OTHER_LIBS -pg"
178 dnl check for internal profiling
179 if test "$enable_iprofile" == yes; then
180    CFLAGS="$CFLAGS -DSYX_PROFILE"
183 dnl check for math library
184 AC_CHECK_LIB(m, floor, [SYX_OTHER_LIBS="$SYX_OTHER_LIBS -lm"])
186 dnl check for gmp library
187 if test "$with_gmp" != no; then
188    AC_CACHE_CHECK(for mpz_init in -lgmp, syx_cv_gmp_libs, [
189      syx_cv_gmp_libs="-lgmp"
190      ac_save_LIBS="$LIBS"
191      LIBS="$LIBS $syx_cv_gmp_libs"
193      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
194             #include <stdio.h>
195             #include <gmp.h>
196         ]], [[
197             mpz_t z;
198             mpz_init (z);
199         ]])],, [syx_cv_gmp_libs="not found"])
200      LIBS="$ac_save_LIBS"
201    ])
203    if test "$syx_cv_gmp_libs" != "not found"; then
204       SYX_OTHER_LIBS="$SYX_OTHER_LIBS $syx_cv_gmp_libs"
205       AC_DEFINE(HAVE_LIBGMP, 1, [Define to 1 if you have the 'gmp' library (-lgmp).])
206       build_gmp="yes"
207    else
208       build_gmp="no"
209    fi
212 dnl check for plugins
213 if test "$with_plugins" != no; then
214    AC_CHECK_LIB(dl, dlopen, [
215                 AC_DEFINE(HAVE_LIBDL, 1, [Define to 1 if you have the 'ltdl' library (-ldl).])
216                 SYX_OTHER_LIBS="$SYX_OTHER_LIBS -ldl"
217                 SYX_OTHER_CFLAGS="$SYX_OTHER_CFLAGS -DWITH_PLUGINS"
218                 build_plugins="yes"], [build_plugins="no"])
221 AC_SUBST(SYX_OTHER_CFLAGS)
222 AC_SUBST(SYX_OTHER_LIBS)
224 dnl set syx/st/kernel dir
225 stkerneldatadir="$datadir/syx/st/kernel"
226 AC_SUBST(stkerneldatadir)
228 dnl set syx/st/foreign dir
229 stforeigndatadir="$datadir/syx/st/foreign"
230 AC_SUBST(stforeigndatadir)
232 dnl stuff to go in the syx-config.h file
233 AH_TOP(
234 [#ifndef SYX_CONFIG_H
235 #define SYX_CONFIG_H])
236 AH_BOTTOM(
237 [#endif /* SYX_CONFIG_H */])
239 AC_CONFIG_FILES([
240 syx.pc
241 Makefile
242 syx/Makefile
243 src/Makefile
244 share/Makefile
245 doc/Makefile
246 examples/Makefile
247 examples/basic/Makefile
248 examples/console/Makefile
249 examples/embedding/Makefile
250 examples/web/Makefile
251 examples/gtk/Makefile
252 examples/x11/Makefile
253 tests/Makefile
256 plugin_subdirs=
258 if test "$build_plugins" == yes; then
260    dnl enable gtk
261    if test "$enable_gtk" != no; then
262       PKG_CHECK_MODULES([GTK_DEP],
263                      [gthread-2.0 >= 2.12.0
264                       gtk+-2.0 >= 2.12.0],
265                      [build_gtk="yes"
266                       plugin_subdirs="$plugin_subdirs gtk"
267                       AC_CONFIG_FILES([plugins/gtk/Makefile])
268                       stgtkdatadir="$datadir/syx/st/gtk"
269                       AC_SUBST(stgtkdatadir)])
270    fi
272    dnl enable readline
273    if test "$enable_readline" != no; then
274       AC_CHECK_LIB([readline], [add_history],
275                 [build_readline="yes"
276                  READLINE_DEP_LIBS="-lreadline"
277                  AC_SUBST([READLINE_DEP_LIBS])
278                  plugin_subdirs="$plugin_subdirs readline"
279                  AC_CONFIG_FILES([plugins/readline/Makefile])
280                  streadlinedatadir="$datadir/syx/st/readline"
281                  AC_SUBST(streadlinedatadir)])
282    fi
284    dnl enable x11
285    if test "$enable_x11" != no; then
286       AC_CHECK_LIB([X11], [XOpenDisplay],
287                      [build_x11="yes"
288                       X11_DEP_LIBS="-lX11"
289                       AC_SUBST([X11_DEP_LIBS])
290                       plugin_subdirs="$plugin_subdirs x11"
291                       AC_CONFIG_FILES([plugins/x11/Makefile])
292                       stx11datadir="$datadir/syx/st/x11"
293                       AC_SUBST(stx11datadir)])
294    fi
296    dnl enable wingui
297    if test "$enable_wingui" != no; then
298       if test "$target_wince" == yes; then
299             AC_CHECK_LIB([commctrl], [MessageBox],
300                 [build_wingui="yes"])
301       else
302          build_wingui="yes"
303       fi
305       if test "$build_wingui" == yes; then
306             WINGUI_DEP_LIBS="-lcommctrl"
307             AC_SUBST([WINGUI_DEP_LIBS])
308             plugin_subdirs="$plugin_subdirs wingui"
309             AC_CONFIG_FILES([plugins/wingui/Makefile])
310             stwinguidatadir="$datadir/syx/st/wingui"
311             AC_SUBST(stwinguidatadir)
312       fi
313    fi
316 AC_CONFIG_FILES([plugins/Makefile])
318 AC_SUBST(plugin_subdirs)
320 plugindir="$libdir/syx"
321 AC_SUBST(plugindir)
323 AC_OUTPUT
325 echo "
326 Smalltalk YX was configured with the following options:
328  Debug level              : $enable_debug
329  Big numbers support      : $build_gmp
330  Plugins support          : $build_plugins
333 if test "$build_plugins" == "yes"; then
334 echo "
335 The following plugins will be built:
337  GTK+                     : $build_gtk
338  Readline                 : $build_readline
339  X11                      : $build_x11
340  WinGui                   : $build_wingui