aboutsummaryrefslogtreecommitdiffstats
path: root/moon-abe/pbc-0.5.14/configure.ac
blob: 79f564a17d3908ece4bce868441c6552397adc63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#-*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT([pbc], [0.5.14], [blynn@cs.stanford.edu])
AM_INIT_AUTOMAKE
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([./])
LT_INIT
#AC_CANONICAL_HOST

CFLAGS=
default_fink_path=/sw
case $host_os in
     darwin*) 
	      dnl fink installation
     	      AC_MSG_CHECKING([for a fink installation at $default_fink_path])
     	      if test -d $default_fink_path; then 
	      	 AC_MSG_RESULT([found it!])
		 AC_MSG_NOTICE([Adding -I$default_fink_path/include to CPPFLAGS])
	      	 CPPFLAGS="-I$default_fink_path/include $CPPFLAGS"
		 AC_MSG_NOTICE([Adding -L$default_fink_path/lib to LDFLAGS])
		 LDFLAGS="-L$default_fink_path/lib $LDFLAGS"
	      else
		AC_MSG_RESULT(none)
		AC_MSG_NOTICE([You may need to add set CPPFLAGS and LDFLAGS for gmp, etc.])
	      fi
	      ;;
esac

############################
# Configs for Windows DLLs.
# Framework for the below was extracted and
# modeled after the libgmp configure script.

AC_LIBTOOL_WIN32_DLL
AC_SUBST(LIBPBC_DLL,0)

case $host in
  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
    if test -z "$enable_shared"; then
      enable_shared=no
    fi
    # Don't allow both static and DLL.
    if test "$enable_shared" != no && test "$enable_static" != no; then
      AC_MSG_ERROR([cannot build both static and DLL, since gmp.h is different for each.
Use "--disable-static --enable-shared" to build just a DLL.])
    fi

    # "-no-undefined" is required when building a DLL, see documentation on
    # AC_LIBTOOL_WIN32_DLL.  Also, -no-undefined needs a version number
    # or it will complain about not having a nonnegative integer.
    if test "$enable_shared" = yes; then
      PBC_LDFLAGS="$PBC_LDFLAGS -no-undefined 0 -Wl,--export-all-symbols"
      LIBPBC_LDFLAGS="$LIBPBC_LDFLAGS -Wl,--output-def,.libs/libpbc.dll.def"
      LIBPBC_DLL=1
    fi
    ;;
esac
case $host in
  *-*-mingw*)
    gcc_cflags_optlist="$gcc_cflags_optlist nocygwin"
    gcc_cflags_nocygwin="-mno-cygwin"
    ;;
esac

AC_SUBST(PBC_LDFLAGS)
AC_SUBST(LIBPBC_LDFLAGS)
############################

# Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

AC_PROG_LEX
if test "x$LEX" != xflex; then
  echo "************************"
  echo "flex not found"
  echo "************************"
  exit -1
fi

AC_PROG_YACC
if test "x$YACC" != "xbison -y"; then
  echo "************************"
  echo "bison not found"
  echo "************************"
  exit -1
fi

# Checks for libraries.
lib_err_msg="add its path to LDFLAGS\nsee ./configure --help"
AC_CHECK_LIB( [m], [pow], [],[
	      echo "************************"
	      echo "m library not found"
	      echo -e $lib_err_msg
	      echo "************************"
	      exit -1
	      ])
AC_CHECK_LIB( [gmp], [__gmpz_init], [],[
	      echo "************************"
	      echo "gmp library not found"
	      echo -e $lib_err_msg
	      echo "************************"
	      exit -1
	      ])
dnl Reset libs because most programs do not need to link against all of these libs.
LIBS=

# Checks for header files.
AC_FUNC_ALLOCA
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h string.h sys/time.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_HEADER_TIME

dnl setup CFLAGS
with_enable_optimized="no"
AC_ARG_ENABLE( optimized, 
              [AS_HELP_STRING([--enable-optimized],
                              [Enable optimized build])],
              [with_enable_optimized="$withval"],
              [with_enable_optimized="no"])


with_safe_clean=n
AC_ARG_ENABLE( safe-clean,
              [AS_HELP_STRING([--enable-safe-clean],
                              [When free any PBC element or GMP mpz_t, fill internal memory inside the element by zero])],
              [with_safe_clean=y],
              [with_safe_clean=n])

with_debug=n
AC_ARG_ENABLE( debug,
              [AS_HELP_STRING([--enable-debug],
                              [Add extra debugging information. Forbid compiling optimization.])],
                              [with_debug=y],
                              [with_debug=n])

CFLAGS="$CFLAGS -Wall -W -Wfloat-equal -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wredundant-decls \
-Wendif-labels -Wshadow -pipe -ffast-math -U__STRICT_ANSI__ -std=gnu99"
if test "$with_debug" == "y"; then
    CFLAGS="$CFLAGS -g3 -O0"
elif test "$with_enable_optimized" != "no"; then
   	CFLAGS="$CFLAGS -g -O2"
else
	CFLAGS="$CFLAGS -fomit-frame-pointer -O3"
fi

if test "$with_safe_clean" != "n"; then
  CFLAGS="$CFLAGS -DSAFE_CLEAN"
fi

# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([floor gettimeofday memmove memset pow sqrt strchr strdup])

AC_CONFIG_FILES([Makefile example/Makefile gen/Makefile])
AC_OUTPUT

echo -ne "\n"
echo "global build variables"
echo "-----------------------------------------"
echo `date`
echo "host info:        $host"
echo "optimized build:  $with_enable_optimized"
echo "compiler (CC):    $CC"
echo "LDFLAGS:          $LDFLAGS"
echo "CPPFLAGS:         $CPPFLAGS"
echo "CFLAGS:           $CFLAGS"
echo "LEX:              $LEX"
echo "AM_LFLAGS:        $AM_LFLAGS"
echo "LFLAGS:           $LFLAGS"
echo "YACC:             $YACC"
echo "AM_YFLAGS:        $AM_YFLAGS"
echo "YFLAGS:           $YFLAGS"
echo "-----------------------------------------"
echo -ne "\n"

syscmd(bison -d -b pbc/parser pbc/parser.y)
syscmd(flex -o pbc/lex.yy.c --header-file=pbc/lex.yy.h pbc/parser.lex)