summaryrefslogtreecommitdiffstats
path: root/moon-abe/cpabe-0.11/acinclude.m4
blob: 13ed28d423a41b075ceeaa51373ef013c19b0116 (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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
dnl Check for GNU MP (at least version 4.0) and set GMP_CFLAGS and
dnl GMP_LIBS appropriately.

AC_DEFUN([GMP_4_0_CHECK],
[

AC_MSG_CHECKING(for GMP version >= 4.0.0 or later)

AC_ARG_WITH(
  gmp-include,
  AC_HELP_STRING(
    [--with-gmp-include=DIR],
    [look for the header gmp.h in DIR rather than the default search path]),
  [GMP_CFLAGS="-I$withval"], [GMP_CFLAGS=""])

AC_ARG_WITH(
  gmp-lib,
  AC_HELP_STRING([--with-gmp-lib=DIR],
    [look for libgmp.so in DIR rather than the default search path]),
  [
    case $withval in
      /* ) true;;
      *  ) AC_MSG_ERROR([

You must specify an absolute path for --with-gmp-lib.
]) ;;
    esac
    GMP_LIBS="-L$withval -Wl,-rpath $withval -Wl,-rpath /usr/local/lib -lgmp"
  ], [GMP_LIBS="-Wl,-rpath /usr/local/lib -lgmp"])

BACKUP_CFLAGS=${CFLAGS}
BACKUP_LIBS=${LIBS}

CFLAGS="${CFLAGS} ${GMP_CFLAGS}"
LIBS="${LIBS} ${GMP_LIBS}"

AC_TRY_LINK(
  [#include <gmp.h>],
  [mpz_t a; mpz_init (a);],
  [
    AC_TRY_RUN(
      [
#include <gmp.h>
int main() { if (__GNU_MP_VERSION < 4) return -1; else return 0; }
],
      [
        AC_MSG_RESULT(found)
        AC_SUBST(GMP_CFLAGS)
        AC_SUBST(GMP_LIBS)
        AC_DEFINE(HAVE_GMP,1,[Defined if GMP is installed])
      ],
      [
        AC_MSG_RESULT(old version)
        AC_MSG_ERROR([

Your version of the GNU Multiple Precision library (libgmp) is too
old! Please install a more recent version from http://gmplib.org/ and
try again. If more than one version is installed, try specifying a
particular version with

  ./configure --with-gmp-include=DIR --with-gmp-lib=DIR

See ./configure --help for more information.
])
      ])
  ],
  [
    AC_MSG_RESULT(not found)
    AC_MSG_ERROR([

The GNU Multiple Precision library (libgmp) was not found on your
system! Please obtain it from http://gmplib.org/ and install it before
trying again. If libgmp is already installed in a non-standard
location, try again with

  ./configure --with-gmp-include=DIR --with-gmp-lib=DIR

If you already specified those arguments, double check that gmp.h can
be found in the first path and libgmp.a can be found in the second.

See ./configure --help for more information.
])
  ])

CFLAGS=${BACKUP_CFLAGS}
LIBS=${BACKUP_LIBS}

])

dnl Check for libpbc and set PBC_CFLAGS and PBC_LIBS
dnl appropriately.

AC_DEFUN([PBC_CHECK],
[

AC_MSG_CHECKING(for the PBC library)

AC_ARG_WITH(
  pbc-include,
  AC_HELP_STRING(
    [--with-pbc-include=DIR],
    [look for the header pbc.h in DIR rather than the default search path]),
  [PBC_CFLAGS="-I$withval"], [PBC_CFLAGS="-I/usr/include/pbc -I/usr/local/include/pbc"])

AC_ARG_WITH(
  pbc-lib,
  AC_HELP_STRING(
    [--with-pbc-lib=DIR],
    [look for libpbc.so in DIR rather than the default search path]),
  [
    case $withval in
      /* ) true;;
      *  ) AC_MSG_ERROR([

You must specify an absolute path for --with-pbc-lib.
]) ;;
    esac
    PBC_LIBS="-L$withval -Wl,-rpath $withval -Wl,-rpath /usr/local/lib -lpbc"
  ], [PBC_LIBS="-Wl,-rpath /usr/local/lib -lpbc"])

BACKUP_CFLAGS=${CFLAGS}
BACKUP_LIBS=${LIBS}

CFLAGS="${CFLAGS} ${PBC_CFLAGS} ${GMP_CFLAGS}"
LIBS="${LIBS} ${PBC_LIBS} ${GMP_LIBS}"

AC_TRY_LINK(
  [#include <pbc.h>],
  [pairing_t p; pairing_init_set_buf(p, "", 0);],
  [
    AC_MSG_RESULT(found)
    AC_SUBST(PBC_CFLAGS)
    AC_SUBST(PBC_LIBS)
    AC_DEFINE(HAVE_PBC,1,[Defined if PBC is installed])
  ],
  [
    AC_MSG_RESULT(not found)
    AC_MSG_ERROR([

The PBC library was not found on your system! Please obtain it from

  http://crypto.stanford.edu/pbc/

and install it before trying again. If libpbc is already
installed in a non-standard location, try again with

  ./configure --with-pbc-include=DIR --with-pbc-lib=DIR

If you already specified those arguments, double check that pbc.h can
be found in the first path and libpbc.a can be found in the second.

See ./configure --help for more information.
])
  ])

CFLAGS=${BACKUP_CFLAGS}
LIBS=${BACKUP_LIBS}

])

dnl Check for libbswabe and set BSWABE_CFLAGS and BSWABE_LIBS
dnl appropriately.

AC_DEFUN([BSWABE_CHECK],
[

AC_MSG_CHECKING(for libbswabe)

AC_ARG_WITH(
  bswabe-include,
  AC_HELP_STRING(
    [--with-bswabe-include=DIR],
    [look for the header bswabe.h in DIR rather than the default search path]),
  [BSWABE_CFLAGS="-I$withval"], [BSWABE_CFLAGS=""])

AC_ARG_WITH(
  bswabe-lib,
  AC_HELP_STRING(
    [--with-bswabe-lib=DIR],
    [look for libbswabe.a in DIR rather than the default search path]),
  [
    case $withval in
      /* ) true;;
      *  ) AC_MSG_ERROR([

You must specify an absolute path for --with-bswabe-lib.
]) ;;
    esac
    BSWABE_LIBS="-L$withval -lbswabe"
  ], [BSWABE_LIBS="-lbswabe"])

BACKUP_CFLAGS=${CFLAGS}
BACKUP_LIBS=${LIBS}

CFLAGS="${CFLAGS} ${BSWABE_CFLAGS} ${PBC_CFLAGS} ${GMP_CFLAGS} ${GLIB_CFLAGS}"
LIBS="${LIBS} ${BSWABE_LIBS} ${PBC_LIBS} ${GMP_LIBS} ${GLIB_LIBS}"

AC_TRY_LINK(
  [#include <glib.h>
   #include <pbc.h>
   #include <bswabe.h>],
  [bswabe_pub_t* p;
   bswabe_pub_free(p);],
  [
    AC_MSG_RESULT(found)
    AC_SUBST(BSWABE_CFLAGS)
    AC_SUBST(BSWABE_LIBS)
    AC_DEFINE(HAVE_BSWABE,1,[Defined if libbswabe is installed])
  ],
  [
    AC_MSG_RESULT(not found)
    AC_MSG_ERROR([

The library libbswabe was not found on your system! Please obtain it
from

  http://acsc.csl.sri.com/cpabe/

and install it before trying again. If libbswabe is already
installed in a non-standard location, try again with

  ./configure --with-bswabe-include=<path> --with-bswabe-lib=<path>

If you already specified those arguments, double check that bswabe.h
can be found in the first path and libbswabe.a can be found in the
second.

See ./configure --help for more information.
])
  ])

CFLAGS=${BACKUP_CFLAGS}
LIBS=${BACKUP_LIBS}

])