Home | History | Annotate | Download | only in patched-yasm
      1 # Process this file with autoconf to produce a configure script.
      2 
      3 #
      4 # autoconf setup
      5 #
      6 AC_PREREQ(2.53)
      7 AC_INIT([yasm],
      8        	m4_esyscmd([./YASM-VERSION-GEN.sh && tr -d '\n' <YASM-VERSION-FILE]),
      9         [bug-yasm (a] tortall.net])
     10 #AC_CONFIG_SRCDIR([src/main.c])
     11 AC_CONFIG_AUX_DIR(config)
     12 AC_CONFIG_HEADER([config.h])
     13 
     14 AM_INIT_AUTOMAKE([1.9.6 foreign])
     15 AM_MAINTAINER_MODE
     16 
     17 #
     18 # autoconf command-line options
     19 #
     20 AC_ARG_ENABLE(debug,
     21 AC_HELP_STRING([--enable-debug],
     22 	       [Turn on debugging and compile time warnings]),
     23 [case "${enableval}" in
     24   yes) debugging="yes" ;;
     25   no)  debugging="no" ;;
     26   *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
     27 esac])
     28 
     29 AC_ARG_ENABLE(warnerror,
     30 AC_HELP_STRING([--enable-warnerror],[Treat GCC warnings as errors]),
     31 [case "${enableval}" in
     32   yes) warnerror="yes" ;;
     33   no)  warnerror="no" ;;
     34   *) AC_MSG_ERROR([bad value ${enableval} for --enable-warnerror]) ;;
     35 esac])
     36 
     37 AC_ARG_ENABLE(profiling,
     38 AC_HELP_STRING([--enable-profiling],[Enable profiling (requires GCC)]),
     39 [case "${enableval}" in
     40   yes) profiling="yes" ;;
     41   no)  profiling="no" ;;
     42   *) AC_MSG_ERROR([bad value ${enableval} for --enable-profiling]) ;;
     43 esac])
     44 
     45 AC_ARG_ENABLE(gcov,
     46 AC_HELP_STRING([--enable-gcov],[Enable gcov code coverage (requires GCC)]),
     47 [case "${enableval}" in
     48   yes) gcov="yes" ;;
     49   no)  gcov="no" ;;
     50   *) AC_MSG_ERROR([bad value ${enableval} for --enable-gcov]) ;;
     51 esac])
     52 
     53 AC_ARG_ENABLE(python,
     54 AC_HELP_STRING([--enable-python],[Enable Python-requiring portions of build]),
     55 [case "${enableval}" in
     56   yes) enable_python="yes" ;;
     57   no)  enable_python="no" ;;
     58   *) AC_MSG_ERROR([bad value ${enableval} for --enable-python]) ;;
     59 esac], enable_python="auto")
     60 
     61 AC_ARG_ENABLE(python-bindings,
     62 AC_HELP_STRING([--enable-python-bindings],[Build Python bindings]),
     63 [case "${enableval}" in
     64   yes) enable_python_bindings="yes" ;;
     65   no)  enable_python_bindings="no" ;;
     66   *) AC_MSG_ERROR([bad value ${enableval} for --enable-python-bindings]) ;;
     67 esac], enable_python_bindings="no")
     68 
     69 #
     70 # Checks for programs.
     71 #
     72 AC_PROG_CPP
     73 AC_PROG_CC_STDC
     74 AC_PROG_INSTALL
     75 AC_PROG_LN_S
     76 #automake default ARFLAGS to "cru"
     77 AC_CHECK_TOOLS(AR,[$AR ar],[ar])
     78 AC_PROG_RANLIB
     79 
     80 # REQUIRE a standard (ANSI/ISO) C compiler
     81 if test "$ac_cv_prog_cc_stdc" = no; then
     82 	AC_MSG_ERROR([A standard (ANSI/ISO C89) C compiler is required.])
     83 fi
     84 
     85 # Check for xmlto (for rendering manpages, needed only for development)
     86 AC_CHECK_PROGS([XMLTO], [$XMLTO xmlto], [:])
     87 if test "$XMLTO" = ":"; then
     88   AC_MSG_WARN([xmlto not found, manpages will not be rebuilt.])
     89 fi
     90 AM_CONDITIONAL(BUILD_MAN, test "$XMLTO" != ":")
     91 
     92 # Check for compiler output filename suffixes.
     93 AC_OBJEXT
     94 AC_EXEEXT
     95 
     96 #
     97 # Checks for libraries.
     98 #
     99 AM_WITH_DMALLOC
    100 
    101 #
    102 # Checks for header files.
    103 #
    104 AC_HEADER_STDC
    105 AC_CHECK_HEADERS([strings.h libgen.h unistd.h direct.h sys/stat.h])
    106 
    107 # REQUIRE standard C headers
    108 if test "$ac_cv_header_stdc" != yes; then
    109 	AC_MSG_ERROR([Standard (ANSI/ISO C89) header files are required.])
    110 fi
    111 
    112 #
    113 # Checks for typedefs, structures, and compiler characteristics.
    114 #
    115 AC_C_CONST
    116 AC_C_INLINE
    117 AC_C_PROTOTYPES
    118 AC_TYPE_SIZE_T
    119 AX_CREATE_STDINT_H([libyasm-stdint.h])
    120 
    121 #
    122 # Checks for library functions.
    123 #
    124 AC_CHECK_FUNCS([abort toascii vsnprintf])
    125 AC_CHECK_FUNCS([strsep mergesort getcwd])
    126 AC_CHECK_FUNCS([popen ftruncate])
    127 # Look for the case-insensitive comparison functions
    128 AC_CHECK_FUNCS([strcasecmp strncasecmp stricmp _stricmp strcmpi])
    129 
    130 #
    131 # Check for gettext() and other i18n/l10n things.
    132 #
    133 ALL_LINGUAS=""
    134 AM_GNU_GETTEXT([external])
    135 # autoheader templates for AM_GNU_GETTEXT checks.
    136 AH_TEMPLATE([ENABLE_NLS], [])
    137 AH_TEMPLATE([HAVE_CATGETS], [])
    138 AH_TEMPLATE([HAVE_GETTEXT], [])
    139 AH_TEMPLATE([HAVE_LC_MESSAGES], [])
    140 AH_TEMPLATE([HAVE_STPCPY], [])
    141 
    142 # Check for GNU C Library
    143 AH_TEMPLATE([HAVE_GNU_C_LIBRARY], [Define to 1 if you have the GNU C Library])
    144 AC_CACHE_CHECK([for GNU C Library], yasm_cv_header_gnulib,
    145 	AC_EGREP_CPP(gnulib,
    146 	[#include <features.h>
    147 	#ifdef __GNU_LIBRARY__
    148 	  gnulib
    149 	#endif
    150 	], yasm_cv_header_gnulib=yes, yasm_cv_header_gnulib=no))
    151 if test "$yasm_cv_header_gnulib" = yes; then
    152 	AC_DEFINE([HAVE_GNU_C_LIBRARY])
    153 fi
    154 
    155 # Force x86 architecture only for now.
    156 ARCH=x86
    157 AC_SUBST([ARCH])
    158 AC_SUBST([GCC])
    159 
    160 # Require things for --enable-maintainer-mode option.
    161 if test "$USE_MAINTAINER_MODE" = "yes"; then
    162   # Enable debugging
    163   if test "$debugging" != "no"; then
    164     debugging=yes
    165   fi
    166 
    167   # Enable more warnings
    168   if test "$GCC" = "yes"; then
    169     MORE_CFLAGS="$MORE_CFLAGS -W"
    170     MORE_CFLAGS="$MORE_CFLAGS -Waggregate-return"
    171     MORE_CFLAGS="$MORE_CFLAGS -Wbad-function-cast"
    172     MORE_CFLAGS="$MORE_CFLAGS -Wcast-align"
    173     MORE_CFLAGS="$MORE_CFLAGS -Wcast-qual"
    174     MORE_CFLAGS="$MORE_CFLAGS -Wchar-subscripts"
    175 #    MORE_CFLAGS="$MORE_CFLAGS -Wconversion"
    176 #    MORE_CFLAGS="$MORE_CFLAGS -Wdeclaration-after-statement"
    177 #    MORE_CFLAGS="$MORE_CFLAGS -Wendif-labels"
    178     MORE_CFLAGS="$MORE_CFLAGS -Winline"
    179     MORE_CFLAGS="$MORE_CFLAGS -Wmissing-declarations"
    180     MORE_CFLAGS="$MORE_CFLAGS -Wmissing-prototypes"
    181     MORE_CFLAGS="$MORE_CFLAGS -Wnested-externs"
    182     MORE_CFLAGS="$MORE_CFLAGS -Wpointer-arith"
    183     MORE_CFLAGS="$MORE_CFLAGS -Wreturn-type"
    184     MORE_CFLAGS="$MORE_CFLAGS -Wshadow"
    185     MORE_CFLAGS="$MORE_CFLAGS -Wsign-compare"
    186     MORE_CFLAGS="$MORE_CFLAGS -Wstrict-prototypes"
    187     MORE_CFLAGS="$MORE_CFLAGS -Wswitch"
    188     MORE_CFLAGS="$MORE_CFLAGS -Wwrite-strings"
    189     MORE_CFLAGS="$MORE_CFLAGS -Wno-undef"
    190 #    MORE_CFLAGS="$MORE_CFLAGS -Wno-unused"
    191     MORE_CFLAGS="$MORE_CFLAGS -Wno-unused-parameter"
    192   fi
    193 fi
    194 
    195 #
    196 # Add some more CFLAGS for various options.
    197 #
    198 
    199 if test "$debugging" = "no" ; then
    200   changequote(,)
    201   CFLAGS="`echo $CFLAGS' ' | sed -e 's/-g[0-9] //g' | sed -e 's/-g//g'`"
    202   changequote([,])
    203 fi
    204 
    205 # Turn warnings into errors
    206 if test "$warnerror" = "yes"; then
    207   if test "$GCC" = "yes"; then
    208     MORE_CFLAGS="$MORE_CFLAGS -Werror"
    209   fi
    210 fi
    211 
    212 # Enable output of profiling information
    213 if test "$profiling" = "yes"; then
    214   if test "$GCC" = "yes"; then
    215     MORE_CFLAGS="$MORE_CFLAGS -pg"
    216   fi
    217 fi
    218 
    219 # Enable output of gcov information
    220 if test "$gcov" = "yes"; then
    221   if test "$GCC" = "yes"; then
    222     MORE_CFLAGS="$MORE_CFLAGS -fprofile-arcs -ftest-coverage"
    223   fi
    224 fi
    225 
    226 # If we're using GCC, then we can turn on -ansi -pedantic -Wall too.
    227 if test "$USE_MAINTAINER_MODE" = "yes"; then
    228   if test "$GCC" = yes; then
    229     MORE_CFLAGS="-ansi -pedantic -Wall $MORE_CFLAGS"
    230   fi
    231 fi
    232 AC_SUBST(MORE_CFLAGS)
    233 
    234 AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
    235 AC_ARG_VAR(CCLD_FOR_BUILD,[build system C linker frontend])
    236 if test "${build}" != "${host}" ; then
    237   CC_FOR_BUILD=${CC_FOR_BUILD-cc}
    238   CCLD_FOR_BUILD=${CCLD_FOR_BUILD-cc}
    239 else
    240   CC_FOR_BUILD="\$(CC)"
    241   CCLD_FOR_BUILD="\$(CC)"
    242 fi
    243 AC_SUBST(CC_FOR_BUILD)
    244 AC_SUBST(CCLD_FOR_BUILD)
    245 
    246 AC_ARG_VAR(CPP_FOR_HOST,[host system C preprocessor])
    247 if test "$build" != "$target" || test "$build" != "$host"; then
    248   CPP_PROG="${CPP_FOR_HOST-cc -E}"
    249 else
    250   CPP_PROG="${CPP}"
    251 fi
    252 AC_DEFINE_UNQUOTED([CPP_PROG], "${CPP_PROG}", [Command name to run C preprocessor])
    253 
    254 # Detect if we have Python
    255 if test x$enable_python = xno; then
    256     have_python=no
    257 else
    258     AC_MSG_NOTICE([Checking for Python])
    259     have_python=no
    260     AM_PATH_PYTHON(2.4,[],[AC_MSG_WARN([Python not found])])
    261 
    262     if test -z "$PYTHON" || test "$PYTHON" = : ; then
    263         have_python=no
    264     else
    265         have_python=yes
    266     fi
    267 
    268     if test x$have_python = xno ; then
    269         if test x$enable_python = xyes ; then
    270             AC_MSG_ERROR([Python explicitly requested, but a suitable Python version was not found])
    271         else
    272             AC_MSG_WARN([Could not find a suitable version of Python])
    273         fi
    274     fi
    275 fi
    276 
    277 # Detect if we can build Python bindings
    278 # (needs Python, Python headers, and Cython)
    279 if test x$enable_python_bindings = xno; then
    280     have_python_bindings=no
    281 else
    282     AC_MSG_NOTICE([Checking to see if we can build Python bindings])
    283     have_python_bindings=no
    284     if test x$have_python = xyes; then
    285         AC_MSG_CHECKING([for Cython >= 0.11.3])
    286         CYTHON_CHECK_VERSION(0.11.3, [AC_MSG_RESULT(yes)
    287                                       have_cython=yes],
    288                                      [AC_MSG_RESULT(no)
    289                                       have_cython=no])
    290 
    291         AM_CHECK_PYTHON_HEADERS(have_python_headers=yes,have_python_headers=no)
    292 
    293         if test x$have_cython = xyes -a x$have_python_headers = xyes ; then
    294             have_python_bindings=yes
    295         fi
    296     fi
    297 
    298     if test x$have_python_bindings = xno ; then
    299         if test x$enable_python_bindings = xyes ; then
    300             AC_MSG_ERROR([Building Python bindings explicitly requested, but can't build Python bindings because either Cython, Python headers or a suitable Python version was not found])
    301         else
    302             AC_MSG_WARN([Couldn't find either Cython, the Python headers or a suitable version of Python, not building Python bindings])
    303         fi
    304     fi
    305 fi
    306 
    307 AM_CONDITIONAL(HAVE_PYTHON, test x$have_python = xyes)
    308 AM_CONDITIONAL(HAVE_PYTHON_BINDINGS, test x$have_python_bindings = xyes)
    309 
    310 AC_CONFIG_FILES([Makefile
    311 	po/Makefile.in
    312 ])
    313 AC_OUTPUT
    314