1dnl // Process this file with autoconf to produce a configure script.
2
3AC_PREREQ(2.50)
4AC_INIT(bochs.h)
5AC_REVISION([[$Id: configure.in 14330 2021-08-01 08:07:38Z vruppert $]])
6AC_CONFIG_HEADER(config.h)
7AC_CONFIG_HEADER(ltdlconf.h)
8
9dnl // Put Bochs version information right here so that it gets substituted
10dnl // into all the right places.
11VERSION="2.7"
12VER_MAJOR=2
13VER_MINOR=7
14dnl // this should be > 90 for pre-release of next version otherwise revision level
15VER_REVISION=0
16dnl // this should be 0 for release and 1 for svn version
17VER_SVN=0
18REL_STRING="Built from SVN snapshot on August  1, 2021"
19REL_TIMESTAMP=`grep "Updated:" $srcdir/README | sed 's/Updated: //'`
20
21changequote(<<, >>)
22changequote([, ])
23
24dnl Detect host and target
25AC_CANONICAL_HOST
26AC_CANONICAL_TARGET
27
28AC_MSG_CHECKING(if you are configuring for another platform)
29if test "$cross_compiling" = yes -o "$target_os" = "windows"; then
30  AC_MSG_RESULT(yes)
31  cross_configure=1
32else
33  AC_MSG_RESULT(no)
34  cross_configure=0
35fi
36
37# this case statement defines the compile flags which are needed to
38# compile bochs on a platform.  Don't put things like optimization settings
39# into the configure.in file, since people will want to be able to change
40# those settings by defining CFLAGS and CXXFLAGS before running configure.
41NO_LT=0
42MSVC_TARGET=0
43need_dlcompat_for_plugins=0
44case "$target" in
45  *-pc-windows* | *-pc-winnt*)
46    DEFAULT_GUI=win32 # default to win32 gui
47    NO_LT=1           # do not use libtool at all
48    case "$target" in
49      x86_64*)
50        MSVC_TARGET=64
51        AC_DEFINE(MSVC_TARGET, 64)
52        ;;
53      *)
54        MSVC_TARGET=32
55        AC_DEFINE(MSVC_TARGET, 32)
56        ;;
57    esac
58    ;;
59  *-cygwin* | *-mingw32* | *-msys)
60    NO_LT=1   # do not use libtool at all
61    if test "$with_term" = yes; then
62      # ncurses won't compile with -DWIN32
63      # also, I can't get it to link without this -DBROKEN_LINKER=1 hack.
64      # see /usr/include/curses.h for details.
65      ADD_FLAGS="-DBROKEN_LINKER=1"
66    else
67      # default case
68      ADD_FLAGS="-DWIN32"   # required for cygwin/mingw/msys compile+win32 gui
69      DEFAULT_GUI=win32     # default to win32 gui
70    fi
71    ;;
72  *-macosx* | *-darwin*)
73    ADD_FLAGS="-fpascal-strings -fno-common -Wno-four-char-constants -Wno-unknown-pragmas -Dmacintosh"      # required for macosx compile
74    DEFAULT_GUI=carbon                # default to carbon
75    need_dlcompat_for_plugins=1
76    ;;
77  *-macos*)
78    DEFAULT_GUI=macos                 # macos defaults to macos
79    ;;
80  *-amigaos* | *-morphos*)
81    DEFAULT_GUI=amigaos               # amigaos or morphos defaults to amigaos gui
82    ;;
83  *-solaris*)
84    ADD_FLAGS="-D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__"      # required for correct function prototypes
85    LIBS="$LIBS -lsocket -lnsl"
86    DEFAULT_GUI=x11
87    ;;
88  *)
89    DEFAULT_GUI=x11
90    ;;
91esac
92if test "${ADD_FLAGS:+set}" = set; then
93      CFLAGS="$CFLAGS $ADD_FLAGS"
94      CXXFLAGS="$CXXFLAGS $ADD_FLAGS"
95      CPPFLAGS="$CPPFLAGS $ADD_FLAGS"
96fi
97
98case "$target" in
99  x86_64*)
100    BOCHS_BITS=64
101    ;;
102  *)
103    BOCHS_BITS=32
104    ;;
105esac
106
107AC_MSG_CHECKING(for standard CFLAGS on this platform)
108AC_MSG_RESULT($ADD_FLAGS)
109
110dnl // make sure the default gui is enabled if no other chosen
111if (test "$with_sdl" != yes) && \
112   (test "$with_sdl2" != yes) && \
113   (test "$with_x11" != yes) && \
114   (test "$with_win32" != yes) && \
115   (test "$with_nogui" != yes) && \
116   (test "$with_term" != yes) && \
117   (test "$with_rfb" != yes) && \
118   (test "$with_vncsrv" != yes) && \
119   (test "$with_amigaos" != yes) && \
120   (test "$with_carbon" != yes) && \
121   (test "$with_wx" != yes) && \
122   (test "$with_macos" != yes); then
123  # use DEFAULT_GUI.  Set the appropriate variable.
124  # DEFAULT_GUI must be set to one of the names above.  Otherwise, no
125  # valid $with_* variable will be set and who knows what will happen?
126  eval "with_${DEFAULT_GUI}=yes"
127fi
128
129AC_PROG_CC
130AC_PROG_CXX
131AC_PROG_MAKE_SET
132
133if test "$NO_LT" != 1; then
134  dnl------------ libtool configuration
135  dnl Configure libtool, and default to shared libraries.  Libtool will only be
136  dnl used for compiling and linking plugins.
137  AC_DISABLE_STATIC
138  dnl Check for dlopen support
139  AC_LIBTOOL_DLOPEN
140  dnl Configure libtool
141  AC_PROG_LIBTOOL
142  dnl Configure the ltdl library.  This must go after AC_PROG_LIBTOOL or
143  dnl else it disables shared libraries somehow.
144  AC_LIB_LTDL
145else
146  RANLIB="echo"
147fi
148
149AC_PATH_PROG(PKGCONFIG, pkg-config, not_found)
150if test "$PKGCONFIG" = not_found; then
151  AC_PATH_XTRA
152fi
153
154AC_C_BIGENDIAN
155AC_CHECK_SIZEOF(unsigned char)
156AC_CHECK_SIZEOF(unsigned short)
157AC_CHECK_SIZEOF(unsigned int)
158AC_CHECK_SIZEOF(unsigned long)
159AC_CHECK_SIZEOF(unsigned long long)
160if test "$MSVC_TARGET" = 0; then
161  AC_CHECK_SIZEOF(int *)
162fi
163AC_CHECK_FUNCS(getenv, AC_DEFINE(BX_HAVE_GETENV))
164AC_CHECK_FUNCS(setenv, AC_DEFINE(BX_HAVE_SETENV))
165AC_CHECK_FUNCS(snprintf, AC_DEFINE(BX_HAVE_SNPRINTF))
166AC_CHECK_FUNCS(vsnprintf, AC_DEFINE(BX_HAVE_VSNPRINTF))
167
168if test "$MSVC_TARGET" = 0; then
169  AC_CHECK_FUNCS(select, AC_DEFINE(BX_HAVE_SELECT))
170  AC_CHECK_TYPE(socklen_t, AC_DEFINE(BX_HAVE_SOCKLEN_T), , [#include <sys/types.h>
171  #include <sys/socket.h>])
172  AC_CHECK_FUNCS(strtoull, AC_DEFINE(BX_HAVE_STRTOULL))
173  AC_CHECK_FUNCS(strtouq, AC_DEFINE(BX_HAVE_STRTOUQ))
174  AC_CHECK_FUNCS(strdup, AC_DEFINE(BX_HAVE_STRDUP))
175  AC_CHECK_FUNCS(strrev, AC_DEFINE(BX_HAVE_STRREV))
176  AC_CHECK_FUNCS(stricmp, AC_DEFINE(BX_HAVE_STRICMP))
177  AC_CHECK_FUNCS(strcasecmp, AC_DEFINE(BX_HAVE_STRCASECMP))
178  AC_CHECK_FUNCS(mkstemp, AC_DEFINE(BX_HAVE_MKSTEMP))
179  AC_CHECK_HEADER(sys/mman.h, AC_DEFINE(BX_HAVE_SYS_MMAN_H))
180  AC_CHECK_FUNCS(gettimeofday, AC_DEFINE(BX_HAVE_GETTIMEOFDAY))
181  AC_CHECK_FUNCS(usleep, AC_DEFINE(BX_HAVE_USLEEP))
182
183  AC_MSG_CHECKING(for __builtin_bswap32)
184  AC_TRY_LINK([],[
185    __builtin_bswap32(0x12345678);
186  ],[
187    AC_DEFINE(BX_HAVE___BUILTIN_BSWAP32, 1, [Define to 1 if you have the '__builtin_bswap32' function.])
188    AC_MSG_RESULT(yes)
189  ],[
190    AC_MSG_RESULT(no)
191  ])
192  AC_MSG_CHECKING(for __builtin_bswap64)
193  AC_TRY_LINK([],[
194    __builtin_bswap64(0x12345678);
195  ],[
196    AC_DEFINE(BX_HAVE___BUILTIN_BSWAP64, 1, [Define to 1 if you have the '__builtin_bswap64' function.])
197    AC_MSG_RESULT(yes)
198  ],[
199    AC_MSG_RESULT(no)
200  ])
201  AC_CHECK_FUNCS(tmpfile64, AC_DEFINE(BX_HAVE_TMPFILE64))
202  AC_CHECK_FUNCS(fseek64, AC_DEFINE(BX_HAVE_FSEEK64))
203  AC_CHECK_FUNCS(fseeko64, AC_DEFINE(BX_HAVE_FSEEKO64))
204  AC_CHECK_TYPE(ssize_t, AC_DEFINE(BX_HAVE_SSIZE_T), , [#include <sys/types.h>])
205else
206  AC_DEFINE(BX_HAVE_SELECT, 1)
207  AC_DEFINE(BX_HAVE_SOCKLEN_T, 0)
208  AC_DEFINE(BX_HAVE_STRTOULL, 1)
209  AC_DEFINE(BX_HAVE_STRTOUQ, 0)
210  AC_DEFINE(BX_HAVE_STRDUP, 1)
211  AC_DEFINE(BX_HAVE_STRREV, 1)
212  AC_DEFINE(BX_HAVE_STRICMP, 1)
213  AC_DEFINE(BX_HAVE_STRCASECMP, 0)
214  AC_DEFINE(BX_HAVE_MKSTEMP, 0)
215  AC_DEFINE(BX_HAVE_SYS_MMAN_H, 0)
216  AC_DEFINE(BX_HAVE_GETTIMEOFDAY, 0)
217  AC_DEFINE(BX_HAVE_USLEEP, 0)
218  AC_DEFINE(BX_HAVE___BUILTIN_BSWAP32, 0)
219  AC_DEFINE(BX_HAVE___BUILTIN_BSWAP64, 0)
220  AC_DEFINE(BX_HAVE_TMPFILE64, 0)
221  AC_DEFINE(BX_HAVE_FSEEK64, 0)
222  AC_DEFINE(BX_HAVE_FSEEKO64, 0)
223  AC_DEFINE(BX_HAVE_SSIZE_T, 0)
224  AC_DEFINE(BX_HAVE_SETENV, 0)
225  if test "$MSVC_TARGET" = 64; then
226    AC_DEFINE(SIZEOF_INT_P, 8)
227  else
228    AC_DEFINE(SIZEOF_INT_P, 4)
229  fi
230fi
231AC_CHECK_FUNCS(sleep, AC_DEFINE(BX_HAVE_SLEEP))
232AC_CHECK_FUNCS(nanosleep, AC_DEFINE(BX_HAVE_NANOSLEEP))
233AC_CHECK_FUNCS(abort, AC_DEFINE(BX_HAVE_ABORT))
234AC_CHECK_MEMBER(struct sockaddr_in.sin_len, AC_DEFINE(BX_HAVE_SOCKADDR_IN_SIN_LEN), , [#include <sys/socket.h>
235#include <netinet/in.h> ])
236AC_CHECK_FUNCS(timelocal, AC_DEFINE(BX_HAVE_TIMELOCAL))
237AC_CHECK_FUNCS(gmtime, AC_DEFINE(BX_HAVE_GMTIME))
238AC_CHECK_FUNCS(mktime, AC_DEFINE(BX_HAVE_MKTIME))
239
240dnl As of autoconf 2.53, the standard largefile test fails for Linux/gcc.
241dnl It does not put the largefiles arguments into CFLAGS, even though Linux/gcc
242dnl does need them.  So we do it ourselves.
243AC_SYS_LARGEFILE
244
245dnl we need to define _FILE_OFFSET_BITS or _LARGE_FILES on the compiler command
246dnl line because otherwise the system headers risk being included before
247dnl config.h which defines these constants leading to inconsistent
248dnl sizeof(off_t) in different source files of the same program and linking
249dnl problems
250case "x$ac_cv_sys_file_offset_bits" in #(
251  xno | xunknown) ;;
252  *)
253    if test "x$ac_cv_sys_file_offset_bits" = "x64"; then
254        BX_LARGEFILE_FLAGS="-D_FILE_OFFSET_BITS=64 -D_LARGE_FILES"
255    else
256        BX_LARGEFILE_FLAGS="-D_LARGE_FILES"
257    fi
258    CPPFLAGS="$CPPFLAGS $BX_LARGEFILE_FLAGS"
259    CFLAGS="$CFLAGS $BX_LARGEFILE_FLAGS"
260    CXXFLAGS="$CXXFLAGS $BX_LARGEFILE_FLAGS"
261    ;;
262esac
263dnl ---end of largefile tests
264
265AC_MSG_CHECKING(if compiler allows __attribute__)
266AC_TRY_COMPILE([], [typedef struct { } __attribute__ ((packed)) junk;],
267    AC_MSG_RESULT(yes),
268    [
269      AC_MSG_RESULT(no)
270      AC_DEFINE(BX_NO_ATTRIBUTES)
271    ])
272
273AC_LANG_SAVE
274AC_LANG_CPLUSPLUS
275AC_MSG_CHECKING(for set)
276AC_TRY_COMPILE([#include <set>], [],
277   [
278     AC_MSG_RESULT(yes)
279     AC_DEFINE(BX_HAVE_SET)
280   ], AC_MSG_RESULT(no))
281AC_MSG_CHECKING(for set.h)
282AC_TRY_COMPILE([#include <set.h>], [],
283   [
284     AC_MSG_RESULT(yes)
285     AC_DEFINE(BX_HAVE_SET_H)
286   ], AC_MSG_RESULT(no))
287AC_MSG_CHECKING(for map)
288AC_TRY_COMPILE([#include <map>], [],
289   [
290     AC_MSG_RESULT(yes)
291     AC_DEFINE(BX_HAVE_MAP)
292   ], AC_MSG_RESULT(no))
293AC_MSG_CHECKING(for map.h)
294AC_TRY_COMPILE([#include <map.h>], [],
295   [
296     AC_MSG_RESULT(yes)
297     AC_DEFINE(BX_HAVE_MAP_H)
298   ], AC_MSG_RESULT(no))
299AC_LANG_RESTORE
300
301dnl Implement a check for each gui library to see if has a chance of compiling.
302if test "$with_all_libs" = yes; then
303  if test "$cross_configure" = 1; then
304    AC_MSG_WARN([[Using --with-all-libs while cross configuring is very unlikely to be what you want.  You should specify the --with-* args yourself.]])
305  fi
306
307  if test "$with_amigaos" != yes; then
308    can_compile_amigaos=1
309    AC_CHECK_HEADER([proto/intuition.h], [], [ can_compile_amigaos=0 ])
310    AC_CHECK_HEADER([intuition/intuitionbase.h], [], [ can_compile_amigaos=0 ])
311    AC_CHECK_HEADER([cybergraphx/cybergraphics.h], [], [ can_compile_amigaos=0 ])
312    AC_CHECK_HEADER([devices/trackdisk.h], [], [ can_compile_amigaos=0 ])
313    if test $can_compile_amigaos = 1; then
314      with_amigaos=yes
315    fi
316  fi
317
318  if test "$with_carbon" != yes; then
319    can_compile_carbon=1
320    AC_CHECK_HEADER([Carbon.h], [], [ can_compile_carbon=0 ])
321    AC_CHECK_HEADER([ApplicationServices/ApplicationServices.h], [], [ can_compile_carbon=0 ])
322    if test $can_compile_carbon = 1; then
323      with_carbon=yes
324    fi
325  fi
326
327  if test "$with_win32" != yes; then
328    can_compile_win32=1
329    AC_CHECK_HEADER([windows.h], [], [ can_compile_win32=0 ])
330    AC_CHECK_HEADER([commctrl.h], [], [ can_compile_win32=0 ])
331    if test $can_compile_win32 = 1; then
332      with_win32=yes
333    fi
334  fi
335
336  if test "$with_sdl" != yes -a "$with_sdl2" != yes; then
337    can_compile_sdl=2
338    AC_CHECK_HEADER([SDL2/SDL.h], [], [ can_compile_sdl=0 ])
339    AC_CHECK_HEADER([SDL2/SDL_main.h], [], [ can_compile_sdl=0 ])
340    if test $can_compile_sdl != 2; then
341      can_compile_sdl=1
342      AC_CHECK_HEADER([SDL/SDL.h], [], [ can_compile_sdl=0 ])
343      AC_CHECK_HEADER([SDL/SDL_main.h], [], [ can_compile_sdl=0 ])
344      if test $can_compile_sdl = 1; then
345        with_sdl=yes
346      fi
347    else
348      with_sdl2=yes
349    fi
350  fi
351
352  if test "$with_x11" != yes; then
353    can_compile_x11=1
354    AC_CHECK_HEADER([X11/Xlib.h], [], [ can_compile_x11=0 ])
355    AC_CHECK_HEADER([X11/Xutil.h], [], [ can_compile_x11=0 ])
356    if test $can_compile_x11 = 1; then
357      with_x11=yes
358    fi
359  fi
360
361  if test "$with_rfb" != yes; then
362    can_compile_rfb=1
363    case $target in
364      *-pc-windows* | *-pc-winnt* | *-cygwin* | *-mingw32* | *-msys)
365	AC_CHECK_HEADER([winsock2.h], [], [ can_compile_rfb=0 ])
366	AC_CHECK_HEADER([process.h], [], [ can_compile_rfb=0 ])
367        ;;
368      *)
369	AC_CHECK_HEADER([sys/socket.h], [], [ can_compile_rfb=0 ])
370	AC_CHECK_HEADER([netinet/tcp.h], [], [ can_compile_rfb=0 ])
371	AC_CHECK_HEADER([pthread.h], [], [ can_compile_rfb=0 ])
372	;;
373    esac
374    if test $can_compile_rfb = 1; then
375      with_rfb=yes
376    fi
377  fi
378
379  if test "$with_vncsrv" != yes; then
380    can_compile_vncsrv=1
381    case $target in
382      *-pc-windows* | *-pc-winnt*)
383        can_compile_vncsrv=0
384        ;;
385      *-cygwin* | *-mingw32* | *-msys)
386        AC_CHECK_HEADER([rfb/rfb.h], [], [ can_compile_vncsrv=0 ])
387        ;;
388      *)
389        AC_CHECK_HEADER([rfb/rfb.h], [], [ can_compile_vncsrv=0 ])
390        AC_CHECK_HEADER([pthread.h], [], [ can_compile_vncsrv=0 ])
391        ;;
392    esac
393    if test $can_compile_vncsrv = 1; then
394      with_vncsrv=yes
395    fi
396  fi
397
398  if test "$with_term" != yes; then
399    can_compile_term=1
400    AC_CHECK_HEADER([curses.h], [], [ can_compile_term=0 ])
401    AC_CHECK_HEADER([signal.h], [], [ can_compile_term=0 ])
402    if test $can_compile_term = 1; then
403      with_term=yes
404    fi
405  fi
406
407  if test "$with_nogui" != yes; then
408    with_nogui=yes
409  fi
410fi    # end of if $with_all_libs = yes
411
412if test "$with_sdl" = yes -a "$with_sdl2" = yes; then
413  AC_MSG_ERROR([[--with-sdl and --with-sdl2 are mutually exclusive]])
414fi
415
416AC_MSG_CHECKING(for idle hack)
417AC_ARG_ENABLE(idle-hack,
418  AS_HELP_STRING([--enable-idle-hack], [use Roland Mainz's idle hack (no)]),
419  [if test "$enableval" = yes; then
420    AC_MSG_RESULT(yes)
421    AC_DEFINE(BX_USE_IDLE_HACK, 1)
422   else
423    AC_MSG_RESULT(no)
424    AC_DEFINE(BX_USE_IDLE_HACK, 0)
425   fi],
426  [
427    AC_MSG_RESULT(no)
428    AC_DEFINE(BX_USE_IDLE_HACK, 0)
429    ]
430  )
431AC_SUBST(BX_USE_IDLE_HACK)
432
433AC_CHECK_HEADER(dlfcn.h, AC_DEFINE(BX_HAVE_DLFCN_H, 1))
434AC_CHECK_HEADER(assert.h, AC_DEFINE(HAVE_ASSERT_H, 1))
435
436AC_MSG_CHECKING(for plugins support)
437AC_ARG_ENABLE(plugins,
438  AS_HELP_STRING([--enable-plugins], [enable plugin support (no)]),
439  [if test "$enableval" = yes; then
440     bx_plugins=1
441   else
442     bx_plugins=0
443   fi],
444  [
445    bx_plugins=0
446    ]
447  )
448
449USER_PLUGINS_MAKEFILE=''
450if test "$bx_plugins" = 1; then
451  AC_MSG_RESULT(yes)
452  AC_DEFINE(BX_PLUGINS, 1)
453  GUI_NON_PLUGIN_OBJS='$(OBJS_THAT_CANNOT_BE_PLUGINS)'
454  GUI_PLUGIN_OBJS='$(OBJS_THAT_CAN_BE_PLUGINS)'
455  DEFINE_PLUGIN_PATH='-DBX_PLUGIN_PATH="\"${plugdir}\""'
456  # and the $(OBJS_THAT_SUPPORT_OTHER_PLUGINS) will be built and linked
457  if test "$NO_LT" != 1; then
458    # by special link rules for the plugins that they support.
459    LIBS="$LIBS $LIBADD_DL"
460    have_ltdl=0
461    AC_CHECK_HEADER(ltdl.h, [AC_CHECK_LIB(ltdl, lt_dlinit, [have_ltdl=1]]))
462    if test "$have_ltdl" = 1; then
463      PLUGIN_LIB="-lltdl"
464      AC_DEFINE(BX_HAVE_LTDL,1)
465    else
466      PLUGIN_VAR="ltdl.o"
467      PLUGIN_LIB="ltdl.o"
468    fi
469  fi
470  PLUGIN_TARGET=bochs_plugins
471  PLUGIN_TARGET_2=plugins_gcc
472  INSTALL_PLUGINS_VAR=install_libtool_plugins
473  NONPLUGIN_GUI_LINK_OPTS=''
474  if test -d user_plugins; then
475    USER_PLUGINS_MAKEFILE='user_plugins/Makefile'
476  fi
477else
478  AC_MSG_RESULT(no)
479  bx_plugins=0
480  AC_DEFINE(BX_PLUGINS, 0)
481  GUI_NON_PLUGIN_OBJS='$(OBJS_THAT_CANNOT_BE_PLUGINS) $(OBJS_THAT_CAN_BE_PLUGINS) $(OBJS_THAT_SUPPORT_OTHER_PLUGINS)'
482  GUI_PLUGIN_OBJS=''
483  NONPLUGIN_GUI_LINK_OPTS='$(GUI_LINK_OPTS)'
484fi
485AC_SUBST(DEFINE_PLUGIN_PATH)
486
487# copy gui variables into iodev variables.  Later, we will add to the gui
488# objs list, according to which display libraries are enabled.
489IODEV_NON_PLUGIN_OBJS=$GUI_NON_PLUGIN_OBJS
490IODEV_PLUGIN_OBJS=$GUI_PLUGIN_OBJS
491IODEV_EXT_NON_PLUGIN_OBJS=$GUI_NON_PLUGIN_OBJS
492IODEV_EXT_PLUGIN_OBJS=$GUI_PLUGIN_OBJS
493
494# on MacOSX if they enabled plugins, make sure that dlopen() was found.
495# It is provided by a library called dlcompat.
496if test "$bx_plugins" = 1 -a "$need_dlcompat_for_plugins" = 1; then
497  have_dlopen=0
498  AC_CHECK_LIB(dl, dlopen, [have_dlopen=1])
499  AC_MSG_CHECKING(if you have dlcompat, required for MacOSX plugins)
500  if test "$have_dlopen" = 0; then
501    AC_MSG_RESULT(no)
502    AC_MSG_ERROR([To use plugins on MacOSX you must use a library called dlcompat.  The configure script was not able to find dlcompat.  If it is already installed then you must set up your environment variables to point to it, as is done in .conf.macosx.  If you cannot resolve this, you should turn off plugins.])
503  else
504    AC_MSG_RESULT(yes)
505  fi
506fi
507
508AC_MSG_CHECKING(if compiler allows LL for 64-bit constants)
509AC_TRY_COMPILE([], [ { 42LL; } ],
510    AC_MSG_RESULT(yes),
511    [
512      AC_MSG_RESULT(no)
513      AC_DEFINE(BX_64BIT_CONSTANTS_USE_LL, 0)
514    ])
515
516AC_MSG_CHECKING(for A20 support)
517AC_ARG_ENABLE(a20-pin,
518  AS_HELP_STRING([--enable-a20-pin], [compile in support for A20 pin (yes)]),
519  [if test "$enableval" = yes; then
520    AC_MSG_RESULT(yes)
521    AC_DEFINE(BX_SUPPORT_A20, 1)
522   else
523    AC_MSG_RESULT(no)
524    AC_DEFINE(BX_SUPPORT_A20, 0)
525   fi
526   ],
527  [
528    AC_MSG_RESULT(yes)
529    AC_DEFINE(BX_SUPPORT_A20, 1)
530    ]
531  )
532
533use_x86_64=0
534AC_MSG_CHECKING(for x86-64 support)
535AC_ARG_ENABLE(x86-64,
536  AS_HELP_STRING([--enable-x86-64], [compile in support for x86-64 instructions (no)]),
537  [if test "$enableval" = yes; then
538    AC_MSG_RESULT(yes)
539    OBJS64='$(OBJS64)'
540    AC_DEFINE(BX_SUPPORT_X86_64, 1)
541    use_x86_64=1
542   else
543    AC_MSG_RESULT(no)
544    OBJS64=''
545    AC_DEFINE(BX_SUPPORT_X86_64, 0)
546   fi
547   ],
548  [
549    AC_MSG_RESULT(no)
550    OBJS64=''
551    AC_DEFINE(BX_SUPPORT_X86_64, 0)
552    ]
553  )
554AC_SUBST(OBJS64)
555
556use_smp=0
557AC_MSG_CHECKING(for SMP support)
558AC_ARG_ENABLE(smp,
559  AS_HELP_STRING([--enable-smp], [compile in support for SMP configurations (no)]),
560  [if test "$enableval" = yes; then
561    AC_MSG_RESULT(yes)
562    AC_DEFINE(BX_SUPPORT_SMP, 1)
563    AC_DEFINE(BX_USE_CPU_SMF, 0)
564    use_smp=1
565   else
566    AC_MSG_RESULT(no)
567    AC_DEFINE(BX_SUPPORT_SMP, 0)
568   fi
569   ],
570  [
571    AC_MSG_RESULT(no)
572    AC_DEFINE(BX_SUPPORT_SMP, 0)
573    ]
574  )
575
576AC_MSG_CHECKING(for cpu level)
577AC_ARG_ENABLE(cpu-level,
578  AS_HELP_STRING([--enable-cpu-level], [select cpu level (3,4,5,6 - default is 6)]),
579  [case "$enableval" in
580     3)
581       AC_MSG_RESULT(3)
582       AC_DEFINE(BX_CPU_LEVEL, 3)
583       ;;
584     4)
585       AC_MSG_RESULT(4)
586       AC_DEFINE(BX_CPU_LEVEL, 4)
587       ;;
588     5)
589       AC_MSG_RESULT(5)
590       AC_DEFINE(BX_CPU_LEVEL, 5)
591       ;;
592     6)
593       AC_MSG_RESULT(6)
594       AC_DEFINE(BX_CPU_LEVEL, 6)
595       ;;
596     *)
597       echo " "
598       echo "ERROR: you must supply a valid CPU level to --enable-cpu-level"
599       exit 1
600       ;;
601   esac
602   bx_cpu_level=$enableval
603   if test "$use_smp" = 1 -a "$enableval" -lt 5; then
604     echo "ERROR: with >1 processor, use --enable-cpu-level=5 or more"
605     exit 1
606   fi
607   if test "$use_x86_64" = 1 -a "$enableval" -lt 6; then
608     echo "ERROR: --enable-cpu-level=6 required for x86-64 emulation"
609     exit 1
610   fi
611  ],
612  [
613    AC_MSG_RESULT(6)
614    AC_DEFINE(BX_CPU_LEVEL, 6)
615    bx_cpu_level=6
616  ]
617  )
618
619AC_MSG_CHECKING(for larger than 32 bit physical address emulation)
620AC_ARG_ENABLE(long-phy-address,
621  AS_HELP_STRING([--enable-long-phy-address], [compile in support for physical address larger than 32 bit (yes, if cpu level >= 5)]),
622  [if test "$enableval" = yes; then
623    AC_MSG_RESULT(yes)
624    AC_DEFINE(BX_PHY_ADDRESS_LONG, 1)
625   else
626    AC_MSG_RESULT(no)
627    AC_DEFINE(BX_PHY_ADDRESS_LONG, 0)
628   fi
629   ],
630  [
631    if test "$bx_cpu_level" -ge 5; then
632      AC_MSG_RESULT(yes)
633      AC_DEFINE(BX_PHY_ADDRESS_LONG, 1)
634    else
635      AC_MSG_RESULT(no)
636      AC_DEFINE(BX_PHY_ADDRESS_LONG, 0)
637    fi
638    ]
639  )
640
641AC_MSG_CHECKING(for large ramfile support)
642AC_ARG_ENABLE(large-ramfile,
643  AS_HELP_STRING([--enable-large-ramfile], [enable large ramfile support (yes)]),
644  [if test "$enableval" = yes; then
645    AC_MSG_RESULT(yes)
646    AC_DEFINE(BX_LARGE_RAMFILE, 1)
647   else
648    AC_MSG_RESULT(no)
649    AC_DEFINE(BX_LARGE_RAMFILE, 0)
650   fi],
651  [
652    AC_MSG_RESULT(yes)
653    AC_DEFINE(BX_LARGE_RAMFILE, 1)
654    ]
655  )
656AC_SUBST(BX_LARGE_RAMFILE)
657
658AC_MSG_CHECKING(for repeated IO and mem copy speedups)
659AC_ARG_ENABLE(repeat-speedups,
660  AS_HELP_STRING([--enable-repeat-speedups], [support repeated IO and mem copy speedups (no)]),
661  [if test "$enableval" = yes; then
662    AC_MSG_RESULT(yes)
663    speedup_repeat=1
664   else
665    AC_MSG_RESULT(no)
666    speedup_repeat=0
667   fi],
668  [
669    AC_MSG_RESULT(no)
670    speedup_repeat=0
671    ]
672  )
673
674AC_MSG_CHECKING(for gcc / MSVC nmake fast function calls optimization)
675AC_ARG_ENABLE(fast-function-calls,
676  AS_HELP_STRING([--enable-fast-function-calls], [support for fast function calls (no - gcc on x86 and MSVC nmake only)]),
677  [if test "$enableval" = yes; then
678    AC_MSG_RESULT(yes)
679    speedup_fastcall=1
680   else
681    AC_MSG_RESULT(no)
682    speedup_fastcall=0
683   fi],
684  [
685    AC_MSG_RESULT(no)
686    speedup_fastcall=0
687    ]
688  )
689
690AC_MSG_CHECKING(for handlers chaining speedups)
691AC_ARG_ENABLE(handlers-chaining,
692  AS_HELP_STRING([--enable-handlers-chaining], [support handlers-chaining emulation speedups (no)]),
693  [if test "$enableval" = yes; then
694    AC_MSG_RESULT(yes)
695    speedup_handlers_chaining=1
696   else
697    AC_MSG_RESULT(no)
698    speedup_handlers_chaining=0
699   fi],
700  [
701    AC_MSG_RESULT(no)
702    speedup_handlers_chaining=0
703    ]
704  )
705
706AC_MSG_CHECKING(for trace linking speedups support)
707AC_ARG_ENABLE(trace-linking,
708  AS_HELP_STRING([--enable-trace-linking], [enable trace linking speedups support (no)]),
709  [if test "$enableval" = yes; then
710    AC_MSG_RESULT(yes)
711    enable_trace_linking=1
712   else
713    AC_MSG_RESULT(no)
714    enable_trace_linking=0
715   fi],
716  [
717    AC_MSG_RESULT(no)
718    enable_trace_linking=0
719    ]
720  )
721
722AC_MSG_CHECKING(support for configurable MSR registers)
723AC_ARG_ENABLE(configurable-msrs,
724  AS_HELP_STRING([--enable-configurable-msrs], [support for configurable MSR registers (yes if cpu level >= 5)]),
725  [if test "$enableval" = yes; then
726    AC_MSG_RESULT(yes)
727    AC_DEFINE(BX_CONFIGURE_MSRS, 1)
728   else
729    AC_MSG_RESULT(no)
730    AC_DEFINE(BX_CONFIGURE_MSRS, 0)
731   fi],
732  [
733    if test "$bx_cpu_level" -ge 5; then
734      AC_MSG_RESULT(yes)
735      AC_DEFINE(BX_CONFIGURE_MSRS, 1)
736    else
737      AC_MSG_RESULT(no)
738      AC_DEFINE(BX_CONFIGURE_MSRS, 0)
739    fi
740    ]
741  )
742
743AC_MSG_CHECKING(show IPS)
744AC_ARG_ENABLE(show-ips,
745  AS_HELP_STRING([--enable-show-ips], [show IPS in Bochs status bar / log file (yes)]),
746  [if test "$enableval" = yes; then
747    AC_MSG_RESULT(yes)
748    AC_DEFINE(BX_SHOW_IPS, 1)
749   else
750    AC_MSG_RESULT(no)
751    AC_DEFINE(BX_SHOW_IPS, 0)
752   fi],
753  [
754    AC_MSG_RESULT(yes)
755    AC_DEFINE(BX_SHOW_IPS, 1)
756    ]
757  )
758
759AC_MSG_CHECKING(for use of .cpp as suffix)
760AC_ARG_ENABLE(cpp,
761  AS_HELP_STRING([--enable-cpp], [use .cpp as C++ suffix (no)]),
762  [if test "$enableval" = yes; then
763    AC_MSG_RESULT(yes)
764    SUFFIX_LINE='.SUFFIXES: .cpp'
765    CPP_SUFFIX='cpp'
766   else
767    AC_MSG_RESULT(no)
768    SUFFIX_LINE='.SUFFIXES: .cc'
769    CPP_SUFFIX='cc'
770   fi],
771  [
772    AC_MSG_RESULT(no)
773    SUFFIX_LINE='.SUFFIXES: .cc'
774    CPP_SUFFIX='cc'
775    ]
776  )
777AC_SUBST(SUFFIX_LINE)
778AC_SUBST(CPP_SUFFIX)
779
780if test "$enable_cpp" = yes; then
781  echo "moving .cc source files to .cpp"
782  sourcefiles=`find . -name "*.cc" -print`
783  if test "$sourcefiles" != ""; then
784    for ccname in $sourcefiles
785    do
786      cppname=`echo $ccname | sed -e "s/\.cc$/.cpp/"`
787      echo "mv $ccname $cppname"
788      mv   $ccname $cppname
789    done
790  else
791    echo "no more .cc source files to rename"
792  fi
793fi
794
795
796
797AC_MSG_CHECKING(for Bochs internal debugger support)
798AC_ARG_ENABLE(debugger,
799  AS_HELP_STRING([--enable-debugger], [compile in support for Bochs internal debugger (no)]),
800  [if test "$enableval" = yes; then
801    AC_MSG_RESULT(yes)
802    AC_DEFINE(BX_DEBUGGER, 1)
803    DEBUGGER_VAR='$(DEBUGGER_LIB)'
804    NO_FLEX_YACC=''
805    AC_PATH_PROG(FLEX, flex, not_found)
806    AC_PATH_PROG(YACC, yacc, not_found)
807    AC_MSG_CHECKING(whether to generate parser / lexer files)
808    if test "$FLEX" = not_found -o "$YACC" = not_found -o "$MSVC_TARGET" != 0; then
809      NO_FLEX_YACC='#'
810      AC_MSG_RESULT(no)
811    else
812      AC_MSG_RESULT(yes)
813    fi
814    AC_SUBST(NO_FLEX_YACC)
815    bx_debugger=1
816   else
817    AC_MSG_RESULT(no)
818    AC_DEFINE(BX_DEBUGGER, 0)
819    DEBUGGER_VAR=''
820    bx_debugger=0
821   fi
822   ],
823  [
824    AC_MSG_RESULT(no)
825    AC_DEFINE(BX_DEBUGGER, 0)
826    DEBUGGER_VAR=''
827    bx_debugger=0
828    ]
829  )
830AC_SUBST(DEBUGGER_VAR)
831
832AC_MSG_CHECKING(enable Bochs internal debugger GUI)
833AC_ARG_ENABLE(debugger-gui,
834  AS_HELP_STRING([--enable-debugger-gui], [compile in support for Bochs internal debugger GUI (yes, if debugger is on)]),
835  [if test "$enableval" = yes; then
836    AC_MSG_RESULT(yes)
837    gui_debugger=1
838   else
839    AC_MSG_RESULT(no)
840    AC_DEFINE(BX_DEBUGGER_GUI, 0)
841    gui_debugger=0
842   fi],
843  [
844    if test "$bx_debugger" = 1; then
845      AC_MSG_RESULT(yes)
846      gui_debugger=1
847    else
848      AC_MSG_RESULT(no)
849      AC_DEFINE(BX_DEBUGGER_GUI, 0)
850      gui_debugger=0
851    fi
852    ]
853  )
854
855bx_gdb_stub=0
856AC_MSG_CHECKING(for gdb stub enable)
857AC_ARG_ENABLE(gdb-stub,
858  AS_HELP_STRING([--enable-gdb-stub], [enable gdb stub support (no)]),
859  [if test "$enableval" = yes; then
860    AC_MSG_RESULT(yes)
861    AC_DEFINE(BX_GDBSTUB, 1)
862    GDBSTUB_VAR='$(GDBSTUB_OBJS)'
863    bx_gdb_stub=1
864    if test "$bx_debugger" = 1; then
865      AC_MSG_ERROR([[--enable-debugger and --enable-gdb-stub are mutually exclusive]])
866    fi
867    AC_MSG_WARN([This Bochs feature is not maintained yet and may fail])
868   else
869    AC_MSG_RESULT(no)
870    AC_DEFINE(BX_GDBSTUB, 0)
871    GDBSTUB_VAR=''
872   fi],
873  [
874    AC_MSG_RESULT(no)
875    AC_DEFINE(BX_GDBSTUB, 0)
876    GDBSTUB_VAR=''
877    ]
878  )
879AC_SUBST(GDBSTUB_VAR)
880
881
882AC_MSG_CHECKING(for I/O Interface to the debugger)
883IODEBUG_OBJS=''
884AC_ARG_ENABLE(iodebug,
885  AS_HELP_STRING([--enable-iodebug], [enable I/O interface to debugger (yes, if debugger is on)]),
886  [if test "$enableval" = yes; then
887    AC_MSG_RESULT(yes)
888    AC_DEFINE(BX_SUPPORT_IODEBUG, 1)
889    IODEBUG_OBJS='iodebug.o'
890   else
891    AC_MSG_RESULT(no)
892    AC_DEFINE(BX_SUPPORT_IODEBUG, 0)
893   fi
894   ],
895  [
896    if test "$bx_debugger" = 1; then
897      # enable by default if debugger is on
898      AC_MSG_RESULT(yes)
899      AC_DEFINE(BX_SUPPORT_IODEBUG, 1)
900      IODEBUG_OBJS='iodebug.o'
901    else
902      AC_MSG_RESULT(no)
903    fi
904    ]
905  )
906AC_SUBST(IODEBUG_OBJS)
907
908
909AC_MSG_CHECKING(for ALL optimizations enabled)
910AC_ARG_ENABLE(all-optimizations,
911  AS_HELP_STRING([--enable-all-optimizations], [compile in all possible optimizations (no)]),
912  [if test "$enableval" = yes; then
913    AC_MSG_RESULT(yes)
914    speedups_all=1
915   else
916    AC_MSG_RESULT(no)
917    speedups_all=0
918   fi
919   ],
920  [
921    AC_MSG_RESULT(no)
922    speedups_all=0
923    ]
924  )
925
926#
927# Optimizations section.  Decide what the status of various optimizations
928# should be based on configure choices and other factors.
929#
930
931if test "$speedups_all" = 1; then
932  # Configure requested to force all options enabled.
933  speedup_repeat=1
934  speedup_fastcall=1
935  speedup_handlers_chaining=1
936  enable_trace_linking=1
937fi
938
939if test "$speedup_repeat" = 1; then
940  AC_DEFINE(BX_SUPPORT_REPEAT_SPEEDUPS, 1)
941else
942  AC_DEFINE(BX_SUPPORT_REPEAT_SPEEDUPS, 0)
943fi
944
945if test "$speedup_fastcall" = 1; then
946  AC_DEFINE(BX_FAST_FUNC_CALL, 1)
947else
948  AC_DEFINE(BX_FAST_FUNC_CALL, 0)
949fi
950
951if test "$bx_debugger" = 1 -a "$speedup_handlers_chaining" = 1; then
952  speedup_handlers_chaining=0
953  echo "ERROR: handlers-chaining speedups are not supported with internal debugger or gdbstub yet"
954fi
955
956if test "$bx_gdb_stub" = 1 -a "$speedup_handlers_chaining" = 1; then
957  speedup_handlers_chaining=0
958  echo "ERROR: handlers-chaining speedups are not supported with internal debugger or gdbstub yet"
959fi
960
961if test "$speedup_handlers_chaining" = 1; then
962  AC_DEFINE(BX_SUPPORT_HANDLERS_CHAINING_SPEEDUPS, 1)
963else
964  AC_DEFINE(BX_SUPPORT_HANDLERS_CHAINING_SPEEDUPS, 0)
965fi
966
967if test "$enable_trace_linking" = 1; then
968  AC_DEFINE(BX_ENABLE_TRACE_LINKING, 1)
969else
970  AC_DEFINE(BX_ENABLE_TRACE_LINKING, 0)
971fi
972
973READLINE_LIB=""
974rl_without_curses_ok=no
975rl_with_curses_ok=no
976
977AC_MSG_CHECKING(whether user wants readline)
978AC_ARG_ENABLE(readline,
979  AS_HELP_STRING([--enable-readline], [use readline library, if available (no)]),
980  [if test "$enableval" = yes; then
981    AC_MSG_RESULT(yes)
982     want_readline=yes
983   else
984     AC_MSG_RESULT(no)
985     want_readline=no
986   fi],
987  [
988    AC_MSG_RESULT(yes)
989    want_readline=yes
990    ]
991 )
992
993use_readline=0
994AC_MSG_CHECKING(whether to use readline)
995if test "$want_readline" = yes; then
996  if test "$bx_debugger" = 1; then
997
998    AC_MSG_CHECKING(if readline works without -lcurses)
999    OLD_LIBS=$LIBS
1000    LIBS="$LIBS -lreadline"
1001    AC_TRY_RUN([
1002      #include <stdio.h>
1003      #include <readline/readline.h>
1004      int main() { rl_initialize(); exit(0); }
1005      ],
1006      [ AC_MSG_RESULT(yes)
1007        rl_without_curses_ok=yes ],
1008      [ AC_MSG_RESULT(no) ]
1009    )
1010    AC_MSG_CHECKING(if readline works with -lcurses)
1011    LIBS="$LIBS -lcurses"
1012    AC_TRY_RUN([
1013      #include <stdio.h>
1014      #include <readline/readline.h>
1015      int main() { rl_initialize(); exit(0); }
1016      ],
1017      [AC_MSG_RESULT(yes)
1018       rl_with_curses_ok=yes ],
1019      [ AC_MSG_RESULT(no) ]
1020    )
1021    LIBS=$OLD_LIBS
1022
1023    if test "$rl_without_curses_ok" = yes; then
1024      AC_MSG_RESULT(yes)
1025      AC_DEFINE(HAVE_LIBREADLINE, 1)
1026      READLINE_LIB="-lreadline"
1027      use_readline=1
1028    elif test "$rl_with_curses_ok" = yes; then
1029      AC_MSG_RESULT(yes)
1030      AC_DEFINE(HAVE_LIBREADLINE, 1)
1031      READLINE_LIB="-lreadline -lcurses"
1032      use_readline=1
1033    else
1034      AC_MSG_RESULT(no)
1035      echo WARNING: The readline library was disabled because it was not found.
1036    fi
1037  else
1038    AC_MSG_RESULT(no)
1039  fi
1040else
1041  AC_MSG_RESULT(no)
1042fi
1043AC_SUBST(READLINE_LIB)
1044
1045AC_CHECK_HEADER(readline/history.h,
1046  AC_DEFINE(HAVE_READLINE_HISTORY_H)
1047  )
1048
1049INSTRUMENT_DIR='instrument/stubs'
1050
1051AC_MSG_CHECKING(for instrumentation support)
1052AC_ARG_ENABLE(instrumentation,
1053  AS_HELP_STRING([--enable-instrumentation=instrument-dir], [compile in support for instrumentation (no)]),
1054  [if test "$enableval" = yes; then
1055    AC_MSG_RESULT(yes)
1056    AC_DEFINE(BX_INSTRUMENTATION, 1)
1057    INSTRUMENT_VAR='$(INSTRUMENT_LIB)'
1058   elif test "$enableval" = no; then
1059    AC_MSG_RESULT(no)
1060    AC_DEFINE(BX_INSTRUMENTATION, 0)
1061    INSTRUMENT_VAR=''
1062   else
1063    AC_MSG_RESULT(yes)
1064    AC_DEFINE(BX_INSTRUMENTATION, 1)
1065    INSTRUMENT_DIR=$enableval
1066    INSTRUMENT_VAR='$(INSTRUMENT_LIB)'
1067   fi],
1068  [
1069    AC_MSG_RESULT(no)
1070    AC_DEFINE(BX_INSTRUMENTATION, 0)
1071    INSTRUMENT_VAR=''
1072    ]
1073  )
1074AC_SUBST(INSTRUMENT_DIR)
1075AC_SUBST(INSTRUMENT_VAR)
1076
1077AC_MSG_CHECKING(enable logging)
1078AC_ARG_ENABLE(logging,
1079  AS_HELP_STRING([--enable-logging], [enable logging (yes)]),
1080  [if test "$enableval" = yes; then
1081    AC_MSG_RESULT(yes)
1082    AC_DEFINE(BX_NO_LOGGING, 0)
1083   else
1084    AC_MSG_RESULT(no)
1085    AC_DEFINE(BX_NO_LOGGING, 1)
1086   fi],
1087  [
1088    AC_MSG_RESULT(yes)
1089    AC_DEFINE(BX_NO_LOGGING, 0)
1090    ]
1091  )
1092
1093AC_MSG_CHECKING(enable statistics collection)
1094AC_ARG_ENABLE(stats,
1095  AS_HELP_STRING([--enable-stats], [enable statistics collection (yes)]),
1096  [if test "$enableval" = yes; then
1097    AC_MSG_RESULT(yes)
1098    AC_DEFINE(BX_ENABLE_STATISTICS, 1)
1099   else
1100    AC_MSG_RESULT(no)
1101    AC_DEFINE(BX_ENABLE_STATISTICS, 0)
1102   fi],
1103  [
1104    AC_MSG_RESULT(yes)
1105    AC_DEFINE(BX_ENABLE_STATISTICS, 1)
1106    ]
1107  )
1108
1109AC_MSG_CHECKING(enable assert checks)
1110AC_ARG_ENABLE(assert-checks,
1111  AS_HELP_STRING([--enable-assert-checks], [enable BX_ASSERT checks (yes, if debugger is on)]),
1112  [if test "$enableval" = yes; then
1113    AC_MSG_RESULT(yes)
1114    AC_DEFINE(BX_ASSERT_ENABLE, 1)
1115   else
1116    AC_MSG_RESULT(no)
1117    AC_DEFINE(BX_ASSERT_ENABLE, 0)
1118   fi],
1119  [
1120    if test "$bx_debugger" = 1; then
1121      AC_MSG_RESULT(yes)
1122      AC_DEFINE(BX_ASSERT_ENABLE, 1)
1123    else
1124      AC_MSG_RESULT(no)
1125      AC_DEFINE(BX_ASSERT_ENABLE, 0)
1126    fi
1127    ]
1128  )
1129
1130support_fpu=1
1131AC_MSG_CHECKING(for FPU emulation)
1132FPU_VAR=''
1133AC_ARG_ENABLE(fpu,
1134  AS_HELP_STRING([--enable-fpu], [compile in FPU emulation (yes)]),
1135  [if test "$enableval" = yes; then
1136    AC_MSG_RESULT(yes)
1137    AC_DEFINE(BX_SUPPORT_FPU, 1)
1138    FPU_VAR='$(FPU_LIB)'
1139   elif test "$enableval" = no; then
1140    AC_MSG_RESULT(no)
1141    AC_DEFINE(BX_SUPPORT_FPU, 0)
1142    support_fpu=0
1143   else
1144    echo " "
1145    echo "ERROR: --enable-fpu does not accept a path"
1146    exit 1
1147   fi
1148   ],
1149  [
1150    AC_MSG_RESULT(yes)
1151    AC_DEFINE(BX_SUPPORT_FPU, 1)
1152    FPU_VAR='$(FPU_LIB)'
1153    ]
1154  )
1155AC_SUBST(FPU_VAR)
1156
1157support_vmx=0
1158AC_MSG_CHECKING(for VMX support)
1159AC_ARG_ENABLE(vmx,
1160  AS_HELP_STRING([--enable-vmx], [VMX (virtualization extensions) emulation (--enable-vmx=[no|1|2])]),
1161  [case "$enableval" in
1162    no | 0)
1163      support_vmx=0
1164      AC_MSG_RESULT(no)
1165      AC_DEFINE(BX_SUPPORT_VMX, 0)
1166      ;;
1167    yes | 1)
1168      support_vmx=1
1169      AC_MSG_RESULT(1)
1170      AC_DEFINE(BX_SUPPORT_VMX, 1)
1171      ;;
1172    2)
1173      support_vmx=2
1174      AC_MSG_RESULT(2)
1175      AC_DEFINE(BX_SUPPORT_VMX, 2)
1176      ;;
1177    *)
1178      echo "ERROR: --enable-vmx=$enableval not understood. Use --enable-vmx=[no|1|2]"
1179      exit 1
1180      ;;
1181   esac
1182   ],
1183  [
1184    AC_MSG_RESULT(no)
1185    AC_DEFINE(BX_SUPPORT_VMX, 0)
1186  ]
1187  )
1188
1189if test "$support_vmx" -gt 0 -a "$bx_cpu_level" -lt 6; then
1190  AC_MSG_ERROR([for VMX support the CPU level must be set to 6])
1191fi
1192
1193if test "$support_vmx" -gt 1 -a "$use_x86_64" = 0; then
1194  AC_MSG_ERROR([VMXx2 support require x86-64 enabled])
1195fi
1196
1197support_svm=0
1198AC_MSG_CHECKING(for SVM support)
1199AC_ARG_ENABLE(svm,
1200  AS_HELP_STRING([--enable-svm], [SVM (AMD: secure virtual machine) emulation (no)]),
1201  [if test "$enableval" = yes; then
1202    AC_MSG_RESULT(yes)
1203    AC_DEFINE(BX_SUPPORT_SVM, 1)
1204    support_svm=1
1205   elif test "$enableval" = no; then
1206    AC_MSG_RESULT(no)
1207    AC_DEFINE(BX_SUPPORT_SVM, 0)
1208   fi
1209   ],
1210  [
1211    AC_MSG_RESULT(no)
1212    AC_DEFINE(BX_SUPPORT_SVM, 0)
1213    ]
1214  )
1215
1216if test "$support_svm" -gt 0 -a "$use_x86_64" = 0; then
1217  AC_MSG_ERROR([SVM support require x86-64 enabled])
1218fi
1219
1220support_pkeys=0
1221AC_MSG_CHECKING(for User-Mode Protection Keys support)
1222AC_ARG_ENABLE(protection-keys,
1223  AS_HELP_STRING([--enable-protection-keys], [User-Mode Protection Keys support (no)]),
1224  [if test "$enableval" = yes; then
1225    AC_MSG_RESULT(yes)
1226    AC_DEFINE(BX_SUPPORT_PKEYS, 1)
1227    support_pkeys=1
1228   elif test "$enableval" = no; then
1229    AC_MSG_RESULT(no)
1230    AC_DEFINE(BX_SUPPORT_PKEYS, 0)
1231   fi
1232   ],
1233  [
1234    AC_MSG_RESULT(no)
1235    AC_DEFINE(BX_SUPPORT_PKEYS, 0)
1236  ]
1237  )
1238
1239if test "$support_pkeys" -gt 0 -a "$use_x86_64" = 0; then
1240  AC_MSG_ERROR([User-Mode Protection Keys feature emulation require x86-64 enabled])
1241fi
1242
1243support_cet=0
1244AC_MSG_CHECKING(for Control Flow Enforcement Technology support)
1245AC_ARG_ENABLE(cet,
1246  AS_HELP_STRING([--enable-cet], [Control Flow Enforcement Technology support (no)]),
1247  [if test "$enableval" = yes; then
1248    AC_MSG_RESULT(yes)
1249    AC_DEFINE(BX_SUPPORT_CET, 1)
1250    support_cet=1
1251   elif test "$enableval" = no; then
1252    AC_MSG_RESULT(no)
1253    AC_DEFINE(BX_SUPPORT_CET, 0)
1254   fi
1255   ],
1256  [
1257    AC_MSG_RESULT(no)
1258    AC_DEFINE(BX_SUPPORT_CET, 0)
1259  ]
1260  )
1261
1262if test "$support_cet" -gt 0 -a "$use_x86_64" = 0; then
1263  AC_MSG_ERROR([Control Flow Enforcement Technology feature emulation require x86-64 enabled])
1264fi
1265
1266AC_MSG_CHECKING(for 3DNow! support)
1267AC_ARG_ENABLE(3dnow,
1268  AS_HELP_STRING([--enable-3dnow], [3DNow! support (no - incomplete)]),
1269  [if test "$enableval" = yes; then
1270    AC_MSG_RESULT(yes)
1271    AC_DEFINE(BX_SUPPORT_3DNOW, 1)
1272   elif test "$enableval" = no; then
1273    AC_MSG_RESULT(no)
1274    AC_DEFINE(BX_SUPPORT_3DNOW, 0)
1275   fi
1276   ],
1277  [
1278    AC_MSG_RESULT(no)
1279    AC_DEFINE(BX_SUPPORT_3DNOW, 0)
1280  ]
1281  )
1282
1283AC_MSG_CHECKING(for alignment check support)
1284AC_ARG_ENABLE(alignment-check,
1285  AS_HELP_STRING([--enable-alignment-check], [alignment check (#AC) support (yes, if cpu level > 3)]),
1286  [if test "$enableval" = yes; then
1287    AC_MSG_RESULT(yes)
1288    AC_DEFINE(BX_SUPPORT_ALIGNMENT_CHECK, 1)
1289   elif test "$enableval" = no; then
1290    AC_MSG_RESULT(no)
1291    AC_DEFINE(BX_SUPPORT_ALIGNMENT_CHECK, 0)
1292   fi
1293   ],
1294  [
1295    if test "$bx_cpu_level" -gt 3; then
1296      AC_MSG_RESULT(yes)
1297      AC_DEFINE(BX_SUPPORT_ALIGNMENT_CHECK, 1)
1298    else
1299      AC_MSG_RESULT(no)
1300      AC_DEFINE(BX_SUPPORT_ALIGNMENT_CHECK, 0)
1301    fi
1302    ]
1303  )
1304
1305AC_MSG_CHECKING(for MONITOR/MWAIT instructions support (experimental))
1306AC_ARG_ENABLE(monitor_mwait,
1307  AS_HELP_STRING([--enable-monitor-mwait], [support for MONITOR/MWAIT instructions (yes, if cpu level > 5 - experimental)]),
1308  [if test "$enableval" = yes; then
1309    AC_MSG_RESULT(yes)
1310    AC_DEFINE(BX_SUPPORT_MONITOR_MWAIT, 1)
1311   elif test "$enableval" = no; then
1312    AC_MSG_RESULT(no)
1313    AC_DEFINE(BX_SUPPORT_MONITOR_MWAIT, 0)
1314   fi
1315   ],
1316  [
1317    if test "$bx_cpu_level" -gt 5; then
1318      AC_MSG_RESULT(yes)
1319      AC_DEFINE(BX_SUPPORT_MONITOR_MWAIT, 1)
1320    else
1321      AC_MSG_RESULT(no)
1322      AC_DEFINE(BX_SUPPORT_MONITOR_MWAIT, 0)
1323    fi
1324  ]
1325  )
1326
1327AC_MSG_CHECKING(for limited hardware performance monitoring emulation support (experimental))
1328AC_ARG_ENABLE(perfmon,
1329  AS_HELP_STRING([--enable-perfmon], [support for limited hardware performance monitoring emulation (yes, if cpu level > 5 - experimental)]),
1330  [if test "$enableval" = yes; then
1331    AC_MSG_RESULT(yes)
1332    AC_DEFINE(BX_SUPPORT_PERFMON, 1)
1333   elif test "$enableval" = no; then
1334    AC_MSG_RESULT(no)
1335    AC_DEFINE(BX_SUPPORT_PERFMON, 0)
1336   fi
1337   ],
1338  [
1339    if test "$bx_cpu_level" -gt 5; then
1340      AC_MSG_RESULT(yes)
1341      AC_DEFINE(BX_SUPPORT_PERFMON, 1)
1342    else
1343      AC_MSG_RESULT(no)
1344      AC_DEFINE(BX_SUPPORT_PERFMON, 0)
1345    fi
1346  ]
1347  )
1348
1349AC_MSG_CHECKING(for memory type support)
1350AC_ARG_ENABLE(memtype,
1351  AS_HELP_STRING([--enable-memtype], [support for memory type]),
1352  [if test "$enableval" = yes; then
1353    AC_MSG_RESULT(yes)
1354    AC_DEFINE(BX_SUPPORT_MEMTYPE, 1)
1355   elif test "$enableval" = no; then
1356    AC_MSG_RESULT(no)
1357    AC_DEFINE(BX_SUPPORT_MEMTYPE, 0)
1358   fi
1359   ],
1360  [
1361    AC_MSG_RESULT(no)
1362    AC_DEFINE(BX_SUPPORT_MEMTYPE, 0)
1363  ]
1364  )
1365
1366support_avx=0
1367AVX_LIB_VAR=''
1368AC_MSG_CHECKING(for AVX instructions support)
1369AC_ARG_ENABLE(avx,
1370  AS_HELP_STRING([--enable-avx], [support for AVX instructions (no)]),
1371  [if test "$enableval" = yes; then
1372    AC_MSG_RESULT(yes)
1373    AVX_LIB_VAR='$(AVX_LIB)'
1374    AC_DEFINE(BX_SUPPORT_AVX, 1)
1375    support_avx=1
1376   elif test "$enableval" = no; then
1377    AC_MSG_RESULT(no)
1378    AC_DEFINE(BX_SUPPORT_AVX, 0)
1379   fi
1380   ],
1381  [
1382    AC_MSG_RESULT(no)
1383    AC_DEFINE(BX_SUPPORT_AVX, 0)
1384  ]
1385  )
1386AC_SUBST(AVX_LIB_VAR)
1387
1388if test "$support_avx" -gt 0 -a "$use_x86_64" = 0; then
1389  AC_MSG_ERROR([for AVX support x86-64 emulation must be compiled in!])
1390fi
1391
1392support_evex=0
1393AC_MSG_CHECKING(for EVEX prefix and AVX-512 extensions support)
1394AC_ARG_ENABLE(evex,
1395  AS_HELP_STRING([--enable-evex], [support for EVEX prefix and AVX-512 extensions (no)]),
1396  [if test "$enableval" = yes; then
1397    AC_MSG_RESULT(yes)
1398    AC_DEFINE(BX_SUPPORT_EVEX, 1)
1399    support_evex=1
1400   elif test "$enableval" = no; then
1401    AC_MSG_RESULT(no)
1402    AC_DEFINE(BX_SUPPORT_EVEX, 0)
1403   fi
1404   ],
1405  [
1406    AC_MSG_RESULT(no)
1407    AC_DEFINE(BX_SUPPORT_EVEX, 0)
1408  ]
1409  )
1410
1411if test "$support_evex" -gt 0 -a "$support_avx" = 0; then
1412  AC_MSG_ERROR([for EVEX and AVX-512 support AVX emulation must be compiled in!])
1413fi
1414
1415AC_MSG_CHECKING(for x86 debugger support)
1416AC_ARG_ENABLE(x86-debugger,
1417  AS_HELP_STRING([--enable-x86-debugger], [x86 debugger support (no)]),
1418  [if test "$enableval" = yes; then
1419    AC_MSG_RESULT(yes)
1420    AC_DEFINE(BX_X86_DEBUGGER, 1)
1421   elif test "$enableval" = no; then
1422    AC_MSG_RESULT(no)
1423    AC_DEFINE(BX_X86_DEBUGGER, 0)
1424   fi
1425   ],
1426  [
1427    AC_MSG_RESULT(no)
1428    AC_DEFINE(BX_X86_DEBUGGER, 0)
1429    ]
1430  )
1431
1432dnl devices configuration section
1433
1434PCI_OBJS=''
1435AC_MSG_CHECKING(for i440FX PCI support)
1436AC_ARG_ENABLE(pci,
1437  AS_HELP_STRING([--enable-pci], [enable i440FX PCI support (yes)]),
1438  [if test "$enableval" = yes; then
1439    AC_MSG_RESULT(yes)
1440    AC_DEFINE(BX_SUPPORT_PCI, 1)
1441    pci=1
1442   else
1443    AC_MSG_RESULT(no)
1444    AC_DEFINE(BX_SUPPORT_PCI, 0)
1445    pci=0
1446   fi],
1447  [
1448    AC_MSG_RESULT(yes)
1449    AC_DEFINE(BX_SUPPORT_PCI, 1)
1450    pci=1
1451    ]
1452  )
1453if test "$pci" = "1"; then
1454  PCI_OBJS='pci.o pci2isa.o pci_ide.o acpi.o hpet.o'
1455fi
1456AC_SUBST(PCI_OBJS)
1457
1458
1459AC_MSG_CHECKING(for PCI host device mapping support)
1460AC_ARG_ENABLE(pcidev,
1461  AS_HELP_STRING([--enable-pcidev], [enable PCI host device mapping support (no - linux host only)]),
1462  [
1463    if test "$enableval" = "yes"; then
1464      AC_MSG_RESULT(yes)
1465      if test "$pci" != "1"; then
1466        AC_MSG_ERROR([PCI host device mapping requires PCI support])
1467      fi
1468      case "$target" in
1469        *-linux*)
1470          AC_MSG_NOTICE([Linux detected as host for PCI host device mapping])
1471          linux_version=`uname -r`
1472          case "$linux_version" in
1473            2.2*)
1474              AC_MSG_ERROR([Linux kernel 2.4, 2.6 or 3.x is required for PCI host device mapping])
1475              ;;
1476            2.4*)
1477              PCIDEV_MODULE_MAKE_ALL="all-kernel24"
1478              KERNEL_MODULE_SUFFIX="o"
1479              ;;
1480            *)
1481              PCIDEV_MODULE_MAKE_ALL="all-kernel26"
1482              KERNEL_MODULE_SUFFIX="ko"
1483              ;;
1484          esac
1485          KERNELDIR="/lib/modules/$linux_version/build"
1486          LSMOD="lsmod"
1487          INSMOD="insmod"
1488          RMMOD="rmmod"
1489          DEPMOD="depmod"
1490          CLEAN_PCIDEV_VAR=clean_pcidev
1491          AC_SUBST(KERNELDIR)
1492          AC_SUBST(LSMOD)
1493          AC_SUBST(INSMOD)
1494          AC_SUBST(RMMOD)
1495          AC_SUBST(DEPMOD)
1496          AC_SUBST(PCIDEV_MODULE_MAKE_ALL)
1497          AC_SUBST(KERNEL_MODULE_SUFFIX)
1498          AC_SUBST(CLEAN_PCIDEV_VAR)
1499        ;;
1500        *)
1501          AC_MSG_ERROR([PCI host device mapping requires Linux as host])
1502        ;;
1503      esac
1504      AC_DEFINE(BX_SUPPORT_PCIDEV, 1)
1505      PCI_OBJS="$PCI_OBJS pcidev.o"
1506      AC_MSG_WARN([This Bochs feature is not maintained yet and may fail])
1507    else
1508      AC_MSG_RESULT(no)
1509      AC_DEFINE(BX_SUPPORT_PCIDEV, 0)
1510    fi
1511  ],
1512  [
1513    AC_MSG_RESULT(no)
1514    AC_DEFINE(BX_SUPPORT_PCIDEV, 0)
1515  ]
1516)
1517
1518use_usb=0
1519USBHC_OBJS=''
1520UHCICORE_OBJ=''
1521USBHC_DLL_TARGETS=''
1522AC_MSG_CHECKING(for USB UHCI support)
1523AC_ARG_ENABLE(usb,
1524  AS_HELP_STRING([--enable-usb], [enable USB UHCI support (no)]),
1525  [if test "$enableval" = yes; then
1526    AC_MSG_RESULT(yes)
1527    AC_DEFINE(BX_SUPPORT_USB_UHCI, 1)
1528    USBHC_OBJS="usb_uhci.o"
1529    UHCICORE_OBJ="uhci_core.o"
1530    USBHC_DLL_TARGETS="bx_usb_uhci.dll"
1531    use_usb=1
1532   else
1533    AC_MSG_RESULT(no)
1534    AC_DEFINE(BX_SUPPORT_USB_UHCI, 0)
1535   fi],
1536  [
1537    AC_MSG_RESULT(no)
1538    AC_DEFINE(BX_SUPPORT_USB_UHCI, 0)
1539    ]
1540  )
1541
1542AC_MSG_CHECKING(for USB OHCI support)
1543AC_ARG_ENABLE(usb-ohci,
1544  AS_HELP_STRING([--enable-usb-ohci], [enable USB OHCI support (no)]),
1545  [if test "$enableval" = yes; then
1546    AC_MSG_RESULT(yes)
1547    AC_DEFINE(BX_SUPPORT_USB_OHCI, 1)
1548    USBHC_OBJS="$USBHC_OBJS usb_ohci.o"
1549    USBHC_DLL_TARGETS="$USBHC_DLL_TARGETS bx_usb_ohci.dll"
1550    use_usb=1
1551   else
1552    AC_MSG_RESULT(no)
1553    AC_DEFINE(BX_SUPPORT_USB_OHCI, 0)
1554   fi],
1555  [
1556    AC_MSG_RESULT(no)
1557    AC_DEFINE(BX_SUPPORT_USB_OHCI, 0)
1558    ]
1559  )
1560
1561AC_MSG_CHECKING(for USB EHCI support)
1562AC_ARG_ENABLE(usb-ehci,
1563  AS_HELP_STRING([--enable-usb-ehci], [enable USB EHCI support (no)]),
1564  [if test "$enableval" = yes; then
1565    AC_MSG_RESULT(yes)
1566    AC_DEFINE(BX_SUPPORT_USB_EHCI, 1)
1567    USBHC_OBJS="$USBHC_OBJS usb_ehci.o"
1568    USBHC_DLL_TARGETS="$USBHC_DLL_TARGETS bx_usb_ehci.dll"
1569    use_usb=1
1570   else
1571    AC_MSG_RESULT(no)
1572    AC_DEFINE(BX_SUPPORT_USB_EHCI, 0)
1573   fi],
1574  [
1575    AC_MSG_RESULT(no)
1576    AC_DEFINE(BX_SUPPORT_USB_EHCI, 0)
1577    ]
1578  )
1579
1580AC_MSG_CHECKING(for USB xHCI support)
1581AC_ARG_ENABLE(usb-xhci,
1582  AS_HELP_STRING([--enable-usb-xhci], [enable USB xHCI support (no)]),
1583  [if test "$enableval" = yes; then
1584    AC_MSG_RESULT(yes)
1585    AC_DEFINE(BX_SUPPORT_USB_XHCI, 1)
1586    USBHC_OBJS="$USBHC_OBJS usb_xhci.o"
1587    USBHC_DLL_TARGETS="$USBHC_DLL_TARGETS bx_usb_xhci.dll"
1588    use_usb=1
1589   else
1590    AC_MSG_RESULT(no)
1591    AC_DEFINE(BX_SUPPORT_USB_XHCI, 0)
1592   fi],
1593  [
1594    AC_MSG_RESULT(no)
1595    AC_DEFINE(BX_SUPPORT_USB_XHCI, 0)
1596    ]
1597  )
1598
1599if test "$use_usb" = 1; then
1600  if test "$pci" != "1"; then
1601    AC_MSG_ERROR([USB requires PCI support])
1602  fi
1603  USB_LIB_VAR='iodev/usb/libusb.a'
1604  AC_SUBST(USB_LIB_VAR)
1605fi
1606AC_SUBST(USBHC_OBJS)
1607AC_SUBST(USBHC_DLL_TARGETS)
1608
1609
1610networking=no
1611NETDEV_OBJS=''
1612NETDEV_DLL_TARGETS=''
1613AC_MSG_CHECKING(for NE2000 support)
1614AC_ARG_ENABLE(ne2000,
1615  AS_HELP_STRING([--enable-ne2000], [enable NE2000 support (no)]),
1616  [if test "$enableval" = yes; then
1617    AC_MSG_RESULT(yes)
1618    AC_DEFINE(BX_SUPPORT_NE2K, 1)
1619    NETDEV_OBJS='ne2k.o'
1620    NETDEV_DLL_TARGETS="bx_ne2k.dll"
1621    networking=yes
1622   else
1623    AC_MSG_RESULT(no)
1624    AC_DEFINE(BX_SUPPORT_NE2K, 0)
1625   fi],
1626  [
1627    AC_MSG_RESULT(no)
1628    AC_DEFINE(BX_SUPPORT_NE2K, 0)
1629    ]
1630  )
1631
1632AC_MSG_CHECKING(for PCI pseudo NIC support)
1633AC_ARG_ENABLE(pnic,
1634  AS_HELP_STRING([--enable-pnic], [enable PCI pseudo NIC support (no)]),
1635  [if test "$enableval" = yes; then
1636    AC_MSG_RESULT(yes)
1637    AC_DEFINE(BX_SUPPORT_PCIPNIC, 1)
1638    NETDEV_OBJS="$NETDEV_OBJS pcipnic.o"
1639    NETDEV_DLL_TARGETS="$NETDEV_DLL_TARGETS bx_pcipnic.dll"
1640    networking=yes
1641   else
1642    AC_MSG_RESULT(no)
1643    AC_DEFINE(BX_SUPPORT_PCIPNIC, 0)
1644   fi],
1645  [
1646    AC_MSG_RESULT(no)
1647    AC_DEFINE(BX_SUPPORT_PCIPNIC, 0)
1648    ]
1649  )
1650
1651AC_MSG_CHECKING(for Intel(R) Gigabit Ethernet support)
1652AC_ARG_ENABLE(e1000,
1653  AS_HELP_STRING([--enable-e1000], [enable Intel(R) Gigabit Ethernet support (no)]),
1654  [if test "$enableval" = yes; then
1655    AC_MSG_RESULT(yes)
1656    if test "$pci" != "1"; then
1657      AC_MSG_ERROR([E1000 network adapter requires PCI support])
1658    fi
1659    AC_DEFINE(BX_SUPPORT_E1000, 1)
1660    NETDEV_OBJS="$NETDEV_OBJS e1000.o"
1661    NETDEV_DLL_TARGETS="$NETDEV_DLL_TARGETS bx_e1000.dll"
1662    networking=yes
1663   else
1664    AC_MSG_RESULT(no)
1665    AC_DEFINE(BX_SUPPORT_E1000, 0)
1666   fi],
1667  [
1668    AC_MSG_RESULT(no)
1669    AC_DEFINE(BX_SUPPORT_E1000, 0)
1670    ]
1671  )
1672
1673NETLOW_OBJS=''
1674if test "$networking" = yes; then
1675  NETLOW_OBJS='eth_null.o eth_vnet.o'
1676  ethernet_modules='null vnet'
1677  can_compile_slirp=0
1678  case "$target" in
1679    *-cygwin* | *-mingw32* | *-msys)
1680      can_compile_slirp=1
1681      DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -liphlpapi"
1682      ;;
1683    *-pc-windows* | *-pc-winnt*)
1684      can_compile_slirp=1
1685      DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS iphlpapi.lib"
1686      ;;
1687    *)
1688      AC_CHECK_HEADER([netinet/in.h], [ can_compile_slirp=1 ], [])
1689      ;;
1690  esac
1691  if test $can_compile_slirp = 1; then
1692    NETLOW_OBJS="$NETLOW_OBJS eth_slirp.o"
1693    ethernet_modules="$ethernet_modules slirp"
1694    AC_DEFINE(BX_NETMOD_SLIRP, 1)
1695    NETLOW_OBJS="$NETLOW_OBJS eth_socket.o"
1696    ethernet_modules="$ethernet_modules socket"
1697    AC_DEFINE(BX_NETMOD_SOCKET, 1)
1698  fi
1699  if test "$MSVC_TARGET" = 0; then
1700    AC_CHECK_HEADER(net/bpf.h, [
1701        NETLOW_OBJS="$NETLOW_OBJS eth_fbsd.o"
1702        ethernet_modules="$ethernet_modules fbsd"
1703        AC_DEFINE(BX_NETMOD_FBSD, 1)
1704      ])
1705    AC_CHECK_HEADER(netpacket/packet.h, [
1706        NETLOW_OBJS="$NETLOW_OBJS eth_linux.o"
1707        ethernet_modules="$ethernet_modules linux"
1708        AC_DEFINE(BX_NETMOD_LINUX, 1)
1709      ])
1710  fi
1711  case "$target" in
1712    *-pc-windows* | *-pc-winnt* | *-cygwin* | *-mingw32* | *-msys)
1713    NETLOW_OBJS="$NETLOW_OBJS eth_win32.o"
1714    ethernet_modules="$ethernet_modules win32"
1715    AC_DEFINE(BX_NETMOD_WIN32, 1)
1716    ;;
1717    *-macosx* | *-darwin*)
1718    NETLOW_OBJS="$NETLOW_OBJS eth_tuntap.o"
1719    ethernet_modules="$ethernet_modules tuntap"
1720    AC_DEFINE(BX_NETMOD_TUNTAP, 1)
1721    ;;
1722    *)
1723    AC_CHECK_HEADER(net/if.h, [
1724        use_vde=yes
1725        AC_DEFINE(BX_HAVE_NET_IF_H, 1)
1726      ], [],
1727      [
1728      #include <sys/types.h>
1729      #include <sys/socket.h>
1730    ])
1731    AC_CHECK_HEADER(linux/netlink.h, [
1732        use_vde=yes
1733      ], [],
1734      [
1735      #include <asm/types.h>
1736      #include <sys/socket.h>
1737    ])
1738
1739    if test "$use_vde" = yes; then
1740      NETLOW_OBJS="$NETLOW_OBJS eth_vde.o"
1741      ethernet_modules="$ethernet_modules vde"
1742      AC_DEFINE(BX_NETMOD_VDE, 1)
1743    fi
1744
1745    AC_CHECK_HEADER(net/if_tun.h, [
1746        use_tuntap=yes
1747      ], [],
1748      [
1749      #include <sys/types.h>
1750      #include <sys/socket.h>
1751      #include <net/if.h>
1752    ])
1753    AC_CHECK_HEADER(linux/if_tun.h, [
1754        use_tuntap=yes
1755      ], [],
1756      [
1757      #include <asm/types.h>
1758      #include <sys/socket.h>
1759    ])
1760    if test "$use_tuntap" = yes; then
1761      NETLOW_OBJS="$NETLOW_OBJS eth_tuntap.o"
1762      ethernet_modules="$ethernet_modules tuntap"
1763      AC_DEFINE(BX_NETMOD_TUNTAP, 1)
1764    fi
1765
1766    ;;
1767  esac
1768  NETWORK_LIB_VAR='iodev/network/libnetwork.a'
1769  AC_SUBST(NETWORK_LIB_VAR)
1770  AC_DEFINE(BX_NETWORKING, 1)
1771  AC_MSG_CHECKING(for ethernet modules)
1772  AC_MSG_RESULT($ethernet_modules)
1773else
1774  AC_DEFINE(BX_NETWORKING, 0)
1775fi
1776AC_SUBST(NETDEV_OBJS)
1777AC_SUBST(NETLOW_OBJS)
1778AC_SUBST(NETDEV_DLL_TARGETS)
1779
1780
1781dnl // serial mode 'socket' needs ws2_32.dll in non-plugin mode
1782if test "$bx_plugins" = 0; then
1783  case $target in
1784    *-pc-windows*)
1785      DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS ws2_32.lib"
1786      ;;
1787    *-mingw32* | *-cygwin* | *-msys)
1788      DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -lws2_32"
1789      ;;
1790  esac
1791fi
1792
1793AC_MSG_CHECKING(for raw serial support)
1794AC_ARG_ENABLE(raw-serial,
1795  AS_HELP_STRING([--enable-raw-serial], [use raw serial port access (no - incomplete)]),
1796  [if test "$enableval" = yes; then
1797    AC_MSG_RESULT(yes)
1798    AC_DEFINE(USE_RAW_SERIAL, 1)
1799   else
1800    AC_MSG_RESULT(no)
1801    AC_DEFINE(USE_RAW_SERIAL, 0)
1802   fi],
1803  [
1804    AC_MSG_RESULT(no)
1805    AC_DEFINE(USE_RAW_SERIAL, 0)
1806    ]
1807  )
1808
1809DISPLAY_OBJS=''
1810DISPLAY_EXTRA_OBJS=''
1811DISPLAY_DLL_TARGETS=''
1812AC_MSG_CHECKING(for CLGD54XX emulation)
1813AC_ARG_ENABLE(clgd54xx,
1814  AS_HELP_STRING([--enable-clgd54xx], [enable CLGD54XX emulation (no)]),
1815  [if test "$enableval" = yes; then
1816    AC_MSG_RESULT(yes)
1817    AC_DEFINE(BX_SUPPORT_CLGD54XX, 1)
1818    DISPLAY_OBJS="svga_cirrus.o"
1819    DISPLAY_DLL_TARGETS="bx_svga_cirrus.dll"
1820   else
1821    AC_MSG_RESULT(no)
1822    AC_DEFINE(BX_SUPPORT_CLGD54XX, 0)
1823   fi],
1824  [
1825    AC_MSG_RESULT(no)
1826    AC_DEFINE(BX_SUPPORT_CLGD54XX, 0)
1827    ]
1828  )
1829
1830AC_MSG_CHECKING(for 3dfx Voodoo Graphics emulation)
1831AC_ARG_ENABLE(voodoo,
1832  AS_HELP_STRING([--enable-voodoo], [enable 3dfx Voodoo Graphics emulation (no)]),
1833  [if test "$enableval" = yes; then
1834    AC_MSG_RESULT(yes)
1835    if test "$pci" != "1"; then
1836      AC_MSG_ERROR([3dfx Voodoo Graphics emulation requires PCI support])
1837    fi
1838    AC_DEFINE(BX_SUPPORT_VOODOO, 1)
1839    DISPLAY_OBJS="$DISPLAY_OBJS voodoo.o"
1840    DISPLAY_EXTRA_OBJS="$DISPLAY_EXTRA_OBJS banshee.o"
1841    DISPLAY_DLL_TARGETS="$DISPLAY_DLL_TARGETS bx_voodoo.dll"
1842   else
1843    AC_MSG_RESULT(no)
1844    AC_DEFINE(BX_SUPPORT_VOODOO, 0)
1845   fi],
1846  [
1847    AC_MSG_RESULT(no)
1848    AC_DEFINE(BX_SUPPORT_VOODOO, 0)
1849    ]
1850  )
1851AC_SUBST(DISPLAY_OBJS)
1852AC_SUBST(DISPLAY_EXTRA_OBJS)
1853AC_SUBST(DISPLAY_DLL_TARGETS)
1854
1855
1856AC_MSG_CHECKING(for lowlevel CDROM support)
1857AC_ARG_ENABLE(cdrom,
1858  AS_HELP_STRING([--enable-cdrom], [lowlevel CDROM support (yes)]),
1859  [if test "$enableval" = no; then
1860     bx_cdrom=0
1861   else
1862     bx_cdrom=1
1863   fi],
1864  [ bx_cdrom=1 ]
1865  )
1866
1867CDROM_OBJS='cdrom.o'
1868if test "$bx_cdrom" = 1; then
1869  AC_MSG_RESULT(yes)
1870  case $target in
1871    *-pc-windows* | *-pc-winnt* | *-cygwin* | *-mingw32* | *.msys)
1872      CDROM_OBJS="$CDROM_OBJS cdrom_win32.o"
1873      AC_DEFINE(LOWLEVEL_CDROM, cdrom_win32_c)
1874      AC_DEFINE(BX_SUPPORT_CDROM, 1)
1875      ;;
1876    *)
1877      AC_CHECK_HEADER(IOKit/storage/IOCDMedia.h,
1878        can_use_osx_cdrom=yes
1879        )
1880      if test "$with_amigaos" = yes; then
1881        # use the amiga cdrom file instead.
1882        CDROM_OBJS="$CDROM_OBJS cdrom_amigaos.o"
1883        AC_DEFINE(LOWLEVEL_CDROM, cdrom_amigaos_c)
1884      elif test "$can_use_osx_cdrom" = yes; then
1885        # use cdrom_osx
1886        AC_MSG_RESULT(Using OSX IOKit CD Interface)
1887        CDROM_OBJS="$CDROM_OBJS cdrom_osx.o"
1888        AC_DEFINE(LOWLEVEL_CDROM, cdrom_osx_c)
1889        EXTRA_LINK_OPTS="${EXTRA_LINK_OPTS} -framework IOKit -framework CoreFoundation "'$(GUI_LINK_OPTS)'
1890      else
1891        CDROM_OBJS="$CDROM_OBJS cdrom_misc.o"
1892        AC_DEFINE(LOWLEVEL_CDROM, cdrom_misc_c)
1893      fi
1894      AC_DEFINE(BX_SUPPORT_CDROM, 1)
1895      ;;
1896  esac
1897else
1898  AC_MSG_RESULT(no)
1899  AC_DEFINE(BX_SUPPORT_CDROM, 0)
1900fi
1901
1902AC_SUBST(CDROM_OBJS)
1903
1904
1905SOUNDHW_OBJS=''
1906SOUNDHW_DLL_TARGETS=''
1907SOUNDLOW_OBJS=''
1908GAME_OBJS=''
1909soundlow_drivers=''
1910soundlow_default=''
1911soundcard_present=0
1912gameport_present=0
1913AC_MSG_CHECKING(for Sound Blaster 16 support)
1914AC_ARG_ENABLE(sb16,
1915  AS_HELP_STRING([--enable-sb16], [Sound Blaster 16 Support (no)]),
1916  [if test "$enableval" = yes; then
1917     AC_MSG_RESULT(yes)
1918     SOUNDHW_OBJS='sb16.o'
1919     SOUNDHW_DLL_TARGETS="bx_sb16.dll"
1920     soundcard_present=1
1921     AC_DEFINE(BX_SUPPORT_SB16, 1)
1922     GAME_OBJS='gameport.o'
1923     gameport_present=1
1924   else
1925     AC_MSG_RESULT(no)
1926     AC_DEFINE(BX_SUPPORT_SB16, 0)
1927   fi],
1928
1929  [
1930    AC_MSG_RESULT(no)
1931    AC_DEFINE(BX_SUPPORT_SB16, 0)
1932    ]
1933  )
1934
1935AC_MSG_CHECKING(for ES1370 soundcard support)
1936AC_ARG_ENABLE(es1370,
1937  AS_HELP_STRING([--enable-es1370], [enable ES1370 soundcard support (no)]),
1938  [if test "$enableval" = yes; then
1939    AC_MSG_RESULT(yes)
1940    if test "$pci" != "1"; then
1941      AC_MSG_ERROR([ES1370 soundcard requires PCI support])
1942    fi
1943    SOUNDHW_OBJS="$SOUNDHW_OBJS es1370.o"
1944    SOUNDHW_DLL_TARGETS="$SOUNDHW_DLL_TARGETS bx_es1370.dll"
1945    soundcard_present=1
1946    AC_DEFINE(BX_SUPPORT_ES1370, 1)
1947    GAME_OBJS='gameport.o'
1948    gameport_present=1
1949   else
1950    AC_MSG_RESULT(no)
1951    AC_DEFINE(BX_SUPPORT_ES1370, 0)
1952   fi],
1953  [
1954    AC_MSG_RESULT(no)
1955    AC_DEFINE(BX_SUPPORT_ES1370, 0)
1956    ]
1957  )
1958
1959if test "$soundcard_present" = 1; then
1960  AC_DEFINE(BX_SUPPORT_SOUNDLOW, 1)
1961  case "$target" in
1962    *-linux-android*)
1963      SOUNDLOW_OBJS='soundsdl.o'
1964      soundlow_drivers="sdl"
1965      soundlow_default="sdl"
1966      AC_DEFINE(BX_HAVE_SOUND_SDL, 1)
1967      ;;
1968    *-linux* | *-freebsd*)
1969      SOUNDLOW_OBJS='soundoss.o'
1970      soundlow_drivers="oss"
1971      soundlow_default="oss"
1972      AC_DEFINE(BX_HAVE_SOUND_OSS, 1)
1973      bx_have_alsa=0
1974      AC_CHECK_HEADER([alsa/asoundlib.h], [bx_have_alsa=1])
1975      if test "$bx_have_alsa" = 1; then
1976        SOUNDLOW_OBJS="$SOUNDLOW_OBJS soundalsa.o"
1977        soundlow_default="alsa"
1978        soundlow_drivers="alsa $soundlow_drivers"
1979        AC_DEFINE(BX_HAVE_SOUND_ALSA, 1)
1980        if test "$bx_plugins" = 1; then
1981          ALSA_SOUND_LINK_OPTS="$ALSA_SOUND_LINK_OPTS -lasound"
1982        else
1983          DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -lasound"
1984        fi
1985      fi
1986      ;;
1987    *-pc-windows*)
1988      SOUNDLOW_OBJS='soundwin.o'
1989      DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS winmm.lib"
1990      soundlow_drivers="win"
1991      soundlow_default="win"
1992      AC_DEFINE(BX_HAVE_SOUND_WIN, 1)
1993      ;;
1994    *-cygwin* | *-mingw32* | *-msys)
1995      SOUNDLOW_OBJS='soundwin.o'
1996      DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -lwinmm"
1997      soundlow_drivers="win"
1998      soundlow_default="win"
1999      AC_DEFINE(BX_HAVE_SOUND_WIN, 1)
2000      ;;
2001    *-macosx* | *-macos* | *-apple-darwin*)
2002      SOUNDLOW_OBJS='soundosx.o'
2003      DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -framework CoreServices -framework AudioUnit -framework AudioToolbox"
2004      soundlow_drivers="osx"
2005      soundlow_default="osx"
2006      AC_DEFINE(BX_HAVE_SOUND_OSX, 1)
2007      ;;
2008    *)
2009      SOUNDLOW_OBJS=''
2010      soundlow_default="dummy"
2011      ;;
2012  esac
2013  if test "$with_sdl" = yes; then
2014    SOUNDLOW_OBJS="$SOUNDLOW_OBJS soundsdl.o"
2015    if test "$bx_plugins" = 1; then
2016      SDL_SOUND_LINK_OPTS="$SDL_SOUND_LINK_OPTS `sdl-config --libs`"
2017    fi
2018    soundlow_drivers="$soundlow_drivers sdl"
2019    if test "$soundlow_default" = "dummy"; then
2020      soundlow_default="sdl"
2021    fi
2022    AC_DEFINE(BX_HAVE_SOUND_SDL, 1)
2023  elif test "$with_sdl2" = yes; then
2024    SOUNDLOW_OBJS="$SOUNDLOW_OBJS soundsdl.o"
2025    if test "$bx_plugins" = 1; then
2026      SDL_SOUND_LINK_OPTS="$SDL_SOUND_LINK_OPTS `sdl2-config --libs`"
2027    fi
2028    soundlow_drivers="$soundlow_drivers sdl"
2029    if test "$soundlow_default" = "dummy"; then
2030      soundlow_default="sdl"
2031    fi
2032    AC_DEFINE(BX_HAVE_SOUND_SDL, 1)
2033    SDL2_VERSION=`sdl2-config --version`
2034    # SDL version >= 2.0.5 supports audio capture
2035    sdl2_audio_capture=0
2036    [
2037    case x$SDL2_VERSION in
2038      x2.0.[0-4]) ;;
2039      x2.0.[5-9]) sdl2_audio_capture=1 ;;
2040      *) ;;
2041    esac
2042    ]
2043    if test "$sdl2_audio_capture" = 1; then
2044      AC_DEFINE(BX_HAVE_SDL2_AUDIO_CAPTURE, 1)
2045    fi
2046  fi
2047  if test "$MSVC_TARGET" = 0; then
2048    AC_CHECK_HEADER([samplerate.h], [bx_have_libsamplerate=1])
2049    if test "$bx_have_libsamplerate" = 1; then
2050      DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -lsamplerate"
2051      AC_DEFINE(BX_HAVE_LIBSAMPLERATE, 1)
2052    else
2053      AC_CHECK_HEADER([soxr-lsr.h], [bx_have_soxr_lsr=1])
2054      if test "$bx_have_soxr_lsr" = 1; then
2055        DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -lsoxr-lsr"
2056        AC_DEFINE(BX_HAVE_SOXR_LSR, 1)
2057      fi
2058    fi
2059  fi
2060  SOUND_LIB_VAR='iodev/sound/libsound.a'
2061  AC_SUBST(SOUND_LIB_VAR)
2062  AC_MSG_CHECKING(for sound lowlevel modules)
2063  AC_MSG_RESULT($soundlow_drivers)
2064  AC_MSG_CHECKING(for default sound lowlevel module)
2065  AC_MSG_RESULT($soundlow_default)
2066  AC_DEFINE_UNQUOTED(BX_SOUND_LOWLEVEL_NAME, "$soundlow_default")
2067else
2068  AC_DEFINE(BX_SUPPORT_SOUNDLOW, 0)
2069fi
2070AC_SUBST(SOUNDHW_OBJS)
2071AC_SUBST(SOUNDLOW_OBJS)
2072AC_SUBST(ALSA_SOUND_LINK_OPTS)
2073AC_SUBST(SDL_SOUND_LINK_OPTS)
2074AC_SUBST(SOUNDHW_DLL_TARGETS)
2075
2076
2077AC_MSG_CHECKING(for standard PC gameport support)
2078AC_ARG_ENABLE(gameport,
2079  AS_HELP_STRING([--enable-gameport], [enable standard PC gameport support (yes, if soundcard present)]),
2080  [if test "$enableval" = yes; then
2081    AC_MSG_RESULT(yes)
2082    AC_DEFINE(BX_SUPPORT_GAMEPORT, 1)
2083    if test "$gameport_present" = 0; then
2084      GAME_OBJS='gameport.o'
2085      case $target in
2086        *-cygwin* | *-mingw32* | *-msys)
2087           DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS -lwinmm"
2088           ;;
2089      esac
2090    fi
2091   else
2092    AC_MSG_RESULT(no)
2093    GAME_OBJS=''
2094    AC_DEFINE(BX_SUPPORT_GAMEPORT, 0)
2095   fi],
2096  [
2097    if test "$gameport_present" = 1; then
2098      AC_DEFINE(BX_SUPPORT_GAMEPORT, 1)
2099      AC_MSG_RESULT(yes)
2100    else
2101      AC_DEFINE(BX_SUPPORT_GAMEPORT, 0)
2102      AC_MSG_RESULT(no)
2103    fi]
2104  )
2105AC_SUBST(GAME_OBJS)
2106
2107
2108BUSM_OBJS=''
2109bx_busmouse=0
2110AC_MSG_CHECKING(for Busmouse support)
2111AC_ARG_ENABLE(busmouse,
2112  AS_HELP_STRING([--enable-busmouse], [enable Busmouse support (InPort & Standard)]),
2113  [if test "$enableval" = yes; then
2114    AC_MSG_RESULT(yes)
2115    AC_DEFINE(BX_SUPPORT_BUSMOUSE, 1)
2116    BUSM_OBJS='busmouse.o'
2117    bx_busmouse=1
2118   else
2119    AC_MSG_RESULT(no)
2120    AC_DEFINE(BX_SUPPORT_BUSMOUSE, 0)
2121   fi],
2122  [
2123    AC_DEFINE(BX_SUPPORT_BUSMOUSE, 0)
2124    AC_MSG_RESULT(no)]
2125  )
2126AC_SUBST(BUSM_OBJS)
2127
2128
2129AC_PATH_PROG(DOCBOOK2HTML, docbook2html, not_found)
2130AC_CHECK_PROGS([JADE], [jade openjade], not_found)
2131AC_MSG_CHECKING(whether to build docbook documentation)
2132build_docbook=0
2133AC_ARG_ENABLE(docbook,
2134  AS_HELP_STRING([--enable-docbook], [build the Docbook documentation (yes, if docbook present)]),
2135  [
2136    if test "$enableval" = yes; then build_docbook=1; fi
2137  ],
2138  [
2139    dnl Not specified. If they have docbook2html or jade, then yes.
2140    if test "$DOCBOOK2HTML" != not_found; then
2141      build_docbook=1
2142    else
2143      if test "$JADE" != not_found; then build_docbook=1; fi
2144    fi
2145    ]
2146  )
2147
2148if test $build_docbook = 1; then
2149  AC_MSG_RESULT(yes)
2150  BUILD_DOCBOOK_VAR=build_docbook
2151  INSTALL_DOCBOOK_VAR=install_docbook
2152  CLEAN_DOCBOOK_VAR=clean_docbook
2153  if test "$DOCBOOK2HTML" = not_found -a "$JADE" = not_found; then
2154    echo "ERROR: docbook2html or jade must be installed to build the documentation"
2155    exit 1
2156  fi
2157else
2158  AC_MSG_RESULT(no)
2159fi
2160AC_SUBST(BUILD_DOCBOOK_VAR)
2161AC_SUBST(INSTALL_DOCBOOK_VAR)
2162AC_SUBST(CLEAN_DOCBOOK_VAR)
2163AC_SUBST(DOCBOOK2HTML)
2164
2165PRIMARY_TARGET='bochs'
2166PLUGIN_LIBNAME_TRANSFORMATION='%.o=libbx_%.la'
2167GUI_PLUGIN_NAME_TRANSFORMATION='%.o=libbx_%_gui.la'
2168IMG_PLUGIN_NAME_TRANSFORMATION='%.o=libbx_%_img.la'
2169
2170if test "$bx_plugins" = 0; then
2171  DISPLAY_LIB_VAR='iodev/display/libdisplay.a'
2172  AC_SUBST(DISPLAY_LIB_VAR)
2173fi
2174HDIMAGE_LIB_VAR='iodev/hdimage/libhdimage.a'
2175AC_SUBST(HDIMAGE_LIB_VAR)
2176IODEV_LIB_VAR='iodev/libiodev.a'
2177NONINLINE_VAR='$(NONINLINE_OBJS)'
2178
2179AC_SUBST(IODEV_LIB_VAR)
2180AC_SUBST(EXTRA_BX_OBJS)
2181AC_SUBST(NONINLINE_VAR)
2182AC_SUBST(INLINE_VAR)
2183AC_SUBST(EXTERNAL_DEPENDENCY)
2184AC_SUBST(RC_CMD)
2185
2186
2187AC_ARG_WITH(x11,
2188  [  --with-x11                        use X11 GUI],
2189  )
2190
2191AC_ARG_WITH(win32,
2192  [  --with-win32                      use Win32 GUI],
2193  )
2194
2195AC_ARG_WITH(macos,
2196  [  --with-macos                      use Macintosh/CodeWarrior environment],
2197  )
2198
2199AC_ARG_WITH(carbon,
2200  [  --with-carbon                     compile for MacOS X with Carbon GUI],
2201  )
2202
2203AC_ARG_WITH(nogui,
2204  [  --with-nogui                      no native GUI, just use blank stubs],
2205  )
2206
2207AC_ARG_WITH(term,
2208  [  --with-term                       textmode terminal environment],
2209  )
2210
2211AC_ARG_WITH(rfb,
2212  [  --with-rfb                        use RFB protocol, works with VNC viewer],
2213  )
2214
2215AC_ARG_WITH(vncsrv,
2216  [  --with-vncsrv                     use LibVNCServer, works with VNC viewer],
2217  )
2218
2219AC_ARG_WITH(amigaos,
2220  [  --with-amigaos                    use AmigaOS (or MorphOS) GUI],
2221  )
2222
2223AC_ARG_WITH(sdl,
2224  [  --with-sdl                        use SDL libraries],
2225  )
2226
2227AC_ARG_WITH(sdl2,
2228  [  --with-sdl2                       use SDL2 libraries],
2229  )
2230
2231AC_ARG_WITH(wx,
2232  [  --with-wx                         use wxWidgets libraries],
2233  )
2234
2235AC_ARG_WITH(all-libs,
2236  [  --with-all-libs                   compile all guis that Bochs supports],
2237  )
2238
2239dnl // DASH is option prefix for your platform
2240dnl // SLASH is directory for your platform
2241dnl // CXXFP is C++ File Prefix; the flag that tells the compiler
2242dnl //   this is a C++ source file
2243dnl // CFP is C File Prefix; the flag that tells the compiler
2244dnl //   this is a C source file
2245dnl // OFP is Object File Prefix; the flag that tells the compiler
2246dnl //   generate an object file with this name
2247DASH="-"
2248SLASH="/"
2249CXXFP=""
2250CFP=""
2251OFP="-o "
2252MAKELIB="ar rv \$@"
2253RMCOMMAND="rm -f "
2254# first define link variables without libtool
2255LINK="\$(CXX) -o \$@ \$(CXXFLAGS) \$(LDFLAGS)"
2256LINK_CONSOLE="\$(CXX) -o \$@ \$(CXXFLAGS_CONSOLE) \$(LDFLAGS)"
2257# unless NO_LT is set, add libtool to the front of the link command
2258if test "$NO_LT" != 1; then
2259  LINK="\$(LIBTOOL) --mode=link --tag CXX $LINK"
2260  LINK_CONSOLE="\$(LIBTOOL) --mode=link --tag CXX $LINK_CONSOLE"
2261fi
2262EXE=""
2263COMMAND_SEPARATOR="&& \\"
2264CD_UP_ONE="echo done"
2265CD_UP_TWO="echo done"
2266CD_UP_THREE="echo done"
2267
2268INSTALL_TARGET=install_unix
2269INSTALL_LIST_FOR_PLATFORM=
2270
2271# check for existence of and usable version of wxWidgets.  This comes
2272# early so that it could affect which one gets chosen.
2273if test x$WX_CONFIG = x; then
2274  AC_CHECK_PROG(WX_CONFIG, [ wx-config --version ], wx-config, not_found)
2275fi
2276AC_MSG_CHECKING(for wxWidgets configuration script)
2277AC_MSG_RESULT($WX_CONFIG)
2278
2279ok_wx_version=0
2280wx_multi_lib=0
2281needs_gtk2=0
2282wx_needs_gdk_version=0
2283wx_msw_unicode=0
2284AC_MSG_CHECKING(for wxWidgets library version)
2285if test x$WX_CONFIG != xnot_found; then
2286  WX_VERSION=`$WX_CONFIG --version`
2287  WX_BASENAME=`$WX_CONFIG --basename`
2288  [
2289  if test "$WX_BASENAME" = wx_mswu; then
2290    wx_msw_unicode=1
2291  fi
2292  # test that version >= 2.3.2.  Anybody have a better way to do this? Yuck.
2293  case x$WX_VERSION in
2294    x2.[012]*) ;; # less than version 2.3.x
2295    x2.3.[01]) ;; # less than version 2.3.2
2296    x2.3.[2-4]*) ok_wx_version=1 ;;  # 2.3.2 or greater
2297    x2.[4-5]*) ok_wx_version=1 ;;  # version 2.4 / 2.5
2298    x2.[6-9]*)  # version 2.6 or greater
2299      ok_wx_version=1
2300      wx_multi_lib=1
2301      case x$WX_BASENAME in
2302        xwx_gtk2|xwx_gtk2u) wx_needs_gdk_version=2 ;;
2303        *) ;;
2304      esac
2305      ;;
2306    x3*)  # version 3
2307      ok_wx_version=1
2308      wx_multi_lib=1
2309      case x$WX_BASENAME in
2310        xwx_gtk2|xwx_gtk2u) wx_needs_gdk_version=2 ;;
2311        xwx_gtk3|xwx_gtk3u) wx_needs_gdk_version=3 ;;
2312        *) ;;
2313      esac
2314      ;;
2315    *) ;; # who knows?
2316  esac
2317  ]
2318fi
2319AC_MSG_RESULT($WX_VERSION)
2320if test $wx_msw_unicode = 1; then
2321  AC_DEFINE(WX_MSW_UNICODE, 1)
2322fi
2323if test "$cross_configure" = 0; then
2324  if test "$ok_wx_version" = 1; then
2325    # detected a usable version
2326    if test "$with_all_libs" = yes; then
2327      with_wx=yes
2328    fi
2329  else
2330    if test "$with_wx" = yes; then
2331      AC_MSG_WARN([Bochs for wxWidgets cannot be compiled here, disabling it])
2332    fi
2333    with_wx=no
2334  fi
2335fi
2336
2337AC_MSG_CHECKING(for default gui on this platform)
2338AC_MSG_RESULT($DEFAULT_GUI)
2339
2340display_libs=""
2341GUI_DLL_TARGETS=""
2342use_gui_console=0
2343
2344# the $with_* variable tells the gui library to use, but does NOT necessarily
2345# indicate the platform.  Settings that depend on the platform should be
2346# handled later.
2347
2348XPM_LIB=''
2349XRANDR_LIB=''
2350if test "$with_x11" = yes; then
2351  display_libs="$display_libs X11"
2352  if test "$no_x" = yes; then
2353    echo ERROR: X windows gui was selected, but X windows libraries were not found.
2354    exit 1
2355  fi
2356
2357  check_xpm=0
2358  AC_MSG_CHECKING(whether user wants XPM support)
2359  AC_ARG_ENABLE(xpm,
2360    AS_HELP_STRING([--enable-xpm], [enable the check for XPM support (yes)]),
2361    [if test "$enableval" = yes; then
2362      check_xpm=0
2363      AC_MSG_RESULT(yes)
2364      check_xpm=1
2365     else
2366      AC_MSG_RESULT(no)
2367      check_xpm=0
2368     fi],
2369    [
2370      AC_MSG_RESULT(yes)
2371      check_xpm=1
2372      ]
2373    )
2374  if test $check_xpm = 1; then
2375    AC_CHECK_HEADER(X11/xpm.h, [
2376        AC_DEFINE(BX_HAVE_XPM_H)
2377        XPM_LIB='-lXpm'
2378      ])
2379  fi
2380  AC_CHECK_HEADER(X11/extensions/Xrandr.h, [
2381    AC_DEFINE(BX_HAVE_XRANDR_H)
2382    XRANDR_LIB='-lXrandr'
2383    ])
2384
2385  if test "$PKGCONFIG" != not_found; then
2386    X_CFLAGS="`pkg-config --cflags x11`"
2387    X_LIBS="`pkg-config --libs x11` $XPM_LIB $XRANDR_LIB"
2388  else
2389    X_LIBS="$X_LIBS -lX11 $XPM_LIB $XRANDR_LIB"
2390  fi
2391
2392  AC_DEFINE(BX_WITH_X11, 1)
2393  SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_X11)"
2394  GUI_CFLAGS="$GUI_CFLAGS \$(X_CFLAGS)"
2395  GUI_CXXFLAGS="$GUI_CXXFLAGS \$(X_CFLAGS)"
2396  GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_X)"
2397  # The enhanced X debugger depends on GTK2
2398  if test "$gui_debugger" = 1; then
2399    needs_gtk2=1
2400  fi
2401  use_gui_console=1
2402fi
2403AC_SUBST(X_CFLAGS)
2404AC_SUBST(X_LIBS)
2405
2406if test "$with_sdl" = yes; then
2407  display_libs="$display_libs sdl"
2408  GUI_DLL_TARGETS="$GUI_DLL_TARGETS bx_sdl_gui.dll"
2409  AC_DEFINE(BX_WITH_SDL, 1)
2410  SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_SDL)"
2411  # GUI_*FLAGS are added to the compilation of every bochs file, not just
2412  # the files in gui/*.cc.
2413  SDL_CFLAGS=`sdl-config --cflags`
2414  GUI_CFLAGS="$GUI_CFLAGS $SDL_CFLAGS"
2415  GUI_CXXFLAGS="$GUI_CXXFLAGS $SDL_CFLAGS"
2416  GUI_LINK_OPTS_SDL="`sdl-config --libs`"
2417  GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_SDL)"
2418  # The plugin version uses multi-threading support in Bochs core
2419  if test "$bx_plugins" = 1; then
2420    NONPLUGIN_GUI_LINK_OPTS="`sdl-config --libs`"
2421  fi
2422  # The enhanced X debugger depends on GTK2
2423  if test "$gui_debugger" = 1 -a "$DEFAULT_GUI" != win32; then
2424    needs_gtk2=1
2425  fi
2426  if test "$with_win32" != yes -a "$with_wx" != yes; then
2427    case $target in
2428      *-pc-windows*)
2429         RC_CMD="rc /fo"
2430         EXTRA_BX_OBJS="$EXTRA_BX_OBJS win32res.o"
2431         ;;
2432      *-cygwin* | *-mingw32* | *-msys)
2433         RC_CMD="windres -I. -o "
2434         EXTRA_BX_OBJS="$EXTRA_BX_OBJS win32res.o"
2435         ;;
2436    esac
2437  fi
2438  use_gui_console=1
2439fi
2440
2441if test "$with_sdl2" = yes; then
2442  display_libs="$display_libs sdl2"
2443  GUI_DLL_TARGETS="$GUI_DLL_TARGETS bx_sdl2_gui.dll"
2444  AC_DEFINE(BX_WITH_SDL2, 1)
2445  SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_SDL2)"
2446  # GUI_*FLAGS are added to the compilation of every bochs file, not just
2447  # the files in gui/*.cc.
2448  SDL2_CFLAGS=`sdl2-config --cflags`
2449  GUI_CFLAGS="$GUI_CFLAGS $SDL2_CFLAGS"
2450  GUI_CXXFLAGS="$GUI_CXXFLAGS $SDL2_CFLAGS"
2451  GUI_LINK_OPTS_SDL2="`sdl2-config --libs`"
2452  GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_SDL2)"
2453  # The plugin version uses multi-threading support in Bochs core
2454  if test "$bx_plugins" = 1; then
2455    NONPLUGIN_GUI_LINK_OPTS="`sdl2-config --libs`"
2456  fi
2457  # The enhanced X debugger depends on GTK2
2458  if test "$gui_debugger" = 1 -a "$DEFAULT_GUI" != win32; then
2459    needs_gtk2=1
2460  fi
2461  if test "$with_win32" != yes -a "$with_wx" != yes; then
2462    case $target in
2463      *-pc-windows*)
2464         RC_CMD="rc /fo"
2465         EXTRA_BX_OBJS="$EXTRA_BX_OBJS win32res.o"
2466         ;;
2467      *-cygwin* | *-mingw32* | *-msys)
2468         RC_CMD="windres -I. -o "
2469         EXTRA_BX_OBJS="$EXTRA_BX_OBJS win32res.o"
2470         ;;
2471    esac
2472  fi
2473  use_gui_console=1
2474fi
2475
2476if test "$with_rfb" = yes; then
2477  display_libs="$display_libs rfb"
2478  GUI_DLL_TARGETS="$GUI_DLL_TARGETS bx_rfb_gui.dll"
2479  AC_DEFINE(BX_WITH_RFB, 1)
2480  SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_RFB)"
2481  GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_RFB)"
2482  use_gui_console=1
2483fi
2484
2485if test "$with_vncsrv" = yes; then
2486  if test "$PKGCONFIG" != not_found; then
2487    pkg-config --exists libvncserver
2488    if test x$? = x0; then
2489      VNCSRV_CXXFLAGS="`pkg-config --cflags libvncserver`"
2490      GUI_LINK_OPTS_VNCSRV="`pkg-config --libs libvncserver`"
2491    fi
2492  else
2493    AC_CHECK_PROG(LIBVNCSERVER_CONFIG, [ libvncserver-config --version ], libvncserver-config, not_found)
2494    AC_MSG_CHECKING(for LibVNCServer configuration script)
2495    AC_MSG_RESULT($LIBVNCSERVER_CONFIG_CONFIG)
2496    VNCSRV_CXXFLAGS="`$LIBVNCSERVER_CONFIG --cflags`"
2497    GUI_LINK_OPTS_VNCSRV="`$LIBVNCSERVER_CONFIG --libs`"
2498  fi
2499  if test "$GUI_LINK_OPTS_VNCSRV" != ""; then
2500    display_libs="$display_libs vncsrv"
2501    AC_DEFINE(BX_WITH_VNCSRV, 1)
2502    SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_VNCSRV)"
2503    GUI_CXXFLAGS="$GUI_CXXFLAGS $VNCSRV_CXXFLAGS"
2504    if test "$bx_plugins" = 0; then
2505      GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_VNCSRV)"
2506    fi
2507  else
2508    AC_MSG_WARN([Bochs for LibVNCServer cannot be compiled here, disabling it])
2509    with_vncsrv=no
2510  fi
2511  use_gui_console=1
2512fi
2513
2514if test "$with_amigaos" = yes; then
2515  display_libs="$display_libs amigaos"
2516  AC_DEFINE(BX_WITH_AMIGAOS, 1)
2517  SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_AMIGAOS)"
2518  GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_AMIGAOS)"
2519fi
2520
2521if test "$with_win32" = yes; then
2522  display_libs="$display_libs win32"
2523  GUI_DLL_TARGETS="$GUI_DLL_TARGETS bx_win32_gui.dll"
2524  AC_DEFINE(BX_WITH_WIN32, 1)
2525  SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_WIN32)"
2526  case $target in
2527    *-pc-windows*)
2528       if test "$with_wx" != yes; then
2529         RC_CMD="rc /fo"
2530         EXTRA_BX_OBJS="$EXTRA_BX_OBJS win32res.o"
2531       fi
2532       GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_WIN32_VCPP)"
2533       ;;
2534    *-cygwin* | *-mingw32* | *-msys)
2535       if test "$with_wx" != yes; then
2536         if test "$cross_compiling" = no; then
2537           RC_CMD="windres -I. -o "
2538         else
2539           RC_CMD="$WINDRES -I. -o "
2540         fi
2541         EXTRA_BX_OBJS="$EXTRA_BX_OBJS win32res.o"
2542       fi
2543       GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_WIN32)"
2544       ;;
2545    *) echo Unsupported compile setup: GUI library is win32, but target is neither windows nor cygwin.
2546       ;;
2547  esac
2548fi
2549
2550if test "$with_macos" = yes; then
2551  display_libs="$display_libs macos"
2552  AC_DEFINE(BX_WITH_MACOS, 1)
2553  SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_MACOS)"
2554  GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_MACOS)"
2555  AC_MSG_WARN([This Bochs feature is not maintained yet and may fail])
2556fi
2557
2558if test "$with_carbon" = yes; then
2559  display_libs="$display_libs carbon"
2560  AC_DEFINE(BX_WITH_CARBON, 1)
2561  SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_CARBON)"
2562  GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_CARBON)"
2563  if test "$bx_plugins" = 1; then
2564    PRIMARY_TARGET=bochs.app/.build_plugins   # only for carbon application
2565  else
2566    PRIMARY_TARGET=bochs.app/.build   # only for carbon application
2567  fi
2568  INSTALL_TARGET='install_macosx'
2569  AC_MSG_WARN([This Bochs feature is not maintained yet and may fail])
2570fi
2571
2572if test "$with_term" = yes; then
2573  display_libs="$display_libs term"
2574  AC_DEFINE(BX_WITH_TERM, 1)
2575  SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_TERM)"
2576  GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_TERM)"
2577  use_curses=yes
2578fi
2579
2580if test "$with_wx" = yes; then
2581  display_libs="$display_libs wxWidgets"
2582  if test "$cross_configure" = 1; then
2583    true  # do not insist, if configuring for another machine
2584  else
2585    if test x$ok_wx_version != x1; then
2586      echo ERROR: A usable version of wxWidgets was not found.
2587      echo Upgrade the library or choose another gui.
2588      exit 1
2589    fi
2590  fi
2591  AC_DEFINE(BX_WITH_WX, 1)
2592  SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_WX)"
2593  SPECIFIC_GUI_SUPPORT_OBJS="$SPECIFIC_GUI_SUPPORT_OBJS \$(GUI_OBJS_WX_SUPPORT)"
2594  WX_CFLAGS="`$WX_CONFIG --cflags`"
2595  WX_CXXFLAGS="`$WX_CONFIG --cxxflags`"
2596  if test "$wx_needs_gdk_version" = 2; then
2597    GDK_CFLAGS="`pkg-config --cflags gdk-2.0`"
2598    WX_CFLAGS="$WX_CFLAGS $GDK_CFLAGS"
2599    WX_CXXFLAGS="$WX_CXXFLAGS $GDK_CFLAGS"
2600    AC_DEFINE(WX_GDK_VERSION, 2)
2601  fi
2602  if test "$wx_needs_gdk_version" = 3; then
2603    GDK_CFLAGS="`pkg-config --cflags gdk-3.0`"
2604    WX_CFLAGS="$WX_CFLAGS $GDK_CFLAGS"
2605    WX_CXXFLAGS="$WX_CXXFLAGS $GDK_CFLAGS"
2606    AC_DEFINE(WX_GDK_VERSION, 3)
2607  fi
2608  if test "$wx_multi_lib" = 1; then
2609    GUI_LINK_OPTS_WX="`$WX_CONFIG --libs core,base`"
2610  else
2611    GUI_LINK_OPTS_WX="`$WX_CONFIG --libs`"
2612  fi
2613  # GUI_C*FLAGS are added to the compilation of every bochs file, not just
2614  # the files in gui/*.cc.  They are not used when building other things
2615  # such as bximage.
2616  GUI_CFLAGS="$GUI_CFLAGS $WX_CFLAGS"
2617  GUI_CXXFLAGS="$GUI_CXXFLAGS $WX_CXXFLAGS"
2618  GUI_LINK_OPTS="$GUI_LINK_OPTS \$(GUI_LINK_OPTS_WX)"
2619  # using debugger with readline is failing due to thread/signal handler
2620  # problems.
2621  case $target in
2622    *-pc-windows* | *-cygwin* | *-mingw32* | *-msys)
2623       EXTRA_BX_OBJS="$EXTRA_BX_OBJS wxbochs_resources.o"
2624	   GUI_LINK_OPTS_WX="$GUI_LINK_OPTS_WX"
2625       ;;
2626    *)
2627      # This is required for XStringToKeysym
2628      if test "$with_x11" != yes -a "$bx_plugins" != 1; then
2629        GUI_LINK_OPTS="$GUI_LINK_OPTS -lX11"
2630      fi
2631      ;;
2632  esac
2633  # The enhanced X debugger depends on GTK2
2634  if test "$gui_debugger" = 1 -a "$DEFAULT_GUI" != win32; then
2635    needs_gtk2=1
2636  fi
2637fi
2638
2639if test "$with_nogui" = yes; then
2640  display_libs="$display_libs nogui"
2641  GUI_DLL_TARGETS="$GUI_DLL_TARGETS bx_nogui_gui.dll"
2642  AC_DEFINE(BX_WITH_NOGUI, 1)
2643  SPECIFIC_GUI_OBJS="$SPECIFIC_GUI_OBJS \$(GUI_OBJS_NOGUI)"
2644fi
2645
2646AC_MSG_CHECKING(for display libraries)
2647AC_MSG_RESULT($display_libs)
2648
2649if test "$display_libs" = ""; then
2650  echo "No display libraries were selected. Use --with-* options to enable"
2651  echo "individual display libraries, or --with-all-libs to detect the ones"
2652  echo "that Bochs supports."
2653  exit 1
2654fi
2655
2656# some display libraries and the enhanced debugger may depend on the GTK+ software package
2657bx_have_gtk_version=0
2658if test "$needs_gtk2" = 1; then
2659  # pkg-config is required to set TOOLKIT_CXXFLAGS and LIBS
2660  if test "$PKGCONFIG" != not_found; then
2661    # if wxGTK is based on GTK 3.0, use it for gui debugger to avoid conflicts
2662    if test "$with_wx" = yes -a "$wx_needs_gdk_version" = 3; then
2663      pkg-config --exists gtk+-3.0
2664      if test x$? = x0; then
2665        TOOLKIT_CXXFLAGS="`pkg-config --cflags gtk+-3.0`"
2666        LIBS="$LIBS `pkg-config --libs gtk+-3.0`"
2667        bx_have_gtk_version=3
2668      fi
2669    else
2670      pkg-config --exists gtk+-2.0
2671      if test x$? = x0; then
2672        TOOLKIT_CXXFLAGS="`pkg-config --cflags gtk+-2.0`"
2673        LIBS="$LIBS `pkg-config --libs gtk+-2.0`"
2674        bx_have_gtk_version=2
2675      fi
2676    fi
2677  else
2678    echo "ERROR: pkg-config was not found, unable to access the gtk+-2.0 package."
2679    echo "The gui debugger support is disabled now."
2680  fi
2681fi
2682
2683dnl To use wxWidgets you must select it as both the configuration interface
2684dnl and the display library.  In the simplest case where the user has
2685dnl only configured with --with-wx, set both defaults to wxWidgets.
2686dnl Without this setting, the config interface would default to the text
2687dnl mode config interface, and then the wxWidgets display library would not
2688dnl be usable.
2689if test "$display_libs" = " wxWidgets"; then
2690  AC_MSG_CHECKING(for default configuration interface)
2691  AC_MSG_RESULT(wxWidgets)
2692  AC_MSG_CHECKING(for default display library)
2693  AC_MSG_RESULT(wxWidgets)
2694  AC_DEFINE(BX_DEFAULT_CONFIG_INTERFACE, "wx")
2695  AC_DEFINE(BX_DEFAULT_DISPLAY_LIBRARY, "wx")
2696  AC_DEFINE(BX_USE_TEXTCONFIG, 0)
2697else
2698  if test "$DEFAULT_GUI" = win32; then
2699    AC_DEFINE(BX_DEFAULT_CONFIG_INTERFACE, "win32config")
2700  else
2701    AC_DEFINE(BX_DEFAULT_CONFIG_INTERFACE, "textconfig")
2702  fi
2703  if test "$DEFAULT_GUI" = x11; then
2704    AC_DEFINE(BX_DEFAULT_DISPLAY_LIBRARY, "x")
2705  else
2706    AC_DEFINE_UNQUOTED(BX_DEFAULT_DISPLAY_LIBRARY, "$DEFAULT_GUI")
2707  fi
2708  AC_DEFINE(BX_USE_TEXTCONFIG, 1)
2709fi
2710
2711if test "$use_gui_console" = 1; then
2712  AC_DEFINE(BX_USE_GUI_CONSOLE, 1)
2713else
2714  AC_DEFINE(BX_USE_GUI_CONSOLE, 0)
2715fi
2716
2717AC_SUBST(SPECIFIC_GUI_OBJS)
2718AC_SUBST(SPECIFIC_GUI_SUPPORT_OBJS)
2719AC_SUBST(GUI_CFLAGS)
2720AC_SUBST(GUI_CXXFLAGS)
2721AC_SUBST(WX_CONFIG)
2722AC_SUBST(WX_CFLAGS)
2723AC_SUBST(WX_CXXFLAGS)
2724AC_SUBST(TOOLKIT_CXXFLAGS)
2725
2726AC_CHECK_PROGS(WGET, wget curl fetch, not_found)
2727if test "$WGET" = not_found; then
2728  AC_MSG_WARN([cannot find wget (or equivalent) command])
2729fi
2730# everybody has to re-invent the wheel. differently.
2731test "${WGET}" = "curl" && WGET="curl -O"
2732
2733# modify settings based on target platform
2734case "$target" in
2735  *-macosx*)
2736    AC_DEFINE(BX_HAVE_STRDUP, 0)
2737    ;;
2738  *-macos*)
2739    AC_DEFINE(BX_HAVE_STRDUP, 0)
2740    AC_DEFINE(BX_PLUGINS, 0)
2741    AC_DEFINE(BX_HAVE_DLFCN_H, 0)
2742    AC_DEFINE(BX_HAVE_SOCKLEN_T, 0)
2743    AC_DEFINE(BX_HAVE_SELECT, 0)
2744    AC_DEFINE(BX_HAVE_GETTIMEOFDAY, 0)
2745    AC_DEFINE(BX_NO_ATTRIBUTES, 1)
2746    AC_DEFINE(BX_NETMOD_TUNTAP, 0)
2747    ;;
2748  *-pc-windows*)
2749    INSTALL_TARGET='install_win32'
2750    CC="cl"
2751    CXX="$CC"
2752    #C_OPT="/Zi"   # for debugging
2753    if test "$speedup_fastcall" = 1; then
2754      C_OPT="/O2 /Gr"   # optimize for speed, using fastcall everywhere
2755    else
2756      C_OPT="/O2"   # optimize for speed, no fastcall
2757    fi
2758    if test "$bx_debugger" = 1; then
2759      C_OPT="$C_OPT /EHsc"
2760    else
2761      C_OPT="$C_OPT /EHs-c-"
2762    fi
2763    if test "$bx_plugins" = 1; then
2764      CFLAGS="/nologo /MD /W3 /DNDEBUG /DWIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS $C_OPT"
2765    else
2766      CFLAGS="/nologo /MT /W3 /DNDEBUG /DWIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS $C_OPT"
2767    fi
2768    CXXFLAGS="$CFLAGS"
2769    DASH="/"
2770    SLASH="\\"
2771    CXXFP="/Tp"
2772    CFP="/Tc"
2773    OFP="/Fo"
2774    MAKE=nmake
2775    MAKELIB="lib /nologo /subsystem:console /verbose /out:\$@"
2776    RMCOMMAND="-del"
2777    #L_OPT="/debug"    # for debugging
2778    L_OPT=""           # no debug info
2779    LINK="link $L_OPT /nologo /subsystem:console /incremental:no /out:\$@ "
2780    LINK_CONSOLE=$LINK
2781    EXE=".exe"
2782    PRIMARY_TARGET="bochs.exe"
2783    BXIMAGE_LINK_OPTS="user32.lib"
2784    # also compile bxhub and niclist if networking is on
2785    if test "$networking" = yes; then
2786      OPTIONAL_TARGET="$OPTIONAL_TARGET bxhub.exe niclist.exe"
2787      BXHUB_FLAG="/DBXHUB"
2788      BXHUB_LINK_OPTS="ws2_32.lib"
2789    fi
2790    COMMAND_SEPARATOR=""
2791    CD_UP_ONE="cd .."
2792    CD_UP_TWO="cd ..\.."
2793    CD_UP_THREE="cd ..\..\.."
2794    have_gettimeofday=0  # even though it may exist in build environment
2795    AC_DEFINE(BX_64BIT_CONSTANTS_USE_LL, 0)
2796    AC_DEFINE(BX_CPP_INLINE, __forceinline)
2797    AC_DEFINE(BX_NO_ATTRIBUTES, 1)
2798    AC_DEFINE(HAVE_LIBREADLINE, 0)
2799    AC_DEFINE(HAVE_READLINE_HISTORY_H, 0)
2800    READLINE_LIB="";
2801    AC_DEFINE(BX_HAVE_DLFCN_H, 0)
2802    ;;
2803  *-cygwin*)
2804    EXE=".exe"
2805    PRIMARY_TARGET="bochs.exe"
2806    BXIMAGE_LINK_OPTS="-luser32"
2807    if test "$networking" = yes; then
2808      OPTIONAL_TARGET="$OPTIONAL_TARGET bxhub.exe niclist.exe"
2809      BXHUB_FLAG="-DBXHUB"
2810      BXHUB_LINK_OPTS="-lws2_32"
2811    fi
2812    AC_DEFINE(BX_HAVE_SELECT, 1)
2813    ;;
2814  *-mingw32* | *-msys)
2815    BXIMAGE_LINK_OPTS="-luser32"
2816    if test "$networking" = yes; then
2817      OPTIONAL_TARGET="$OPTIONAL_TARGET bxhub niclist"
2818      BXHUB_FLAG="-DBXHUB"
2819      BXHUB_LINK_OPTS="-lws2_32"
2820    fi
2821    AC_DEFINE(BX_HAVE_SELECT, 1)
2822    ;;
2823  *)
2824    if test "$networking" = yes; then
2825      OPTIONAL_TARGET="$OPTIONAL_TARGET bxhub"
2826      BXHUB_FLAG="-DBXHUB"
2827    fi
2828    ;;
2829esac
2830
2831# bximage specific settings
2832case "$target" in
2833  *-pc-windows*)
2834    BXIMAGE_FLAG="/DBXIMAGE"
2835    CXXFLAGS_CONSOLE="/nologo /MT /W3 /EHs-c- /DNDEBUG /DWIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS $C_OPT"
2836    ;;
2837  *)
2838    BXIMAGE_FLAG="-DBXIMAGE"
2839    CXXFLAGS_CONSOLE="$CXXFLAGS"
2840    ;;
2841esac
2842AC_SUBST(BXIMAGE_FLAG)
2843AC_SUBST(BXIMAGE_LINK_OPTS)
2844AC_SUBST(BXHUB_FLAG)
2845AC_SUBST(BXHUB_LINK_OPTS)
2846AC_SUBST(CXXFLAGS_CONSOLE)
2847
2848ENH_DBG_OBJS=""
2849if test "$gui_debugger" = 1; then
2850  if test "$bx_have_gtk_version" -ge 2; then
2851    ENH_DBG_OBJS="enh_dbg.o gtk_enh_dbg_osdep.o"
2852    AC_DEFINE(BX_DEBUGGER_GUI, 1)
2853  elif test "$DEFAULT_GUI" = win32 -o "$with_win32" = yes; then
2854    ENH_DBG_OBJS="enh_dbg.o win32_enh_dbg_osdep.o"
2855    AC_DEFINE(BX_DEBUGGER_GUI, 1)
2856  else
2857    AC_MSG_WARN([The Bochs debugger gui cannot be compiled here, disabling it])
2858    AC_DEFINE(BX_DEBUGGER_GUI, 0)
2859  fi
2860fi
2861AC_SUBST(ENH_DBG_OBJS)
2862
2863CI_PLUGIN_OBJS="textconfig.o"
2864EXPORT_DYNAMIC="-export-dynamic"
2865case $target in
2866  *-pc-windows* | *-pc-winnt*)
2867    if test "$bx_plugins" = 1; then
2868      # set variables for building DLL plugins
2869      PLUGIN_VAR=""
2870      PLUGIN_LIBNAME_TRANSFORMATION='%.o=bx_%.dll'
2871      GUI_PLUGIN_NAME_TRANSFORMATION='%.o=bx_%_gui.dll'
2872      IMG_PLUGIN_NAME_TRANSFORMATION='%.o=bx_%_img.dll'
2873      INSTALL_PLUGINS_VAR=install_dll_plugins
2874      WIN32_DLL_IMPORT_LIB="bochs.lib"
2875      LINK_DLL="link /dll /nologo /subsystem:console /incremental:no /out:\$@"
2876      LIBS="$LIBS advapi32.lib comctl32.lib comdlg32.lib gdi32.lib shell32.lib user32.lib"
2877      PLUGIN_TARGET_2=plugins_msvc
2878      LINK_VAR="_VCPP"
2879      EXT_MSVC_DLL_RULES="!INCLUDE makeincl.vc"
2880      echo -e "# DLL PLUGIN TEST\n" > iodev/makeincl.vc
2881      IODEV_DLL_TARGETS=""
2882      IODEV_DLL_LIST="biosdev cmos dma extfpuirq harddrv ioapic parallel pic speaker unmapped"
2883      if test "$pci" = "1"; then
2884        IODEV_DLL_LIST="$IODEV_DLL_LIST acpi pci pci2isa pci_ide hpet"
2885      fi
2886      if test "$bx_debugger" = 1; then
2887        IODEV_DLL_LIST="$IODEV_DLL_LIST iodebug"
2888      fi
2889      if test "$bx_busmouse" = 1; then
2890        IODEV_DLL_LIST="$IODEV_DLL_LIST busmouse"
2891      fi
2892      for i in $IODEV_DLL_LIST
2893      do
2894        echo -e "bx_$i.dll: $i.o" >> iodev/makeincl.vc
2895        echo -e "\tlink /dll /nologo /subsystem:console /incremental:no /out:\$@ $i.o \$(WIN32_DLL_IMPORT_LIBRARY)\n" >> iodev/makeincl.vc
2896        IODEV_DLL_TARGETS="$IODEV_DLL_TARGETS bx_$i.dll"
2897      done
2898    else
2899      if test "$with_win32" != yes; then
2900        LIBS="$LIBS comctl32.lib"
2901      fi
2902    fi
2903    CI_PLUGIN_OBJS="$CI_PLUGIN_OBJS \$(CI_OBJS_WIN32)"
2904    CI_SUPPORT_OBJS="\$(CI_OBJS_WIN32_SUPPORT)"
2905    EXPORT_DYNAMIC=""
2906    ;;
2907  *-cygwin* | *-mingw* | *-msys)
2908    if test "$bx_plugins" = 1; then
2909      # set variables for building DLL plugins
2910      PRIMARY_TARGET=".win32_dll_plugin_target"
2911      PLUGIN_LIBNAME_TRANSFORMATION='%.o=bx_%.dll'
2912      GUI_PLUGIN_NAME_TRANSFORMATION='%.o=bx_%_gui.dll'
2913      IMG_PLUGIN_NAME_TRANSFORMATION='%.o=bx_%_img.dll'
2914      INSTALL_PLUGINS_VAR=install_dll_plugins
2915      WIN32_DLL_IMPORT_LIB="dllexports.a"
2916      LINK_DLL="\$(CXX) \$(CXXFLAGS) -shared -o \$@"
2917    else
2918      if test "$with_win32" != yes; then
2919        LIBS="$LIBS -lcomctl32"
2920      fi
2921    fi
2922    CI_PLUGIN_OBJS="$CI_PLUGIN_OBJS \$(CI_OBJS_WIN32)"
2923    CI_SUPPORT_OBJS="\$(CI_OBJS_WIN32_SUPPORT)"
2924    EXPORT_DYNAMIC=""
2925    ;;
2926esac
2927AC_SUBST(CI_PLUGIN_OBJS)
2928AC_SUBST(CI_SUPPORT_OBJS)
2929AC_SUBST(EXPORT_DYNAMIC)
2930
2931if test "$use_curses" = yes; then
2932  if test "$PKGCONFIG" != not_found; then
2933    AC_CHECK_LIB(curses, mvaddch, GUI_LINK_OPTS_TERM="`pkg-config --libs curses`")
2934    AC_CHECK_LIB(ncurses, mvaddch, GUI_LINK_OPTS_TERM="`pkg-config --libs ncurses`")
2935    AC_CHECK_LIB(termlib, mvaddch, GUI_LINK_OPTS_TERM="`pkg-config --libs termlib`")
2936    AC_CHECK_LIB(pdcurses, mvaddch, GUI_LINK_OPTS_TERM="`pkg-config --libs pdcurses`")
2937  else
2938    AC_CHECK_LIB(curses, mvaddch, GUI_LINK_OPTS_TERM='-lcurses')
2939    AC_CHECK_LIB(ncurses, mvaddch, GUI_LINK_OPTS_TERM='-lncurses')
2940    AC_CHECK_LIB(termlib, mvaddch, GUI_LINK_OPTS_TERM='-ltermlib')
2941    AC_CHECK_LIB(pdcurses, mvaddch, GUI_LINK_OPTS_TERM='-lpdcurses')
2942  fi
2943  if test "$GUI_LINK_OPTS_TERM" = ""; then
2944    echo Curses library not found: tried curses, ncurses, termlib and pdcurses.
2945    exit 1
2946  fi
2947fi
2948
2949if test "$with_term" = yes; then
2950  old_LIBS="$LIBS"
2951  LIBS="$LIBS $GUI_LINK_OPTS_TERM"
2952  AC_CHECK_FUNCS(color_set, AC_DEFINE(BX_HAVE_COLOR_SET, 1))
2953  AC_CHECK_FUNCS(mvhline, AC_DEFINE(BX_HAVE_MVHLINE, 1))
2954  AC_CHECK_FUNCS(mvvline, AC_DEFINE(BX_HAVE_MVVLINE, 1))
2955  LIBS="$old_LIBS"
2956fi
2957
2958if test "$with_rfb" = yes; then
2959  # we need the socket function
2960  case $target in
2961    *-pc-windows* | *-pc-winnt*)
2962      RFB_LIBS="$RFB_LIBS ws2_32.lib"
2963      have_socket=yes
2964      ;;
2965    *-mingw32* | *-msys)
2966      RFB_LIBS="$RFB_LIBS -lws2_32"
2967      have_socket=yes
2968      ;;
2969    *-cygwin*)
2970      # is this okay without a check ?
2971      have_socket=yes
2972      ;;
2973    *)
2974      AC_CHECK_FUNCS(socket, have_socket=yes)
2975      if test "$have_socket" != yes; then
2976        AC_CHECK_LIB(socket, socket,
2977          [
2978            RFB_LIBS="$RFB_LIBS -lsocket"
2979            have_socket=yes
2980          ])
2981      fi
2982      ;;
2983  esac
2984  if test "$have_socket" != yes; then
2985    echo 'ERROR: socket function required for RFB compile'
2986    exit 1
2987  fi
2988fi
2989
2990# The ACX_PTHREAD function was written by
2991# Steven G. Johnson <stevenj@alum.mit.edu> and
2992# Alejandro Forero Cuervo <bachue@bachue.com>
2993# I found it in the ac-archive project on Source Forge.
2994
2995AC_DEFUN([ACX_PTHREAD], [
2996AC_REQUIRE([AC_CANONICAL_HOST])
2997acx_pthread_ok=no
2998
2999# First, check if the POSIX threads header, pthread.h, is available.
3000# If it isn't, don't bother looking for the threads libraries.
3001AC_CHECK_HEADER(pthread.h, , acx_pthread_ok=noheader)
3002
3003# We must check for the threads library under a number of different
3004# names; the ordering is very important because some systems
3005# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
3006# libraries is broken (non-POSIX).
3007
3008# First of all, check if the user has set any of the PTHREAD_LIBS,
3009# etcetera environment variables, and if threads linking works using
3010# them:
3011if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
3012	save_CFLAGS="$CFLAGS"
3013	CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
3014	CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
3015	save_LIBS="$LIBS"
3016	LIBS="$PTHREAD_LIBS $LIBS"
3017	AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
3018	AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
3019	AC_MSG_RESULT($acx_pthread_ok)
3020	if test x"$acx_pthread_ok" = xno; then
3021		PTHREAD_LIBS=""
3022		PTHREAD_CFLAGS=""
3023	fi
3024	LIBS="$save_LIBS"
3025	CFLAGS="$save_CFLAGS"
3026fi
3027
3028# Create a list of thread flags to try.  Items starting with a "-" are
3029# C compiler flags, and other items are library names, except for "none"
3030# which indicates that we try without any flags at all.
3031
3032acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt"
3033
3034# The ordering *is* (sometimes) important.  Some notes on the
3035# individual items follow:
3036
3037# pthreads: AIX (must check this before -lpthread)
3038# none: in case threads are in libc; should be tried before -Kthread and
3039#       other compiler flags to prevent continual compiler warnings
3040# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
3041# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
3042# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
3043# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
3044# -pthreads: Solaris/gcc
3045# -mthreads: Mingw32/gcc, Lynx/gcc
3046# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
3047#      doesn't hurt to check since this sometimes defines pthreads too;
3048#      also defines -D_REENTRANT)
3049# pthread: Linux, etcetera
3050# --thread-safe: KAI C++
3051
3052case "${host_cpu}-${host_os}" in
3053	*solaris*)
3054
3055	# On Solaris (at least, for some versions), libc contains stubbed
3056	# (non-functional) versions of the pthreads routines, so link-based
3057	# tests will erroneously succeed.  (We need to link with -pthread or
3058	# -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
3059	# a function called by this macro, so we could check for that, but
3060	# who knows whether they'll stub that too in a future libc.)  So,
3061	# we'll just look for -pthreads and -lpthread first:
3062
3063	acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
3064	;;
3065esac
3066
3067if test x"$acx_pthread_ok" = xno; then
3068for flag in $acx_pthread_flags; do
3069
3070	case $flag in
3071		none)
3072		AC_MSG_CHECKING([whether pthreads work without any flags])
3073		;;
3074
3075		-*)
3076		AC_MSG_CHECKING([whether pthreads work with $flag])
3077		PTHREAD_CFLAGS="$flag"
3078		;;
3079
3080		*)
3081		AC_MSG_CHECKING([for the pthreads library -l$flag])
3082		PTHREAD_LIBS="-l$flag"
3083		;;
3084	esac
3085
3086	save_LIBS="$LIBS"
3087	save_CFLAGS="$CFLAGS"
3088	LIBS="$PTHREAD_LIBS $LIBS"
3089	CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
3090
3091	# Check for various functions.  We must include pthread.h,
3092	# since some functions may be macros.  (On the Sequent, we
3093	# need a special flag -Kthread to make this header compile.)
3094	# We check for pthread_join because it is in -lpthread on IRIX
3095	# while pthread_create is in libc.  We check for pthread_attr_init
3096	# due to DEC craziness with -lpthreads.  We check for
3097	# pthread_cleanup_push because it is one of the few pthread
3098	# functions on Solaris that doesn't have a non-functional libc stub.
3099	# We try pthread_create on general principles.
3100	AC_TRY_LINK([#include <pthread.h>],
3101		    [pthread_t th; pthread_join(th, 0);
3102		     pthread_attr_init(0); pthread_cleanup_push(0, 0);
3103		     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
3104		    [acx_pthread_ok=yes])
3105
3106	LIBS="$save_LIBS"
3107	CFLAGS="$save_CFLAGS"
3108
3109	AC_MSG_RESULT($acx_pthread_ok)
3110	if test "x$acx_pthread_ok" = xyes; then
3111		break;
3112	fi
3113
3114	PTHREAD_LIBS=""
3115	PTHREAD_CFLAGS=""
3116done
3117fi
3118
3119# Various other checks:
3120if test "x$acx_pthread_ok" = xyes; then
3121	save_LIBS="$LIBS"
3122	LIBS="$PTHREAD_LIBS $LIBS"
3123	save_CFLAGS="$CFLAGS"
3124	CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
3125
3126	# Detect AIX lossage: threads are created detached by default
3127	# and the JOINABLE attribute has a nonstandard name (UNDETACHED).
3128	AC_MSG_CHECKING([for joinable pthread attribute])
3129	AC_TRY_LINK([#include <pthread.h>],
3130		    [int attr=PTHREAD_CREATE_JOINABLE;],
3131		    ok=PTHREAD_CREATE_JOINABLE, ok=unknown)
3132	if test x"$ok" = xunknown; then
3133		AC_TRY_LINK([#include <pthread.h>],
3134			    [int attr=PTHREAD_CREATE_UNDETACHED;],
3135			    ok=PTHREAD_CREATE_UNDETACHED, ok=unknown)
3136	fi
3137	if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then
3138		AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok,
3139			  [Define to the necessary symbol if this constant
3140			   uses a non-standard name on your system.])
3141	fi
3142	AC_MSG_RESULT(${ok})
3143	if test x"$ok" = xunknown; then
3144		AC_MSG_WARN([we do not know how to create joinable pthreads])
3145	fi
3146
3147	AC_MSG_CHECKING([if more special flags are required for pthreads])
3148	flag=no
3149	case "${host_cpu}-${host_os}" in
3150		*-aix* | *-freebsd*)     flag="-D_THREAD_SAFE";;
3151		*solaris* | alpha*-osf*) flag="-D_REENTRANT";;
3152	esac
3153	AC_MSG_RESULT(${flag})
3154	if test "x$flag" != xno; then
3155		PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
3156	fi
3157
3158	LIBS="$save_LIBS"
3159	CFLAGS="$save_CFLAGS"
3160
3161	# More AIX lossage: must compile with cc_r
3162	AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC})
3163else
3164	PTHREAD_CC="$CC"
3165fi
3166
3167AC_SUBST(PTHREAD_LIBS)
3168AC_SUBST(PTHREAD_CFLAGS)
3169AC_SUBST(PTHREAD_CC)
3170
3171# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
3172if test x"$acx_pthread_ok" = xyes; then
3173	ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
3174	:
3175else
3176	acx_pthread_ok=no
3177	$2
3178fi
3179
3180])dnl ACX_PTHREAD
3181
3182pthread_ok=no
3183ACX_PTHREAD([
3184  pthread_ok=yes
3185  #echo Using PTHREAD_LIBS=$PTHREAD_LIBS
3186  #echo Using PTHREAD_CFLAGS=$PTHREAD_CFLAGS
3187  #echo Using PTHREAD_CC=$PTHREAD_CC
3188  ])
3189
3190
3191# since some features need the pthread library, check that it was found.
3192# But on win32 platforms, the pthread library is not needed.
3193case "$target" in
3194  *-pc-windows* | *-pc-winnt* | *-cygwin* | *-mingw32* | *-msys)
3195    # pthread not needed for win32 platform
3196    ;;
3197  *)
3198    # assuming that some GUIs and the sound subsystem require pthreads
3199    if test "$pthread_ok" = yes; then
3200      if test "$with_rfb" = yes; then
3201        RFB_LIBS="$RFB_LIBS $PTHREAD_LIBS"
3202      fi
3203      if test "$with_vncsrv" = yes; then
3204        GUI_LINK_OPTS_VNCSRV="$GUI_LINK_OPTS_VNCSRV $PTHREAD_LIBS"
3205      fi
3206      if test "$soundcard_present" = 1; then
3207        if test "$bx_plugins" = 1; then
3208          ALSA_SOUND_LINK_OPTS="$ALSA_SOUND_LINK_OPTS $PTHREAD_LIBS"
3209          SDL_SOUND_LINK_OPTS="$SDL_SOUND_LINK_OPTS $PTHREAD_LIBS"
3210        else
3211          DEVICE_LINK_OPTS="$DEVICE_LINK_OPTS $PTHREAD_LIBS"
3212        fi
3213      fi
3214      CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
3215      CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
3216      CC="$PTHREAD_CC"
3217    else
3218      echo ERROR: the pthread library is required, but could not be found.; exit 1
3219    fi
3220	;;
3221esac
3222
3223dnl // DEPRECATED configure options - force users to remove them
3224
3225dnl AC_MSG_CHECKING(for misaligned SSE support (deprecated))
3226dnl AC_ARG_ENABLE(misaligned-sse,
3227dnl   AS_HELP_STRING([--enable-misaligned-sse], [misaligned SSE support (deprecated)]),
3228dnl   [AC_MSG_RESULT($enableval)
3229dnl    AC_MSG_ERROR([DEPRECATED - moved to runtime .bochsrc option])
3230dnl   ],
3231dnl   [
3232dnl    AC_MSG_RESULT(no)
3233dnl   ])
3234
3235# Create some subdirectories for when you run configure from some other
3236# directory (part #1).
3237if test ! -d instrument; then mkdir instrument; fi
3238if test ! -d build; then mkdir build; fi
3239if test ! -d build/linux; then mkdir build/linux; fi
3240if test ! -d build/win32; then mkdir build/win32; fi
3241if test ! -d build/win32/nsis; then mkdir build/win32/nsis; fi
3242
3243AC_SUBST(INSTALL_TARGET)
3244AC_SUBST(INSTALL_LIST_FOR_PLATFORM)
3245AC_SUBST(RFB_LIBS)
3246AC_SUBST(GUI_LINK_OPTS_VNCSRV)
3247AC_SUBST(GUI_LINK_OPTS_SDL)
3248AC_SUBST(GUI_LINK_OPTS_SDL2)
3249AC_SUBST(DEVICE_LINK_OPTS)
3250AC_SUBST(GUI_LINK_OPTS)
3251AC_SUBST(GUI_LINK_OPTS_TERM)
3252AC_SUBST(GUI_LINK_OPTS_WX)
3253AC_SUBST(NONPLUGIN_GUI_LINK_OPTS)
3254AC_SUBST(DASH)
3255AC_SUBST(SLASH)
3256AC_SUBST(CXXFP)
3257AC_SUBST(CFP)
3258AC_SUBST(OFP)
3259AC_SUBST(MAKELIB)
3260AC_SUBST(RMCOMMAND)
3261AC_SUBST(LINK)
3262AC_SUBST(LINK_CONSOLE)
3263AC_SUBST(LINK_DLL)
3264AC_SUBST(LINK_VAR)
3265AC_SUBST(EXE)
3266AC_SUBST(PRIMARY_TARGET)
3267AC_SUBST(OPTIONAL_TARGET)
3268AC_SUBST(PLUGIN_LIBNAME_TRANSFORMATION)
3269AC_SUBST(GUI_PLUGIN_NAME_TRANSFORMATION)
3270AC_SUBST(IMG_PLUGIN_NAME_TRANSFORMATION)
3271AC_SUBST(COMMAND_SEPARATOR)
3272AC_SUBST(CD_UP_ONE)
3273AC_SUBST(CD_UP_TWO)
3274AC_SUBST(CD_UP_THREE)
3275AC_SUBST(VERSION)
3276AC_SUBST(VER_MAJOR)
3277AC_SUBST(VER_MINOR)
3278AC_SUBST(VER_REVISION)
3279AC_SUBST(VER_SVN)
3280AC_SUBST(REL_STRING)
3281AC_SUBST(REL_TIMESTAMP)
3282AC_SUBST(EXTRA_LINK_OPTS)
3283AC_SUBST(GUI_NON_PLUGIN_OBJS)
3284AC_SUBST(GUI_PLUGIN_OBJS)
3285AC_SUBST(IODEV_NON_PLUGIN_OBJS)
3286AC_SUBST(IODEV_PLUGIN_OBJS)
3287AC_SUBST(IODEV_EXT_NON_PLUGIN_OBJS)
3288AC_SUBST(IODEV_EXT_PLUGIN_OBJS)
3289AC_SUBST(PLUGIN_VAR)
3290AC_SUBST(PLUGIN_LIB)
3291AC_SUBST(PLUGIN_TARGET)
3292AC_SUBST(PLUGIN_TARGET_2)
3293AC_SUBST(EXT_MSVC_DLL_RULES)
3294AC_SUBST(GUI_DLL_TARGETS)
3295AC_SUBST(BOCHS_BITS)
3296AC_SUBST(IODEV_DLL_TARGETS)
3297AC_SUBST(WIN32_DLL_IMPORT_LIB)
3298AC_SUBST(INSTALL_PLUGINS_VAR)
3299
3300AC_PATH_PROG(GZIP, gzip)
3301AC_PATH_PROG(TAR, tar)
3302AC_PATH_PROG(IASL, iasl, not_found)
3303
3304AC_OUTPUT(Makefile iodev/Makefile iodev/display/Makefile iodev/hdimage/Makefile \
3305	 iodev/usb/Makefile iodev/network/Makefile iodev/sound/Makefile \
3306	 bx_debug/Makefile bios/Makefile cpu/Makefile cpu/avx/Makefile \
3307	 cpu/cpudb/Makefile cpu/fpu/Makefile memory/Makefile gui/Makefile \
3308	 ${INSTRUMENT_DIR}/Makefile misc/Makefile \
3309	 doc/docbook/Makefile build/linux/bochs-dlx bxversion.h bxversion.rc \
3310	 build/macosx/Info.plist build/win32/nsis/Makefile \
3311	 build/win32/nsis/bochs.nsi host/linux/pcidev/Makefile ${USER_PLUGINS_MAKEFILE})
3312
3313# Create some subdirectories for when you run configure from some other
3314# directory (part #2).
3315if test ! -d cpu/cpudb/amd; then mkdir cpu/cpudb/amd; fi
3316if test ! -d cpu/cpudb/intel; then mkdir cpu/cpudb/intel; fi
3317if test ! -d cpu/decoder; then mkdir cpu/decoder; fi
3318if test ! -d iodev/network/slirp; then mkdir iodev/network/slirp; fi
3319