2 # Process this file with autoconf to produce a configure script.
5 AC_INIT(avr-sim, 1.0, thaber@uhasselt.be)
6 AC_CONFIG_SRCDIR([src/Instructions.h])
7 AC_CONFIG_HEADER([src/config.h])
10 # Checks for programs.
18 # Checks for libraries.
20 XML2_INCLUDES="-I /usr/include/libxml2"
21 AC_SUBST(XML2_INCLUDES)
22 AC_CHECK_LIB(xml2,[xmlReadFile],,[AC_MSG_ERROR([libxml2 library missing])])
24 AC_CHECK_LIB(bfd,[bfd_init])
26 # Checks for header files.
29 AC_CHECK_HEADERS([arpa/inet.h fcntl.h inttypes.h malloc.h memory.h netdb.h netinet/in.h stddef.h sys/socket.h unistd.h])
31 # Checks for typedefs, structures, and compiler characteristics.
40 AC_DEFUN([AC_LIBLUA_CHECK],[
42 if test "x$lua_dir" != "x"; then
44 # The user specified a directory in which liblua resides,
45 # so add the "include" subdirectory of that directory to
46 # the include file search path and the "lib" subdirectory
47 # of that directory to the library search path.
49 # XXX - if there's also a liblua in a directory that's
50 # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
51 # make us find the version in the specified directory,
52 # as the compiler and/or linker will search that other
53 # directory before it searches the specified directory.
56 CFLAGS="$CFLAGS -I$lua_dir/include"
57 save_CXXFLAGS="$CFLAGS"
58 CXXFLAGS="$CXXFLAGS -I$lua_dir/include"
59 save_CPPFLAGS="$CPPFLAGS"
60 CPPFLAGS="$CPPFLAGS -I$lua_dir/include"
62 LIBS="$LIBS -L$lua_dir/lib -llua50"
63 save_LDFLAGS="$LDFLAGS"
64 LDFLAGS="$LDFLAGS -L$lua_dir/lib"
67 # The user specified no directory in which liblua resides,
68 # so just add "-llua50 -llualib50" to the used libs.
71 save_CXXLAGS="$CXXFLAGS"
72 save_CPPFLAGS="$CPPFLAGS"
73 save_LDFLAGS="$LDFLAGS"
79 # Make sure we have "lua.h", "lualib.h" and "lauxlib.h". If we don't, it means we probably
80 # don't have liblua, so don't use it.
82 AC_CHECK_HEADERS(lua50/lua.h lua50/lualib.h lua50/lauxlib.h,,
84 if test "x$lua_dir" != "x"; then
86 # The user used "--with-lua=" to specify a directory
87 # containing liblua, but we didn't find the header file
88 # there; that either means they didn't specify the
89 # right directory or are confused about whether liblua
90 # is, in fact, installed. Report the error and give up.
92 AC_MSG_ERROR([liblua header not found in directory specified in --with-lua])
94 if test "x$want_lua" = "xyes"; then
96 # The user tried to force us to use the library, but we
97 # couldn't find the header file; report an error.
99 AC_MSG_ERROR(Header file lua.h not found.)
102 # We couldn't find the header file; don't use the
103 # library, as it's probably not present.
110 if test "x$want_lua" != "xno"; then
112 # Well, we at least have the lua header file.
114 # let's check if the libs are there
117 LIBS="$LIBS $LUA_LIBS -lm"
119 AC_CHECK_LIB(lua50, lua_call,
121 if test "x$lua_dir" != "x"; then
123 # Put the "-I" and "-L" flags for lua at
124 # the beginning of CFLAGS, CPPFLAGS,
127 LUA_LIBS="-L$lua_dir/lib -llua50"
128 LUA_INCLUDES="-I$lua_dir/include"
135 # we got lua, now look for lualib
137 AC_CHECK_LIB(lualib50, luaL_openlib,
139 LUA_LIBS="$LUA_LIBS -llualib50"
143 # Restore the versions of CFLAGS, CPPFLAGS,
144 # LDFLAGS, and LIBS before we added the
145 # "--with-lua=" directory, as we didn't
146 # actually find lua there.
148 CFLAGS="$save_CFLAGS"
149 CXXFLAGS="$save_CXXFLAGS"
150 CPPFLAGS="$save_CPPFLAGS"
151 LDFLAGS="$save_LDFLAGS"
154 # User requested --with-lua but it isn't available
155 if test "x$want_lua" = "xyes"
157 AC_MSG_ERROR(Linking with liblua failed.)
162 CFLAGS="$save_CFLAGS"
163 CXXFLAGS="$save_CXXFLAGS"
164 CPPFLAGS="$save_CPPFLAGS"
165 LDFLAGS="$save_LDFLAGS"
168 AC_SUBST(LUA_INCLUDES)
173 AC_ARG_ENABLE(scripting,
174 [ --disable-scripting Disable scripting support],
175 [case "${enableval}" in
176 yes) enable_scripting=yes ;;
177 no) enable_scripting=no ;;
178 *) AC_MSG_ERROR(bad value ${enableval} for --disable-scripting) ;;
179 esac],[enable_scripting=yes])
181 if test "$enable_scripting" = "no"; then
182 echo disabling scripting support
184 echo enabling scripting support
188 AC_DEFINE([ENABLE_SCRIPTING],[],[True if scripting is being used])
191 if test "$enable_scripting" = "yes"; then
193 AC_MSG_CHECKING(for lua)
196 [ --with-lua[[=DIR]] use liblua (located in directory DIR, if supplied) for the scripting. [[default=yes]]],
201 *) want_lua=yes; lua_dir="$withval" ;;
205 # Use liblua if it's present, otherwise don't.
210 if test "x$want_lua" = "xno" ; then
215 if test "x$want_lua" = "xno" ; then
216 AC_MSG_RESULT(liblua not found - disabling support for the lua scripting plugin)
219 AM_CONDITIONAL(HAVE_LIBLUA, test x$want_lua = xyes)
221 if test "x$want_lua" = "xno"; then
222 AC_MSG_ERROR([Lua is required for scripting])
226 AC_ARG_ENABLE(optimization,
227 [ --enable-optimization Enable program optimizations],
228 [case "${enableval}" in
229 yes) enable_optimization=yes ;;
230 no) enable_optimization=no ;;
231 *) AC_MSG_ERROR(bad value ${enableval} for --enable-optimizations) ;;
232 esac],[enable_optimization=no])
234 if test "$enable_optimization" = "yes"; then
235 OPTIMIZATION_FLAGS="-O6 -g1 -fomit-frame-pointer -falign-functions=4 -fexpensive-optimizations -fschedule-insns2 -finline-functions -funroll-loops"
237 OPTIMIZATION_FLAGS="-g -DDEBUG"
239 AC_SUBST(OPTIMIZATION_FLAGS)
241 # Checks for library functions.
242 AC_FUNC_CLOSEDIR_VOID
243 AC_CHECK_FUNCS([inet_ntoa memset socket strchr strtoul])
245 AC_CONFIG_FILES([ Makefile src/Makefile ])
250 avr-sim-$PACKAGE_VERSION is now configured for $canonical_host_type
254 Source directory: $srcdir
255 Installation prefix: $prefix
257 C compiler: $CC $CPPFLAGS $CFLAGS
258 C++ compiler: $CXX $CPPFLAGS $CXXFLAGS
260 scripting: $enable_scripting