1#-*- Autoconf -*- 2# Process this file with autoconf to produce a configure script. 3 4AC_PREREQ(2.59) 5AC_INIT([pbc], [0.5.14], [blynn@cs.stanford.edu]) 6AM_INIT_AUTOMAKE 7AC_CONFIG_HEADERS(config.h) 8AC_CONFIG_MACRO_DIR([m4]) 9AC_CONFIG_SRCDIR([./]) 10LT_INIT 11#AC_CANONICAL_HOST 12 13CFLAGS= 14default_fink_path=/sw 15case $host_os in 16 darwin*) 17 dnl fink installation 18 AC_MSG_CHECKING([for a fink installation at $default_fink_path]) 19 if test -d $default_fink_path; then 20 AC_MSG_RESULT([found it!]) 21 AC_MSG_NOTICE([Adding -I$default_fink_path/include to CPPFLAGS]) 22 CPPFLAGS="-I$default_fink_path/include $CPPFLAGS" 23 AC_MSG_NOTICE([Adding -L$default_fink_path/lib to LDFLAGS]) 24 LDFLAGS="-L$default_fink_path/lib $LDFLAGS" 25 else 26 AC_MSG_RESULT(none) 27 AC_MSG_NOTICE([You may need to add set CPPFLAGS and LDFLAGS for gmp, etc.]) 28 fi 29 ;; 30esac 31 32############################ 33# Configs for Windows DLLs. 34# Framework for the below was extracted and 35# modeled after the libgmp configure script. 36 37AC_LIBTOOL_WIN32_DLL 38AC_SUBST(LIBPBC_DLL,0) 39 40case $host in 41 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) 42 if test -z "$enable_shared"; then 43 enable_shared=no 44 fi 45 # Don't allow both static and DLL. 46 if test "$enable_shared" != no && test "$enable_static" != no; then 47 AC_MSG_ERROR([cannot build both static and DLL, since gmp.h is different for each. 48Use "--disable-static --enable-shared" to build just a DLL.]) 49 fi 50 51 # "-no-undefined" is required when building a DLL, see documentation on 52 # AC_LIBTOOL_WIN32_DLL. Also, -no-undefined needs a version number 53 # or it will complain about not having a nonnegative integer. 54 if test "$enable_shared" = yes; then 55 PBC_LDFLAGS="$PBC_LDFLAGS -no-undefined 0 -Wl,--export-all-symbols" 56 LIBPBC_LDFLAGS="$LIBPBC_LDFLAGS -Wl,--output-def,.libs/libpbc.dll.def" 57 LIBPBC_DLL=1 58 fi 59 ;; 60esac 61case $host in 62 *-*-mingw*) 63 gcc_cflags_optlist="$gcc_cflags_optlist nocygwin" 64 gcc_cflags_nocygwin="-mno-cygwin" 65 ;; 66esac 67 68AC_SUBST(PBC_LDFLAGS) 69AC_SUBST(LIBPBC_LDFLAGS) 70############################ 71 72# Checks for programs. 73AC_PROG_CC 74AM_PROG_CC_C_O 75AC_PROG_CPP 76AC_PROG_INSTALL 77AC_PROG_LN_S 78AC_PROG_MAKE_SET 79 80AC_PROG_LEX 81if test "x$LEX" != xflex; then 82 echo "************************" 83 echo "flex not found" 84 echo "************************" 85 exit -1 86fi 87 88AC_PROG_YACC 89if test "x$YACC" != "xbison -y"; then 90 echo "************************" 91 echo "bison not found" 92 echo "************************" 93 exit -1 94fi 95 96# Checks for libraries. 97lib_err_msg="add its path to LDFLAGS\nsee ./configure --help" 98AC_CHECK_LIB( [m], [pow], [],[ 99 echo "************************" 100 echo "m library not found" 101 echo -e $lib_err_msg 102 echo "************************" 103 exit -1 104 ]) 105AC_CHECK_LIB( [gmp], [__gmpz_init], [],[ 106 echo "************************" 107 echo "gmp library not found" 108 echo -e $lib_err_msg 109 echo "************************" 110 exit -1 111 ]) 112dnl Reset libs because most programs do not need to link against all of these libs. 113LIBS= 114 115# Checks for header files. 116AC_FUNC_ALLOCA 117AC_HEADER_STDC 118AC_CHECK_HEADERS([stdlib.h string.h sys/time.h]) 119 120# Checks for typedefs, structures, and compiler characteristics. 121AC_C_CONST 122AC_C_INLINE 123AC_TYPE_SIZE_T 124AC_HEADER_TIME 125 126dnl setup CFLAGS 127with_enable_optimized="no" 128AC_ARG_ENABLE( optimized, 129 [AS_HELP_STRING([--enable-optimized], 130 [Enable optimized build])], 131 [with_enable_optimized="$withval"], 132 [with_enable_optimized="no"]) 133 134 135with_safe_clean=n 136AC_ARG_ENABLE( safe-clean, 137 [AS_HELP_STRING([--enable-safe-clean], 138 [When free any PBC element or GMP mpz_t, fill internal memory inside the element by zero])], 139 [with_safe_clean=y], 140 [with_safe_clean=n]) 141 142with_debug=n 143AC_ARG_ENABLE( debug, 144 [AS_HELP_STRING([--enable-debug], 145 [Add extra debugging information. Forbid compiling optimization.])], 146 [with_debug=y], 147 [with_debug=n]) 148 149CFLAGS="$CFLAGS -Wall -W -Wfloat-equal -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wredundant-decls \ 150-Wendif-labels -Wshadow -pipe -ffast-math -U__STRICT_ANSI__ -std=gnu99" 151if test "$with_debug" == "y"; then 152 CFLAGS="$CFLAGS -g3 -O0" 153elif test "$with_enable_optimized" != "no"; then 154 CFLAGS="$CFLAGS -g -O2" 155else 156 CFLAGS="$CFLAGS -fomit-frame-pointer -O3" 157fi 158 159if test "$with_safe_clean" != "n"; then 160 CFLAGS="$CFLAGS -DSAFE_CLEAN" 161fi 162 163# Checks for library functions. 164AC_FUNC_MALLOC 165AC_FUNC_REALLOC 166AC_CHECK_FUNCS([floor gettimeofday memmove memset pow sqrt strchr strdup]) 167 168AC_CONFIG_FILES([Makefile example/Makefile gen/Makefile]) 169AC_OUTPUT 170 171echo -ne "\n" 172echo "global build variables" 173echo "-----------------------------------------" 174echo `date` 175echo "host info: $host" 176echo "optimized build: $with_enable_optimized" 177echo "compiler (CC): $CC" 178echo "LDFLAGS: $LDFLAGS" 179echo "CPPFLAGS: $CPPFLAGS" 180echo "CFLAGS: $CFLAGS" 181echo "LEX: $LEX" 182echo "AM_LFLAGS: $AM_LFLAGS" 183echo "LFLAGS: $LFLAGS" 184echo "YACC: $YACC" 185echo "AM_YFLAGS: $AM_YFLAGS" 186echo "YFLAGS: $YFLAGS" 187echo "-----------------------------------------" 188echo -ne "\n" 189 190syscmd(bison -d -b pbc/parser pbc/parser.y) 191syscmd(flex -o pbc/lex.yy.c --header-file=pbc/lex.yy.h pbc/parser.lex) 192