summaryrefslogtreecommitdiffstats
path: root/configure.ac
blob: 5497d9d2e1e44669212adf3c4dcfdc058be7d0d1 (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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.2)
AC_INIT(lasso/lasso.c)
AM_CONFIG_HEADER(config.h)
AC_CANONICAL_HOST


LASSO_PACKAGE=lasso
LASSO_VERSION_MAJOR=0
LASSO_VERSION_MINOR=1
LASSO_VERSION_SUBMINOR=0
LASSO_VERSION="$LASSO_VERSION_MAJOR.$LASSO_VERSION_MINOR.$LASSO_VERSION_SUBMINOR"
LASSO_VERSION_INFO=`echo $LASSO_VERSION | awk -F. '{ printf "%d:%d:%d", $1+$2, $3, $2 }'`
LASSO_VERSION_SAFE=`echo $LASSO_VERSION | sed 's/\./_/g'`

PACKAGE=$LASSO_PACKAGE
VERSION=$LASSO_VERSION

AC_SUBST(LASSO_VERSION)
AC_SUBST(LASSO_PACKAGE)
AC_SUBST(LASSO_VERSION_SAFE)
AC_SUBST(LASSO_VERSION_MAJOR)
AC_SUBST(LASSO_VERSION_MINOR)
AC_SUBST(LASSO_VERSION_SUBMINOR)
AC_SUBST(LASSO_VERSION_INFO)

AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
AM_MAINTAINER_MODE

dnl
dnl Check the environment
dnl
AC_PROG_CC
AC_PROG_LIBTOOL
AC_PROG_INSTALL
AC_STDC_HEADERS
AC_PATH_PROG(RM, rm, /bin/rm)
AC_PATH_PROG(CP, cp, /bin/cp)
AC_PATH_PROG(MV, mv, /bin/mv)
AC_PATH_PROG(TAR, tar, /bin/tar)
AC_PATH_PROG(HELP2MAN, help2man)
AC_PATH_PROG(MAN2HTML, man2html)

LIBTOOL_EXPORT_OPTIONS='-export-symbols-regex "^[^_].*"'

dnl Make sure we have an ANSI compiler
AM_C_PROTOTYPES
test "z$U" != "z" && AC_MSG_ERROR(Compiler not ANSI compliant)

dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS([stdio.h])
AC_CHECK_HEADERS([stdlib.h])
AC_CHECK_HEADERS([string.h])
AC_CHECK_HEADERS([ctype.h])
AC_CHECK_HEADERS([errno.h])
AC_CHECK_HEADERS([ansidecl.h])
AC_CHECK_HEADERS([time.h])
AC_CHECK_FUNCS(printf sprintf fprintf snprintf vfprintf vsprintf vsnprintf sscanf timegm)

dnl AC_LIB_LTDL

LASSO_DEFINES=""

dnl ==========================================================================
dnl Perform host specific configuration
dnl ==========================================================================
case "${host}" in
    *aix* )
	CFLAGS="${CFLAGS} -D_ALL_SOURCE"
	;;
esac

dnl ==========================================================================
dnl Check for __FUNCTION__ or __FUNCTION__
dnl ==========================================================================
AC_MSG_CHECKING(for __FUNCTION__ or __func__)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
	[[char *foo = __FUNCTION__;]])],
	[ac_function_exists=yes],
	[ac_function_exists=no])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
	[[char *foo = __func__;]])],
	[ac_func_exists=yes],
	[ac_func_exists=no])
if test "z$ac_function_exists" = "zyes" ; then
	AC_MSG_RESULT(__FUNCTION__)
	LASSO_DEFINES="$LASSO_DEFINES -D__LASSO_FUNCTION__=__FUNCTION__"
elif test "z$ac_func_exists" = "zyes" ; then 
	AC_MSG_RESULT(__func__)
	LASSO_DEFINES="$LASSO_DEFINES -D__LASSO_FUNCTION__=__func__"
else 
	AC_MSG_RESULT("no")
fi

dnl ==========================================================================
dnl check do we have size_t and its size, 
dnl TODO: will need to replace this and the lassoSize define with 
dnl typedef on next ABI refresh
dnl ==========================================================================
AC_CHECK_SIZEOF(size_t)
if test "$ac_cv_sizeof_size_t" -ne "4" ; then
    LASSO_DEFINES="$LASSO_DEFINES -DLASSO_NO_SIZE_T"
fi


dnl ==========================================================================
dnl Check if pkg-config enabled and installed
dnl ==========================================================================
AC_ARG_ENABLE(sha1,   [  --enable-pkgconfig      enable pkgconfig for configuration (yes)])
if test "z$enable_pkgconfig" = "zno" ; then
    PKG_CONFIG_ENABLED=no
else
    AC_CHECK_PROG(PKG_CONFIG_ENABLED, pkg-config, yes, no)
    if test "z$PKG_CONFIG_ENABLED" = "zyes" ; then
	if ! pkg-config --atleast-pkgconfig-version 0.9 ; then
	    PKG_CONFIG_ENABLED=no
	fi
    fi
fi

dnl ==========================================================================
dnl find glib
dnl ==========================================================================
GLIB_MIN_VERSION="2.2.3"
GLIB_CONFIG="glib-config"
GLIB_CFLAGS=""
GLIB_LIBS=""
GLIB_FOUND="no"
AC_ARG_WITH(glib, [  --with-glib=[PFX]       glib location])
if test "z$with_glib" = "zno" ; then 
    AC_MSG_CHECKING(for glib libraries >= $GLIB_MIN_VERSION) 
    AC_MSG_ERROR(glib >= $GLIB_MIN_VERSION is required for $PACKAGE)
elif test "z$with_glib" = "z" -a "z$PKG_CONFIG_ENABLED" = "zyes" ; then
    PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_MIN_VERSION,
	[GLIB_FOUND=yes],
	[GLIB_FOUND=no])
fi

if test "z$GLIB_FOUND" = "zno" ; then
    AC_MSG_CHECKING(for glib libraries >= $GLIB_MIN_VERSION) 
    if test "z$with_glib" != "z" ; then 
	GLIB_CONFIG=$with_glib/bin/$GLIB_CONFIG
    fi
    if ! $GLIB_CONFIG --version > /dev/null 2>&1 ; then
	AC_MSG_ERROR(Could not find glib anywhere (see config.log for details).)
    fi
    vers=`$GLIB_CONFIG --version | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
    minvers=`echo $GLIB_MIN_VERSION | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
    if test "$vers" -ge "$minvers" ; then
        GLIB_LIBS="`$GLIB_CONFIG --libs`"
        GLIB_CFLAGS="`$GLIB_CONFIG --cflags`"
	GLIB_FOUND="yes"
        AC_MSG_RESULT(yes ('$GLIB_VERSION'))
    else
        AC_MSG_ERROR(You need at least glib $GLIB_MIN_VERSION for this version of $PACKAGE)
    fi
fi

AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
AC_SUBST(GLIB_CONFIG)
AC_SUBST(GLIB_MIN_VERSION)

dnl ==========================================================================
dnl find libxml
dnl ==========================================================================
LIBXML_MIN_VERSION="2.4.2"
LIBXML_CONFIG="xml2-config"
LIBXML_CFLAGS=""
LIBXML_LIBS=""
LIBXML_FOUND="no"
LIBXML262_FOUND="no"
AC_ARG_WITH(libxml, [  --with-libxml=[PFX]       libxml2 location])
if test "z$with_libxml" = "zno" ; then 
    AC_MSG_CHECKING(for libxml2 libraries >= $LIBXML_MIN_VERSION) 
    AC_MSG_ERROR(libxml2 >= $LIBXML_MIN_VERSION is required for $PACKAGE)
elif test "z$with_libxml" = "z" -a "z$PKG_CONFIG_ENABLED" = "zyes" ; then
    PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= $LIBXML_MIN_VERSION,
	[LIBXML_FOUND=yes],
	[LIBXML_FOUND=no])
    PKG_CHECK_MODULES(LIBXML262, libxml-2.0 >= 2.6.2,
	[LIBXML262_FOUND=yes],
	[LIBXML262_FOUND=no])
fi

if test "z$LIBXML_FOUND" = "zno" ; then
    AC_MSG_CHECKING(for libxml2 libraries >= $LIBXML_MIN_VERSION) 
    if test "z$with_libxml" != "z" ; then 
	LIBXML_CONFIG=$with_libxml/bin/$LIBXML_CONFIG
    fi
    if ! $LIBXML_CONFIG --version > /dev/null 2>&1 ; then
	AC_MSG_ERROR(Could not find libxml2 anywhere (see config.log for details).)
    fi
    vers=`$LIBXML_CONFIG --version | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
    minvers=`echo $LIBXML_MIN_VERSION | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
    if test "$vers" -ge "$minvers" ; then
        LIBXML_LIBS="`$LIBXML_CONFIG --libs`"
        LIBXML_CFLAGS="`$LIBXML_CONFIG --cflags`"
	LIBXML_FOUND="yes"
	if test "$vers" -ge "2006002" ;  then 
	    LIBXML262_FOUND="yes"
	fi
        AC_MSG_RESULT(yes ('$LIBXML_VERSION'))
    else
        AC_MSG_ERROR(You need at least libxml2 $LIBXML_MIN_VERSION for this version of $PACKAGE)
    fi
fi

if test "z$LIBXML_FOUND" = "zyes" ; then
    if test "z$LIBXML262_FOUND" = "zyes" ; then
	LASSO_DEFINES="-DLASSO_LIBXML_260=1 $LASSO_DEFINES"
    elif test "z$ac_cv_func_snprintf" != "zyes" -o "z$ac_cv_func_vsnprintf" != "zyes" ; then
	AC_MSG_ERROR(Functions snprintf and/or vsnprintf are not available on your platform. You need at least libxml2 2.6.2 for this version of $PACKAGE)
    fi
fi
AC_SUBST(LIBXML_CFLAGS)
AC_SUBST(LIBXML_LIBS)
AC_SUBST(LIBXML_CONFIG)
AC_SUBST(LIBXML_MIN_VERSION)

dnl ==========================================================================
dnl find libxslt
dnl ==========================================================================
LASSO_NO_LIBXSLT="1"
LIBXSLT_MIN_VERSION=1.0.20
LIBXSLT_CONFIG="xslt-config"
LIBXSLT_CFLAGS=""
LIBXSLT_LIBS=""
LIBXSLT_FOUND="no"
AC_ARG_WITH(libxslt, [  --with-libxslt=[PFX]      libxslt location])
if test "z$with_libxslt" = "zno" ; then
    AC_MSG_CHECKING(for libxslt libraries >= $LIBXSLT_MIN_VERSION) 
    AC_MSG_RESULT(no)
    LIBXSLT_FOUND="without"
elif test "z$with_libxslt" = "z" -a  "z$PKG_CONFIG_ENABLED" = "zyes" ; then
    PKG_CHECK_MODULES(LIBXSLT, libxslt >= $LIBXSLT_MIN_VERSION,
	[LIBXSLT_FOUND=yes],
	[LIBXSLT_FOUND=no])
fi

if test "z$LIBXSLT_FOUND" = "zno" ; then
    AC_MSG_CHECKING(for libxslt libraries >= $LIBXSLT_MIN_VERSION) 
    if test "z$LIBXSLT_CONFIG" != "z" ; then 
	LIBXSLT_CONFIG=$with_libxslt/bin/$LIBXSLT_CONFIG
    fi
    if ! $LIBXSLT_CONFIG --version > /dev/null 2>&1 ; then
	if test "z$with_libxslt" != "z" ; then
	    AC_MSG_ERROR(Unable to find libxslt at '$with_libxslt')
	else 
	    AC_MSG_RESULT(no)
	fi
    else
        vers=`$LIBXSLT_CONFIG --version | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
	minvers=`echo $LIBXSLT_MIN_VERSION | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
	if test "$vers" -ge "$minvers" ; then
    	    LIBXSLT_LIBS="`$LIBXSLT_CONFIG --libs`"
	    LIBXSLT_CFLAGS="`$LIBXSLT_CONFIG --cflags`"
    	    AC_MSG_RESULT(yes ('$LIBXSLT_VERSION'))
	else
    	    AC_MSG_ERROR(You need at least libxslt $LIBXSLT_MIN_VERSION for this version of $PACKAGE)
	fi	
    fi
fi

if test "z$LIBXSLT_FOUND" = "zyes" ; then
    LASSO_NO_LIBXSLT="0"
else
    LASSO_DEFINES="$LASSO_DEFINES -DLASSO_NO_XSLT=1"
fi

AC_SUBST(LASSO_NO_LIBXSLT)
AC_SUBST(LIBXSLT_CFLAGS)
AC_SUBST(LIBXSLT_LIBS)
AC_SUBST(LIBXSLT_CONFIG)
AC_SUBST(LIBXSLT_MIN_VERSION)

dnl ==========================================================================
dnl find xmlsec1
dnl ==========================================================================
XMLSEC1_MIN_VERSION="1.2.4"
XMLSEC1_CONFIG="xmlsec1-config"
XMLSEC1_CFLAGS=""
XMLSEC1_LIBS=""
XMLSEC1_FOUND="no"
AC_ARG_WITH(xmlsec1, [  --with-xmlsec1=[PFX]       xmlsec1 location])
if test "z$with_xmlsec1" = "zno" ; then 
    AC_MSG_CHECKING(for xmlsec1 libraries >= $XMLSEC1_MIN_VERSION) 
    AC_MSG_ERROR(xmlsec1 >= $XMLSEC1_MIN_VERSION is required for $PACKAGE)
elif test "z$with_xmlsec1" = "z" -a "z$PKG_CONFIG_ENABLED" = "zyes" ; then
    PKG_CHECK_MODULES(XMLSEC1, xmlsec1 >= $XMLSEC1_MIN_VERSION,
	[XMLSEC1_FOUND=yes],
	[XMLSEC1_FOUND=no])
fi

if test "z$XMLSEC1_FOUND" = "zno" ; then
    AC_MSG_CHECKING(for xmlsec1 libraries >= $XMLSEC1_MIN_VERSION) 
    if test "z$with_xmlsec1" != "z" ; then 
	XMLSEC1_CONFIG=$with_xmlsec1/bin/$XMLSEC1_CONFIG
    fi
    if ! $XMLSEC1_CONFIG --version > /dev/null 2>&1 ; then
	AC_MSG_ERROR(Could not find xmlsec1 anywhere (see config.log for details).)
    fi
    vers=`$XMLSEC1_CONFIG --version | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
    minvers=`echo $XMLSEC1_MIN_VERSION | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
    if test "$vers" -ge "$minvers" ; then
        XMLSEC1_LIBS="`$XMLSEC1_CONFIG --libs`"
        XMLSEC1_CFLAGS="`$XMLSEC1_CONFIG --cflags`"
	XMLSEC1_FOUND="yes"
        AC_MSG_RESULT(yes ('$XMLSEC1_VERSION'))
    else
        AC_MSG_ERROR(You need at least xmlsec1 $XMLSEC1_MIN_VERSION for this version of $PACKAGE)
    fi
fi

AC_SUBST(XMLSEC1_CFLAGS)
AC_SUBST(XMLSEC1_LIBS)
AC_SUBST(XMLSEC1_CONFIG)
AC_SUBST(XMLSEC1_MIN_VERSION)

dnl ==========================================================================
dnl find gtk-doc
dnl ==========================================================================
AC_ARG_WITH(html-dir, [  --with-html-dir=PATH path to installed docs ])

if test "x$with_html_dir" = "x" ; then
  HTML_DIR='${datadir}/gtk-doc/html'
else
  HTML_DIR=$with_html_dir
fi

AC_SUBST(HTML_DIR)

gtk_doc_min_version=1.0
AC_MSG_CHECKING([gtk-doc version >= $gtk_doc_min_version])
if pkg-config --atleast-version=$gtk_doc_min_version gtk-doc; then
  AC_MSG_RESULT(yes)
  GTKDOC=true
else
  AC_MSG_RESULT(no)
  GTKDOC=false
fi

dnl Let people disable the gtk-doc stuff.
AC_ARG_ENABLE(gtk-doc, [  --enable-gtk-doc  Use gtk-doc to build documentation [default=au
to]], enable_gtk_doc="$enableval", enable_gtk_doc=auto)

if test x$enable_gtk_doc = xauto ; then
  if test x$GTKDOC = xtrue ; then
    enable_gtk_doc=yes
  else
    enable_gtk_doc=no 
  fi
fi

AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)

dnl ==========================================================================
dnl Where do we want to install docs
dnl ==========================================================================
AC_MSG_CHECKING(for docs folder) 
AC_ARG_WITH(html-dir,           [  --with-html-dir=PATH    path to installed docs ])
if test "z$with_html_dir" != "z" ; then
    LASSO_DOCDIR=$with_html_dir
else
    LASSO_DOCDIR='$(datadir)/doc/lasso1'
fi

AC_MSG_RESULT($LASSO_DOCDIR)
AC_SUBST(LASSO_DOCDIR)

dnl ==========================================================================
dnl Debug 
dnl ==========================================================================
AC_MSG_CHECKING(for debuging) 
AC_ARG_ENABLE(debuging,   [  --enable-debuging       enable debuging compilation flags (no)])
if test "z$enable_debuging" = "zyes" ; then
    CFLAGS="$CFLAGS -g"
    AC_MSG_RESULT(yes)
else
    AC_MSG_RESULT(no)
fi    

dnl ==========================================================================
dnl Profiling 
dnl ==========================================================================
AC_MSG_CHECKING(for profiling) 
AC_ARG_ENABLE(profiling,   [  --enable-profiling      enable profiling compilation flags (no)])
if test "z$enable_profiling" = "zyes" ; then
    CFLAGS="$CFLAGS -pg"
    AC_MSG_RESULT(yes)
else
    AC_MSG_RESULT(no)
fi 

dnl ==========================================================================
dnl Pedantic compilation
dnl ==========================================================================
AC_MSG_CHECKING(for pedantic) 
AC_ARG_ENABLE(pedantic,   [  --enable-pedantic       enable pedantic compilation flags (no)])
if test "z$enable_pedantic" = "zyes" ; then
    dnl CFLAGS="$CFLAGS -pedantic -Wall -ansi -W -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls"
    CFLAGS="$CFLAGS -O -pedantic -Wall -ansi -fno-inline -W -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls"
    AC_MSG_RESULT(yes)
else
    AC_MSG_RESULT(no)
fi    

dnl ==========================================================================
dnl Static linking
dnl ==========================================================================
LASSO_STATIC_BINARIES=""
AC_MSG_CHECKING(for static linking) 
AC_ARG_ENABLE(static_linking,   [  --enable-static-linking enable static linking (no)])
if test "z$enable_static_linking" = "zyes" ; then
    LASSO_STATIC_BINARIES="-static"
    AC_MSG_RESULT(yes)
else
    AC_MSG_RESULT(no)
fi    
AC_SUBST(LASSO_STATIC_BINARIES)

dnl ==========================================================================
dnl Final steps: lasso config
dnl ==========================================================================
LASSO_CORE_CFLAGS="$LASSO_DEFINES -I${includedir}/lasso"
LASSO_CORE_LIBS="-llasso "
AC_SUBST(LASSO_CORE_CFLAGS)
AC_SUBST(LASSO_CORE_LIBS)

LASSO_CFLAGS="$LASSO_CORE_CFLAGS $GLIB_CFLAGS $LIBXML_CFLAGS $LIBXSLT_CFLAGS $XMLSEC1_CFLAGS $LASSO_CRYPTO_CFLAGS"
LASSO_LIBS="-L${libdir} -l$LASSO_CRYPTO_LIB $LASSO_CORE_LIBS $GLIB_LIBS $LIBXML_LIBS $LIBXSLT_LIBS $XMLSEC1_LIBS $LASSO_CRYPTO_LIBS"
AC_SUBST(LASSO_CFLAGS)
AC_SUBST(LASSO_LIBS)

AC_SUBST(LASSO_DEFINES)
AC_SUBST(LASSO_APP_DEFINES)
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)

dnl ==========================================================================
dnl Writing result files
dnl ==========================================================================
AC_OUTPUT([
lasso/version.h
Makefile
lasso/Makefile
lasso/schema/Makefile
lasso/bindings/Makefile
docs/Makefile
docs/reference/Makefile
]
dnl [lasso-config:lasso-config.in]
dnl [lasso.spec:lasso.spec.in]
)