1# Process this file with autoconf to produce a configure script. 2 3# 4# autoconf setup 5# 6AC_PREREQ(2.53) 7AC_INIT([yasm], 8 m4_esyscmd([./YASM-VERSION-GEN.sh && tr -d '\n' <YASM-VERSION-FILE]), 9 [bug-yasm@tortall.net]) 10#AC_CONFIG_SRCDIR([src/main.c]) 11AC_CONFIG_AUX_DIR(config) 12AC_CONFIG_HEADER([config.h]) 13 14AM_INIT_AUTOMAKE([1.9.6 foreign]) 15AM_MAINTAINER_MODE 16 17# 18# autoconf command-line options 19# 20AC_ARG_ENABLE(debug, 21AC_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]) ;; 27esac]) 28 29AC_ARG_ENABLE(warnerror, 30AC_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]) ;; 35esac]) 36 37AC_ARG_ENABLE(profiling, 38AC_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]) ;; 43esac]) 44 45AC_ARG_ENABLE(gcov, 46AC_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]) ;; 51esac]) 52 53AC_ARG_ENABLE(python, 54AC_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]) ;; 59esac], enable_python="auto") 60 61AC_ARG_ENABLE(python-bindings, 62AC_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]) ;; 67esac], enable_python_bindings="no") 68 69# 70# Checks for programs. 71# 72AC_PROG_CPP 73AC_PROG_CC_STDC 74AC_PROG_INSTALL 75AC_PROG_LN_S 76#automake default ARFLAGS to "cru" 77AC_CHECK_TOOLS(AR,[$AR ar],[ar]) 78AC_PROG_RANLIB 79 80# REQUIRE a standard (ANSI/ISO) C compiler 81if test "$ac_cv_prog_cc_stdc" = no; then 82 AC_MSG_ERROR([A standard (ANSI/ISO C89) C compiler is required.]) 83fi 84 85# Check for xmlto (for rendering manpages, needed only for development) 86AC_CHECK_PROGS([XMLTO], [$XMLTO xmlto], [:]) 87if test "$XMLTO" = ":"; then 88 AC_MSG_WARN([xmlto not found, manpages will not be rebuilt.]) 89fi 90AM_CONDITIONAL(BUILD_MAN, test "$XMLTO" != ":") 91 92# Check for compiler output filename suffixes. 93AC_OBJEXT 94AC_EXEEXT 95 96# 97# Checks for libraries. 98# 99AM_WITH_DMALLOC 100 101# 102# Checks for header files. 103# 104AC_HEADER_STDC 105AC_CHECK_HEADERS([strings.h libgen.h unistd.h direct.h sys/stat.h]) 106 107# REQUIRE standard C headers 108if test "$ac_cv_header_stdc" != yes; then 109 AC_MSG_ERROR([Standard (ANSI/ISO C89) header files are required.]) 110fi 111 112# 113# Checks for typedefs, structures, and compiler characteristics. 114# 115AC_C_CONST 116AC_C_INLINE 117AC_C_PROTOTYPES 118AC_TYPE_SIZE_T 119AX_CREATE_STDINT_H([libyasm-stdint.h]) 120 121# 122# Checks for library functions. 123# 124AC_CHECK_FUNCS([abort toascii vsnprintf]) 125AC_CHECK_FUNCS([strsep mergesort getcwd]) 126AC_CHECK_FUNCS([popen ftruncate]) 127# Look for the case-insensitive comparison functions 128AC_CHECK_FUNCS([strcasecmp strncasecmp stricmp _stricmp strcmpi]) 129 130# 131# Check for gettext() and other i18n/l10n things. 132# 133ALL_LINGUAS="" 134AM_GNU_GETTEXT([external]) 135# autoheader templates for AM_GNU_GETTEXT checks. 136AH_TEMPLATE([ENABLE_NLS], []) 137AH_TEMPLATE([HAVE_CATGETS], []) 138AH_TEMPLATE([HAVE_GETTEXT], []) 139AH_TEMPLATE([HAVE_LC_MESSAGES], []) 140AH_TEMPLATE([HAVE_STPCPY], []) 141 142# Check for GNU C Library 143AH_TEMPLATE([HAVE_GNU_C_LIBRARY], [Define to 1 if you have the GNU C Library]) 144AC_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)) 151if test "$yasm_cv_header_gnulib" = yes; then 152 AC_DEFINE([HAVE_GNU_C_LIBRARY]) 153fi 154 155# Force x86 architecture only for now. 156ARCH=x86 157AC_SUBST([ARCH]) 158AC_SUBST([GCC]) 159 160# Require things for --enable-maintainer-mode option. 161if 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 193fi 194 195# 196# Add some more CFLAGS for various options. 197# 198 199if test "$debugging" = "no" ; then 200 changequote(,) 201 CFLAGS="`echo $CFLAGS' ' | sed -e 's/-g[0-9] //g' | sed -e 's/-g//g'`" 202 changequote([,]) 203fi 204 205# Turn warnings into errors 206if test "$warnerror" = "yes"; then 207 if test "$GCC" = "yes"; then 208 MORE_CFLAGS="$MORE_CFLAGS -Werror" 209 fi 210fi 211 212# Enable output of profiling information 213if test "$profiling" = "yes"; then 214 if test "$GCC" = "yes"; then 215 MORE_CFLAGS="$MORE_CFLAGS -pg" 216 fi 217fi 218 219# Enable output of gcov information 220if test "$gcov" = "yes"; then 221 if test "$GCC" = "yes"; then 222 MORE_CFLAGS="$MORE_CFLAGS -fprofile-arcs -ftest-coverage" 223 fi 224fi 225 226# If we're using GCC, then we can turn on -ansi -pedantic -Wall too. 227if test "$USE_MAINTAINER_MODE" = "yes"; then 228 if test "$GCC" = yes; then 229 MORE_CFLAGS="-ansi -pedantic -Wall $MORE_CFLAGS" 230 fi 231fi 232AC_SUBST(MORE_CFLAGS) 233 234AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler]) 235AC_ARG_VAR(CCLD_FOR_BUILD,[build system C linker frontend]) 236if test "${build}" != "${host}" ; then 237 CC_FOR_BUILD=${CC_FOR_BUILD-cc} 238 CCLD_FOR_BUILD=${CCLD_FOR_BUILD-cc} 239else 240 CC_FOR_BUILD="\$(CC)" 241 CCLD_FOR_BUILD="\$(CC)" 242fi 243AC_SUBST(CC_FOR_BUILD) 244AC_SUBST(CCLD_FOR_BUILD) 245 246AC_ARG_VAR(CPP_FOR_HOST,[host system C preprocessor]) 247if test "$build" != "$target" || test "$build" != "$host"; then 248 CPP_PROG="${CPP_FOR_HOST-cc -E}" 249else 250 CPP_PROG="${CPP}" 251fi 252AC_DEFINE_UNQUOTED([CPP_PROG], "${CPP_PROG}", [Command name to run C preprocessor]) 253 254# Detect if we have Python 255if test x$enable_python = xno; then 256 have_python=no 257else 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 275fi 276 277# Detect if we can build Python bindings 278# (needs Python, Python headers, and Cython) 279if test x$enable_python_bindings = xno; then 280 have_python_bindings=no 281else 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 305fi 306 307AM_CONDITIONAL(HAVE_PYTHON, test x$have_python = xyes) 308AM_CONDITIONAL(HAVE_PYTHON_BINDINGS, test x$have_python_bindings = xyes) 309 310AC_CONFIG_FILES([Makefile 311 po/Makefile.in 312]) 313AC_OUTPUT 314