* configure.ac: New switch for disabling -O2 (--disable-optimizations).
[cacao.git] / m4 / disassembler.m4
1 dnl m4/disassembler.m4
2 dnl
3 dnl Copyright (C) 2008
4 dnl CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 dnl 
6 dnl This file is part of CACAO.
7 dnl 
8 dnl This program is free software; you can redistribute it and/or
9 dnl modify it under the terms of the GNU General Public License as
10 dnl published by the Free Software Foundation; either version 2, or (at
11 dnl your option) any later version.
12 dnl 
13 dnl This program is distributed in the hope that it will be useful, but
14 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
15 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 dnl General Public License for more details.
17 dnl 
18 dnl You should have received a copy of the GNU General Public License
19 dnl along with this program; if not, write to the Free Software
20 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 dnl 02110-1301, USA.
22
23
24 dnl check for disassembler support
25
26 AC_DEFUN([AC_CHECK_ENABLE_DISASSEMBLER],[
27 AC_MSG_CHECKING(whether disassembler should be enabled)
28 AC_ARG_ENABLE([disassembler],
29               [AS_HELP_STRING(--enable-disassembler,enable disassembler [[default=no]])],
30               [case "${enableval}" in
31                    yes) ENABLE_DISASSEMBLER=yes;;
32                    *) ENABLE_DISASSEMBLER=no;;
33                esac],
34               [ENABLE_DISASSEMBLER=no])
35 AC_MSG_RESULT(${ENABLE_DISASSEMBLER})
36 AM_CONDITIONAL([ENABLE_DISASSEMBLER], test x"${ENABLE_DISASSEMBLER}" = "xyes")
37
38 if test x"${ENABLE_DISASSEMBLER}" = "xyes"; then
39     AC_DEFINE([ENABLE_DISASSEMBLER], 1, [enable disassembler])
40
41     dnl check for binutils headers and libraries on some architectures for the
42     dnl disassembler
43     case "${ARCH_DIR}" in
44         arm | i386 | powerpc | x86_64 | sparc64 | powerpc64 | s390 | m68k)
45             AC_CHECK_HEADER([ansidecl.h],, [AC_MSG_ERROR(cannot find ansidecl.h)])
46             AC_CHECK_HEADER([symcat.h],, [AC_MSG_ERROR(cannot find symcat.h)])
47             AC_CHECK_HEADER([bfd.h],, [AC_MSG_ERROR(cannot find bfd.h)])
48             AC_CHECK_HEADER([dis-asm.h],, [AC_MSG_ERROR(cannot find dis-asm.h)])
49
50             case "${OS_DIR}" in
51                 cygwin | darwin | netbsd | solaris)
52                      AC_CHECK_LIB(intl, dcgettext,, [AC_MSG_ERROR(cannot find libintl (from binutils))])
53                      ;;
54             esac
55
56             case "${OS_DIR}" in
57                 solaris)
58                                          AC_CHECK_LIB(rt, sem_init,, [AC_MSG_ERROR(cannot find librt)])
59                      ;;
60             esac
61
62
63             AC_CHECK_LIB(iberty, xstrerror,, [AC_MSG_ERROR(cannot find libiberty (from binutils))])
64             AC_CHECK_LIB(bfd, bfd_get_arch,, [AC_MSG_ERROR(cannot find libbfd (from binutils))])
65             AC_CHECK_LIB(opcodes, disassembler,, [AC_MSG_ERROR(cannot find libopcodes (from binutils))])
66             AC_DEFINE([WITH_BINUTILS_DISASSEMBLER], 1, [use binutils disassembler])
67             AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [true])
68             ;;
69         * )
70             AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [false])
71             ;;
72     esac
73 else
74     AM_CONDITIONAL([WITH_BINUTILS_DISASSEMBLER], [false])
75 fi
76 ])