Fixed typo
[avr-sim.git] / configure.in
blob5c5f85b5bb4ba0ff316548abdfcc6f98ec29e1a0
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
4 AC_PREREQ(2.61)
5 AC_INIT(avr-sim, 1.0, thaber@uhasselt.be)
6 AC_CONFIG_SRCDIR([src/Instructions.h])
7 AC_CONFIG_HEADER([src/config.h])
8 AM_INIT_AUTOMAKE
10 # Checks for programs.
11 AC_PROG_AWK
12 AC_PROG_CXX
13 AC_PROG_CC
14 AC_PROG_INSTALL
15 AC_PROG_LN_S
16 AC_PROG_MAKE_SET
18 # Checks for libraries.
19 AC_LANG([C++])
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.
27 AC_HEADER_DIRENT
28 AC_HEADER_STDC
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.
32 AC_HEADER_STDBOOL
33 AC_C_CONST
34 AC_C_INLINE
35 AC_C_VOLATILE
38 # AC_LIBLUA_CHECK
40 AC_DEFUN([AC_LIBLUA_CHECK],[
42         if test "x$lua_dir" != "x"; then
43                 #
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.
48                 #
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.
54                 #
55                 save_CFLAGS="$CFLAGS"
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"
61                 save_LIBS="$LIBS"
62                 LIBS="$LIBS -L$lua_dir/lib -llua50"
63                 save_LDFLAGS="$LDFLAGS"
64                 LDFLAGS="$LDFLAGS -L$lua_dir/lib"
65         else
66                 #
67                 # The user specified no directory in which liblua resides,
68                 # so just add "-llua50 -llualib50" to the used libs.
69                 #
70                 save_CFLAGS="$CFLAGS"
71                 save_CXXLAGS="$CXXFLAGS"
72                 save_CPPFLAGS="$CPPFLAGS"
73                 save_LDFLAGS="$LDFLAGS"
74                 save_LIBS="$LIBS"
75                 LIBS="$LIBS -llua50"
76         fi
78         #
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.
81         #
82         AC_CHECK_HEADERS(lua50/lua.h lua50/lualib.h lua50/lauxlib.h,,
83         [
84                 if test "x$lua_dir" != "x"; then
85                         #
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.
91                         #
92                         AC_MSG_ERROR([liblua header not found in directory specified in --with-lua])
93                 else
94                         if test "x$want_lua" = "xyes"; then
95                                 #
96                                 # The user tried to force us to use the library, but we
97                                 # couldn't find the header file; report an error.
98                                 #
99                                 AC_MSG_ERROR(Header file lua.h not found.)
100                         else
101                                 #
102                                 # We couldn't find the header file; don't use the
103                                 # library, as it's probably not present.
104                                 #
105                                 want_lua=no
106                         fi
107                 fi
108         ])
110         if test "x$want_lua" != "xno"; then
111                 #
112                 # Well, we at least have the lua header file.
113                 #
114                 # let's check if the libs are there
115                 #
117         LIBS="$LIBS $LUA_LIBS -lm"
119                 AC_CHECK_LIB(lua50, lua_call,
120                 [
121                         if test "x$lua_dir" != "x"; then
122                                 #
123                                 # Put the "-I" and "-L" flags for lua at
124                                 # the beginning of CFLAGS, CPPFLAGS,
125                                 # LDFLAGS, and LIBS.
126                                 #
127                                 LUA_LIBS="-L$lua_dir/lib -llua50"
128                                 LUA_INCLUDES="-I$lua_dir/include"
129                         else
130                                 LUA_LIBS="-llua50"
131                                 LUA_INCLUDES=""
132                         fi
134                         #
135                         # we got lua, now look for lualib
136                         #
137                         AC_CHECK_LIB(lualib50, luaL_openlib,
138                         [
139                                 LUA_LIBS="$LUA_LIBS -llualib50"
140                         ])
141                 ],[
142                         #
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.
147                         #
148                         CFLAGS="$save_CFLAGS"
149                         CXXFLAGS="$save_CXXFLAGS"
150                         CPPFLAGS="$save_CPPFLAGS"
151                         LDFLAGS="$save_LDFLAGS"
152                         LIBS="$save_LIBS"
153                         LUA_LIBS=""
154                         # User requested --with-lua but it isn't available
155                         if test "x$want_lua" = "xyes"
156                         then
157                                 AC_MSG_ERROR(Linking with liblua failed.)
158                         fi
159                         want_lua=no
160                 ])
162         CFLAGS="$save_CFLAGS"
163         CXXFLAGS="$save_CXXFLAGS"
164         CPPFLAGS="$save_CPPFLAGS"
165         LDFLAGS="$save_LDFLAGS"
166         LIBS="$save_LIBS"
167         AC_SUBST(LUA_LIBS)
168         AC_SUBST(LUA_INCLUDES)
170         fi
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
183 else
184   echo enabling scripting support
185   [
186           enable_scripting=yes
187   ]
188   AC_DEFINE([ENABLE_SCRIPTING],[],[True if scripting is being used])
191 if test "$enable_scripting" = "yes"; then
192         dnl Check for lua
193         AC_MSG_CHECKING(for lua)
195         AC_ARG_WITH(lua,
196                         [  --with-lua[[=DIR]]       use liblua (located in directory DIR, if supplied) for the scripting.  [[default=yes]]],
197                         [
198                                 case "${withval}" in
199                                   yes) want_lua=yes ;;
200                                   no) want_lua=no ;;
201                                   *) want_lua=yes; lua_dir="$withval" ;;
202                                 esac
203                         ],[
204                                 #
205                                 # Use liblua if it's present, otherwise don't.
206                                 #
207                                 want_lua=no
208                                 lua_dir=
209                         ], [want_lua=no])
210         if test "x$want_lua" = "xno" ; then
211                 AC_MSG_RESULT(no)
212         else
213                 AC_MSG_RESULT(yes)
214                 AC_LIBLUA_CHECK
215                 if test "x$want_lua" = "xno" ; then
216                         AC_MSG_RESULT(liblua not found - disabling support for the lua scripting plugin)
217                 fi
218         fi
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])
223         fi
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"
236 else
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 ])
246 AC_OUTPUT
248 AC_MSG_RESULT([
250 avr-sim-$PACKAGE_VERSION is now configured for $canonical_host_type
252   Build:                $build
253   Host:                 $host
254   Source directory:     $srcdir
255   Installation prefix:  $prefix
256   $GCC
257   C compiler:           $CC $CPPFLAGS $CFLAGS
258   C++ compiler:         $CXX $CPPFLAGS $CXXFLAGS
260   scripting:            $enable_scripting