1dnl -*- Mode: sh -*-
2dnl
3dnl configure.ac - top level autoconf file for Lasso
4dnl (Process this file with autoconf to produce a configure script.)
5dnl
6dnl
7dnl See COPYING at the top of this package for the full license terms.
8dnl
9dnl
10
11dnl Declare package and package version.
12dnl (r-c).a.r
13dnl - First number is the lowest supported API version number.
14dnl - Second number is the number of supported API versions where API version >
15dnl   first number.
16dnl - Third number is the current API version implementation version number.
17dnl See libtool explanations about current, age and release, later in this file.
18AC_INIT([lasso], m4_esyscmd([tools/git-version-gen .tarball-version]), lasso-devel@lists.labs.libre-entreprise.org)
19dnl Check if autoconf ver > 2.53
20AC_PREREQ(2.53)
21AC_CONFIG_MACRO_DIR([m4])
22dnl Perform only subset commands and variable relevant to the host type.
23AC_CANONICAL_HOST
24AC_CANONICAL_SYSTEM
25dnl Check existence of a relative pathed source file.
26AC_CONFIG_SRCDIR(lasso/lasso.c)
27dnl Copy stamp REVISIO-INFO in the configure script.
28AC_REVISION($Revision$)
29
30dnl Run many macros mostly needed by configure.ac.
31AM_INIT_AUTOMAKE([foreign tar-pax])
32dnl Support automake 1.11 silent mode
33m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
34m4_ifdef([AM_SILENT_RULES],[HAVE_AM_SILENT_RULES=yes])
35AM_CONDITIONAL(HAVE_AM_SILENT_RULES, test x$HAVE_AM_SILENT_RULES != x)
36dnl Create rules to automaticaly regenerate the config header.
37AM_CONFIG_HEADER([config.h lasso/lasso_config.h])
38dnl Add --enable-maintainer-mode option to configure.
39AM_MAINTAINER_MODE([enable])
40
41dnl ==========================================================================
42dnl Perform host specific configuration
43dnl ==========================================================================
44NULL=
45
46### Sun Java environment needs to be told about platform...
47SUN_EXTRA_INCLUDE=
48case "${host}" in
49    *-pc-mingw32)
50        SUN_EXTRA_INCLUDE="win32"
51        ;;
52    *-pc-cygwin)
53        SUN_EXTRA_INCLUDE="win32"
54        ;;
55    *linux*)
56        SUN_EXTRA_INCLUDE="linux"
57        ;;
58    *solaris*)
59        SUN_EXTRA_INCLUDE="solaris"
60        ;;
61esac
62
63### adapting build environment for different platforms...
64MINGW=0
65DARWIN=0
66case "${host}" in
67    *aix*)
68        CFLAGS="${CFLAGS} -D_ALL_SOURCE"
69        ;;
70    *-pc-mingw32)
71        case "${build}" in
72            *-pc-cygwin)
73                CC="gcc -mno-cygwin"
74                CFLAGS="${CFLAGS} -D_MSC_VER -DIN_LASSO -DMINGW -DWIN32 -D_WIN32 -I/usr/local/include"
75                LDFLAGS="${LDFLAGS} -L/usr/local/lib"
76                MINGW=1
77                ;;
78        esac
79        ;;
80    *darwin*)
81        DARWIN=1
82        ;;
83esac
84
85# OSX Fink
86if test -d /sw/bin ; then
87  PATH=$PATH:/sw/bin
88fi
89
90dnl
91dnl Check for programs
92dnl
93AC_PROG_CC
94AM_CFLAGS=""
95AC_HEADER_STDC
96LT_AC_PROG_RC
97AC_EXEEXT
98AC_PROG_CC_C_O
99AM_SANITY_CHECK
100AC_PROG_AWK
101AC_PROG_LN_S
102AC_LIBTOOL_WIN32_DLL
103AM_PROG_LIBTOOL
104AC_SUBST(LIBTOOL_DEPS)
105AS_COMPILER_FLAGS(WARNING_FLAGS, "-Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wold-style-definition -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wmissing-noreturn -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wformat-nonliteral -Wformat-security -Wswitch-enum -Wswitch-default -Winit-self -Wmissing-include-dirs -Wundef -Waggregate-return -Wmissing-format-attribute -Wnested-externs")
106
107dnl Find tar command for make dist
108AC_CHECK_PROGS(TAR, gnutar gtar tar)
109
110dnl Check existence of binding programs
111AC_CHECK_CLASSPATH
112AC_PROG_JAVAC
113AC_PROG_JAVA
114AC_PROG_JAVAH
115AC_PROG_JAR
116DPS_XTRA_CLASSPATH(CLASSPATH_JUNIT, junit.framework.Test, junit.jar)
117old_cp=$CLASSPATH
118export CLASSPATH=${CLASSPATH}:${CLASSPATH_JUNIT}
119AC_CHECK_JUNIT
120if test "x$old_cp" = "x"; then
121    unset CLASSPATH
122else
123    $CLASSPATH=$old_cp
124fi
125unset old_cp
126dnl AC_CHECK_PROGS(JAVA, gij java)
127dnl AC_CHECK_PROGS(JAVAC, gcj javac)
128dnl AC_CHECK_PROGS(JAVAH, gjavah gcjh javah)
129dnl AC_CHECK_PROGS(JAR, fastjar jar)
130
131AC_CHECK_PROGS(PERL, perl)
132AC_CHECK_PROGS(PHP5, php5 php)
133AC_CHECK_PROGS(PHP5_CONFIG, php-config5 php-config)
134AC_CHECK_PROGS(PHP7, php7.4 php7.3 php7.2 php7.1 php7.0 php7 php)
135AC_CHECK_PROGS(PHP7_CONFIG, php-config7.4 php-config7.3 php-config7.2 php-config7.1 php-config7.0 php-config7 php-config)
136AC_CHECK_PROGS(PYTHON, python3 python python2)
137AC_CHECK_PROGS(SWIG, swig)
138
139dnl Make sure we have an ANSI compiler
140test "z$U" != "z" && AC_MSG_ERROR(Compiler not ANSI compliant)
141
142dnl Check for variadic macros
143AC_CACHE_CHECK([for variadic cpp macros],
144    [ac_cv_cpp_variadic_macros],
145    [AC_TRY_COMPILE(
146         [#include <stdio.h>
147          #define a(b,c...) printf(b,##c)],
148         [a("foo");a("%s","bar");a("%s%s","baz","quux");],
149         ac_cv_cpp_variadic_macros=yes,
150         ac_cv_cpp_variadic_macros=no)])
151if test "x${ac_cv_cpp_variadic_macros}" != "xno"; then
152    AC_DEFINE(HAVE_VARIADIC_MACROS, 1, Support for variadic macros)
153fi
154
155
156dnl ==========================================================================
157dnl Version Super.Size.Me.L
158dnl ==========================================================================
159
160changequote(<<, >>)dnl
161VERSION_MAJOR=`echo $VERSION | $SED -e 's/^\([^\.]*\)\.\([^\.]*\)\.\(.*\)$/\1/'`
162VERSION_MINOR=`echo $VERSION | $SED -e 's/^\([^\.]*\)\.\([^\.]*\)\.\(.*\)$/\2/'`
163VERSION_RELEASE=`echo $VERSION | $SED -e 's/^\([^\.]*\)\.\([^\.]*\)\.\([0-9]*\).*$/\3/'`
164changequote([, ])dnl
165VERSION_UNDERSCORED=`echo $VERSION | $SED -e 's/\./_/g'`
166AC_SUBST(VERSION_UNDERSCORED)
167
168
169dnl Add versionning & package defines to lasso_.h
170AC_DEFINE_UNQUOTED(LASSO_VERSION_MAJOR, $VERSION_MAJOR, [Major version number])
171AC_DEFINE_UNQUOTED(LASSO_VERSION_MINOR, $VERSION_MINOR, [Minor version number])
172AC_DEFINE_UNQUOTED(LASSO_VERSION_SUBMINOR, $VERSION_RELEASE, [Release version number])
173
174dnl Dirty hack in order to have dynamic resource version numbering.
175WINDOWS_VERSION=`echo $VERSION_MAJOR,$VERSION_MINOR,$VERSION_RELEASE,0`
176AC_SUBST(WINDOWS_VERSION)
177
178dnl CURRENT, REVISION, AGE
179dnl - library source changed -> increment REVISION
180dnl - interfaces added/removed/changed -> increment CURRENT, REVISION = 0
181dnl - interfaces added -> increment AGE
182dnl - interfaces removed -> AGE = 0
183
184# syntax: CURRENT[:REVISION[:AGE]]
185# So if M=major, m=minor, r=release:
186# c = M + a = M + m;
187# m = a
188# r = r
189current=`expr $VERSION_MAJOR + $VERSION_MINOR`
190LASSO_VERSION_INFO="16:1:13"
191AC_SUBST(LASSO_VERSION_INFO)
192
193dnl Compute the minimal supported ABI version for Win32 scripts and resources files.
194minimal_version=`echo $LASSO_VERSION_INFO | $AWK -F: '{printf("%d\n",$1-$3)};'`
195UPCASED_DLL_FILENAME="LIBLASSO-$minimal_version.DLL"
196DLL_FILENAME="liblasso-$minimal_version.dll"
197AC_SUBST(UPCASED_DLL_FILENAME)
198AC_SUBST(DLL_FILENAME)
199
200dnl Detect available languages binding.
201languages_available=
202
203
204# ------------
205# JAVA binding
206# ------------
207
208dnl Check if java is explicitly disabled.
209AC_ARG_ENABLE(java, [  --enable-java          enable the Java binding],,
210              enable_java="no")
211AC_ARG_WITH(java-home,
212            [  --with-java-home=(JAVA_HOME)  set the full path to the java home directory.])
213SUN=no
214
215dnl If the java compiler seems to be a Sun JDK-like compile (Kaffe, Sun JDK...)
216if test "x$JAVAC" = "xjavac"; then
217    JAVAC_PATH=`which $JAVAC`
218    if test "x$with_java_home" = "x"; then
219	    with_java_home=`readlink -f $JAVAC_PATH | sed s#/bin/.*##`
220    fi
221    dnl If we have a java compiler
222    dnl need to change quotes to allow square brackets
223    changequote(<<, >>)dnl
224    JAVA_VERSION=`$JAVA -version 2>&1 | $SED -ne 's/\(openjdk\|java\) \(full\)*version "\([^"]*\)".*/\3/p' 2>/dev/null`
225    changequote([, ])dnl
226    dnl If no java version found, perphas it is a kaffee environment...
227    if test "x$JAVA_VERSION" = x; then
228        JAVA_VERSION=`$JAVA -version 2>&1 | grep "Java Version" | $SED 's/^.*Java Version: //g'`
229        dnl If the java environment is kaffe, specify the JAVA_INCLUDE directory.
230    else
231        dnl We assume it is a SUN environment.
232        SUN=yes
233    fi
234    CLASSPATH_OPT="-classpath"
235fi
236
237if test "x$with_java_home" != x; then
238    JAVA_INCLUDE="$with_java_home/include"
239fi
240
241if ! test -f "$JAVA_INCLUDE/jni.h"; then
242    JAVA_VERSION=""
243fi
244
245dnl GNU java environment
246if test "x$JAVAH" = "xgcjh" || test "x$JAVAH" = "xgjavah"  ; then
247    dnl JNI compatible header files. (not used with SWIG.)
248    JAVAH_FLAGS="-jni"
249    JAVA_INCLUDE=""
250fi
251
252dnl If the java compiler is the GNU Java Compiler.
253if echo "$JAVAC" | grep -q "gcj"; then
254    changequote(<<, >>)dnl
255    JAVA_VERSION=`$JAVAC --version 2>&1 | $SED -ne 's/gcj[^[:blank:]]* ([^)]*) \([^ ]*\).*/\1/p' 2>/dev/null`
256    MAJOR=`echo $JAVA_VERSION | sed 's/.*[^[:digit:]]\?\([[:digit:]]\+\)\.[[:digit:]]\+\.[[:digit:]]\+/\1/'`
257    MINOR=`echo $JAVA_VERSION | sed 's/.*[^[:digit:]]\?[[:digit:]]\+\.\([[:digit:]]\+\)\.[[:digit:]]\+/\1/'`
258    RELEASE=`echo $JAVA_VERSION | sed 's/.*[^[:digit:]]\?[[:digit:]]\+\.[[:digit:]]\+\.\([[:digit:]]\+\).*/\1/'`
259    changequote([, ])dnl
260    dnl Byte-compiled .class file
261    if test $MAJOR -gt 4 -o \( $MAJOR -eq 4 -a $MINOR -gt 1 \) -o \( $MAJOR -eq 4 -a $MINOR -eq 1 -a $RELEASE -ge 3 \); then
262        JAVAC_FLAGS="-fsource=1.4 -ftarget=1.4"
263    fi
264    unset MAJOR
265    unset MINOR
266    unset RELEASE
267    dnl Checking for jni.h if gcj is the java interpreter.
268    AC_CHECK_HEADERS([jni.h], [], [JAVA_VERSION=""])
269    CLASSPATH_OPT="--classpath"
270fi
271
272dnl Now transform JAVA_INCLUDE in CFLAG option if applicable.
273if test "X$JAVA_INCLUDE" != "X"; then
274    dnl If it is a sun environment
275    if test "x$SUN" = "xyes"; then
276        JAVA_INCLUDE="$JAVA_INCLUDE -I$JAVA_INCLUDE/$SUN_EXTRA_INCLUDE"
277    fi
278    JAVA_INCLUDE=-I$JAVA_INCLUDE
279fi
280
281dnl If we found a java version information, we have java compilation environment.
282if test "X$JAVA_VERSION" != "X" && test "X$JAR" != "X" && test "x$JAVAH" != "x"; then
283  languages_available="$languages_available $JAVA($JAVA_VERSION)"
284else
285  enable_java=no
286  JAVA_VERSION=""
287fi
288
289dnl Support JNI under MacOsX
290if test  "$DARWIN" = 1; then
291    JNI_EXTRA_LDFLAGS="-shrext .jnilib"
292fi
293
294dnl Conditional java sub dir test.
295AM_CONDITIONAL([JAVA_ENABLED],[test "x$enable_java" = "xyes"])
296AM_CONDITIONAL([JUNIT_ENABLED],[test "x$JUNIT" != "x"])
297AC_SUBST(JAVA_VERSION)
298AC_SUBST(JAVAC_FLAGS)
299AC_SUBST(JAVAH_FLAGS)
300AC_SUBST(JAVA_INCLUDE)
301AC_SUBST(CLASSPATH_OPT)
302JDK_INCLUDE=$JAVA_INCLUDE
303AC_SUBST(JDK_INCLUDE)
304AC_SUBST(JNI_EXTRA_LDFLAGS)
305
306
307# --------------
308# Python binding
309# --------------
310
311dnl Check if python is explicitly disabled.
312AC_ARG_ENABLE(python, [  --disable-python        disable the Python binding],,
313              enable_python="yes")
314
315dnl Check if user passed a specific python program.
316AC_ARG_WITH(python,
317            [  --with-python=(PYTHON)  set the full path to the python program to use.])
318
319dnl specific program passed, set PYTHON to it.
320if test "X$with_python" != "X"; then
321    PYTHON=$with_python
322fi
323
324
325dnl need to change quotes to allow square brackets
326changequote(<<, >>)dnl
327PYTHON_VERSION=`$PYTHON -c 'from distutils import sysconfig ; print(sysconfig.get_config_var("VERSION"))'`
328changequote([, ])dnl
329
330test "x$PYTHON" != "x" || AC_MSG_ERROR(Python must be installed to compile lasso)
331
332AC_MSG_CHECKING(for Python development files)
333dnl Check if we were be able to extract a good version number.
334if test "X$PYTHON_VERSION" != "X"; then
335    changequote(<<, >>)dnl
336    PYTHON_INC=`$PYTHON -c 'from distutils import sysconfig ; print(sysconfig.get_python_inc())'`
337    PYTHON_LIB=`$PYTHON -c 'from distutils import sysconfig ; print(sysconfig.get_python_lib(1))'`
338    changequote([, ])dnl
339    PYTHON_H=$PYTHON_INC/Python.h
340    if test -f $PYTHON_H; then
341            PY_CFLAGS="-I$PYTHON_INC"
342            PY_MAKEFILE=`$PYTHON -c 'from distutils import sysconfig ; print(sysconfig.get_makefile_filename())'`
343            PY_OTHER_LIBS=`$SED -n -e 's/^LIBS=\(.*\)/\1/p' $PY_MAKEFILE`
344            PY_EXTRA_LIBS="$PY_LOCALMODLIBS $PY_BASEMODLIBS $PY_OTHER_LIBS"
345            dnl this extracts the $libdir out of python lib directory,
346            dnl replacing it by our own.
347            PY_SUFFIX_LIB=`echo $PYTHON_LIB | $SED -e 's/.*python/python/'`
348            PY_SITE_PACKAGES="\${libdir}/$PY_SUFFIX_LIB"
349            AC_SUBST(PYTHON)
350            AC_SUBST(PY_LIB_LOC)
351            AC_SUBST(PY_CFLAGS)
352            AC_SUBST(PY_EXTRA_LIBS)
353            AC_SUBST(PY_DYNLOAD)
354            AC_SUBST(PY_LIB_A)
355            AC_SUBST(PY_SITE_PACKAGES)
356            languages_available="$languages_available python($PYTHON_VERSION)"
357    else
358            enable_python=no
359    fi
360else
361	enable_python=no
362fi
363AM_CONDITIONAL([PYTHON_ENABLED],[test "x$enable_python" = "xyes"])
364AC_MSG_RESULT($enable_python)
365AC_SUBST(PYTHON_VERSION)
366
367# -----------
368# PHP 5 binding
369# -----------
370
371dnl Check if php is explicitly enabled.
372AC_ARG_ENABLE(php5, [  --enable-php5          enable the PHP 5 binding],,
373              enable_php5="yes")
374
375AC_ARG_WITH(php5-config,
376            [  --with-php5-config=(PHP5_CONFIG)      Specify full path to php-config5.])
377
378AC_ARG_ENABLE(php5-force, [  --enable-php5-force     always enable of the PHP 5 binding (win32)],
379              [ENABLE_PHP5_FORCE="yes"],
380              [ENABLE_PHP5_FORCE="no"])
381
382
383dnl Check if user passed a specific php-config program.
384if test "X$with_php5_config" != "X" ; then
385    PHP5_CONFIG=$with_php5_config
386fi
387
388if test "X$PHP5_CONFIG" != "X" ; then
389  PHP5_INCLUDES=`$PHP5_CONFIG --includes`
390  PHP5_LDFLAGS=`$PHP5_CONFIG --ldflags`
391  PHP5_LIBS=`$PHP5_CONFIG --libs`
392  PHP5_PREFIX=`$PHP5_CONFIG --prefix`
393  PHP5_QUOTED_PREFIX=$(echo $PHP5_PREFIX | $SED 's/\//\\\//g')
394  PHP5_UNPREFIXED_EXTENSION_DIR=$($PHP5_CONFIG --extension-dir | $SED "s/$PHP5_QUOTED_PREFIX//g")
395else
396  # We assume PHP are in /usr/local directory.
397  if test $MINGW -eq 1; then
398    CFLAGS="$CFLAGS -DZTS -DZEND_WIN32 -DWIN32 -D_MBCS"
399  fi
400  PHP5_INCLUDES="-I/usr/local/include/php5 -I/usr/local/include/php5/main -I/usr/local/include/php5/Zend -I/usr/local/include/php5/TSRM -I/usr/local/include/php5/win32"
401  PHP5_LDFLAGS=
402  PHP5_LIBS="-lphp5ts -lxmlparse -lxmltok"
403  PHP5_UNPREFIXED_EXTENSION_DIR=
404  PHP5_PREFIX=
405fi
406
407AC_ARG_WITH(php5-include-dir,
408            [  --with-php5-include-dir=(PHP5_INCLUDE_DIR)      Specify full path to php 5 include dir.],
409            [PHP5_INCLUDE_DIR="$withval"],[PHP5_INCLUDE_DIR=${datadir}/php])
410
411AC_ARG_WITH(php5-config-dir,
412            [  --with-php5-config-dir=(PHP5_CONFIG_DIR)      Specify full path to php 5 config dir.],
413            [PHP5_CONFIG_DIR="$withval"],[PHP5_CONFIG_DIR=${sysconfdir}/php5/conf.d/])
414
415AC_SUBST(PHP5_INCLUDES)
416AC_SUBST(PHP5_LDFLAGS)
417AC_SUBST(PHP5_LIBS)
418AC_SUBST(PHP5_UNPREFIXED_EXTENSION_DIR)
419AC_SUBST(PHP5_EXTENSION_DIR)
420AC_SUBST(PHP5_PREFIX)
421AC_SUBST(PHP5_INCLUDE_DIR)
422AC_SUBST(PHP5_CONFIG_DIR)
423
424AC_MSG_CHECKING(for PHP 5 development files)
425if $PHP5_CONFIG --version | grep -q "^5" || test "x$ENABLE_PHP5_FORCE" = "xyes"
426then
427	PHP5_VERSION=`$PHP5_CONFIG --version 2> /dev/null`
428	languages_available="$languages_available php5($PHP5_VERSION)"
429else
430	enable_php5=no
431fi
432
433AC_MSG_RESULT($enable_php5)
434AM_CONDITIONAL([PHP5_ENABLED], [test "x$enable_php5" = "xyes"])
435AC_SUBST(PHP5_VERSION)
436
437
438# -----------
439# PHP 7 binding
440# -----------
441
442dnl Check if php is explicitly enabled.
443AC_ARG_ENABLE(php7, [  --enable-php7          enable the PHP 7 binding],,
444              enable_php7="yes")
445
446AC_ARG_WITH(php7-config,
447            [  --with-php7-config=(PHP7_CONFIG)      Specify full path to php-config7.])
448
449AC_ARG_ENABLE(php7-force, [  --enable-php7-force     always enable of the PHP 7 binding (win32)],
450              [ENABLE_PHP7_FORCE="yes"],
451              [ENABLE_PHP7_FORCE="no"])
452
453
454dnl Check if user passed a specific php-config program.
455if test "X$with_php7_config" != "X" ; then
456    PHP7_CONFIG=$with_php7_config
457fi
458
459if test "X$PHP7_CONFIG" != "X" ; then
460  PHP7_INCLUDES=`$PHP7_CONFIG --includes`
461  PHP7_LDFLAGS=`$PHP7_CONFIG --ldflags`
462  PHP7_LIBS=`$PHP7_CONFIG --libs`
463  PHP7_PREFIX=`$PHP7_CONFIG --prefix`
464  PHP7_QUOTED_PREFIX=$(echo $PHP7_PREFIX | $SED 's/\//\\\//g')
465  PHP7_UNPREFIXED_EXTENSION_DIR=$($PHP7_CONFIG --extension-dir | $SED "s/$PHP7_QUOTED_PREFIX//g")
466else
467  # We assume PHP are in /usr/local directory.
468  if test $MINGW -eq 1; then
469    CFLAGS="$CFLAGS -DZTS -DZEND_WIN32 -DWIN32 -D_MBCS"
470  fi
471  PHP7_INCLUDES="-I/usr/local/include/php7 -I/usr/local/include/php7/main -I/usr/local/include/php7/Zend -I/usr/local/include/php7/TSRM -I/usr/local/include/php7/win32"
472  PHP7_LDFLAGS=
473  PHP7_LIBS="-lphp7ts -lxmlparse -lxmltok"
474  PHP7_UNPREFIXED_EXTENSION_DIR=
475  PHP7_PREFIX=
476fi
477
478AC_ARG_WITH(php7,
479            [  --with-php7=(PHP)      Specify full path to php 7 executable.],
480            [PHP7="$withval"],[PHP7_INCLUDE_DIR=php7])
481
482AC_ARG_WITH(php7-include-dir,
483            [  --with-php7-include-dir=(PHP7_INCLUDE_DIR)      Specify full path to php 7 include dir.],
484            [PHP7_INCLUDE_DIR="$withval"],[PHP7_INCLUDE_DIR=${datadir}/php])
485
486AC_ARG_WITH(php7-config-dir,
487            [  --with-php7-config-dir=(PHP7_CONFIG_DIR)      Specify full path to php 7 config dir.],
488            [PHP7_CONFIG_DIR="$withval"],[PHP7_CONFIG_DIR=${sysconfdir}/php7/conf.d/])
489
490AC_SUBST(PHP7_INCLUDES)
491AC_SUBST(PHP7_LDFLAGS)
492AC_SUBST(PHP7_LIBS)
493AC_SUBST(PHP7_UNPREFIXED_EXTENSION_DIR)
494AC_SUBST(PHP7_EXTENSION_DIR)
495AC_SUBST(PHP7_PREFIX)
496AC_SUBST(PHP7_INCLUDE_DIR)
497AC_SUBST(PHP7_CONFIG_DIR)
498
499AC_MSG_CHECKING(for PHP 7 development files)
500if $PHP7_CONFIG --version | grep -q "^7" || test "x$ENABLE_PHP7_FORCE" = "xyes"
501then
502	PHP7_VERSION=`$PHP7_CONFIG --version 2> /dev/null`
503	languages_available="$languages_available php7($PHP7_VERSION)"
504else
505	enable_php7=no
506fi
507
508AC_MSG_RESULT($enable_php7)
509AM_CONDITIONAL([PHP7_ENABLED], [test "x$enable_php7" = "xyes"])
510AC_SUBST(PHP7_VERSION)
511
512
513### # ----------
514### # C# binding (disabled for the moment)
515### # ----------
516###
517### AC_ARG_ENABLE(csharp, [  --disable-csharp        disable the C Sharp binding],,
518###               enable_csharp="yes")
519###
520### AC_ARG_WITH(cil-interpreter, [  --with-cil-interpreter=path     set location of CIL interpreter for CSharp],[CSHARPBIN="$withval"], [CSHARPBIN=])
521### AC_ARG_WITH(csharp-compiler, [  --with-csharp-compiler=path     set location of CSharp compiler],[CSHARPCOMPILERBIN="$withval"], [CSHARPCOMPILERBIN=])
522###
523### if test -z "$CSHARPCOMPILERBIN" ; then
524###   case $host in
525###   *-*-cygwin* | *-*-mingw*)
526###     AC_CHECK_PROGS(CSHARPCOMPILER, mcs.bat cscc csc);;
527###   *)AC_CHECK_PROGS(CSHARPCOMPILER, mcs cscc);;
528###   esac
529### else
530###   CSHARPCOMPILER="$CSHARPCOMPILERBIN"
531### fi
532###
533### CSHARPPATHSEPARATOR="/"
534### CSHARPCYGPATH_W=echo
535### if test -z "$CSHARPBIN" ; then
536###   #languages_available="$languages_available C#($CSHARPCOMPILER)"
537###   CSHARPCILINTERPRETER=""
538###   if test "cscc" = "$CSHARPCOMPILER" ; then
539###     AC_CHECK_PROGS(CSHARPCILINTERPRETER, ilrun)
540###   else
541###     if test "mcs" = "$CSHARPCOMPILER"; then
542###       # Check that mcs is the C# compiler and not the Unix mcs utility by examining the output of 'mcs --version'
543###       # The Mono compiler should emit: Mono C# compiler version a.b.c.d
544###       csharp_version_raw=`(mcs --version) 2>/dev/null`
545###       csharp_version_searched=`(mcs --version | sed -n "/C#\|Mono/p") 2>/dev/null`
546###       CSHARPCOMPILER="";
547###       if test -n "$csharp_version_raw" ; then
548###         if test "$csharp_version_raw" = "$csharp_version_searched" ; then
549###           CSHARPCOMPILER="mcs"
550###         fi
551###       fi
552###
553###       # mono interpreter (ver 0.26 doesn't seem to work on Windows platforms)
554###       case $host in
555###       *-*-cygwin* | *-*-mingw*)
556###         ;;
557###       *)AC_CHECK_PROGS(CSHARPCILINTERPRETER, mint);;
558###       esac
559###     else
560###       if test "csc" = "$CSHARPCOMPILER"; then
561###           CSHARPPATHSEPARATOR="\\\\"
562###           CSHARPCYGPATH_W='cygpath -w'
563###       fi
564###     fi
565###   fi
566### else
567###   CSHARPCILINTERPRETER="$CSHARPBIN"
568### fi
569
570# Cygwin requires the Windows standard (Pascal) calling convention as it is a Windows executable and not a Cygwin built executable
571case $host in
572*-*-cygwin* | *-*-mingw*)
573    if test "$GCC" = yes; then
574        CSHARPDYNAMICLINKING=" -Wl,--add-stdcall-alias"
575    else
576        CSHARPDYNAMICLINKING=""
577    fi ;;
578*)CSHARPDYNAMICLINKING="";;
579esac
580
581AC_CHECK_PROGS(GACUTIL, gacutil)
582
583AC_SUBST(CSHARPCILINTERPRETER)
584AC_SUBST(CSHARPCYGPATH_W)
585AC_SUBST(CSHARPCOMPILER)
586AC_SUBST(CSHARPDYNAMICLINKING)
587AC_SUBST(CSHARPLIBRARYPREFIX) # Is this going to be used?
588AC_SUBST(GACUTIL)
589
590if test "X$CSHARPCOMPILER" = X; then
591    enable_csharp=no
592fi
593if test "X$GACUTIL" = X; then
594    enable_csharp=no
595fi
596AM_CONDITIONAL([CSHARP_ENABLED], [test "x$enable_csharp" = "xyes"])
597
598
599# ------------
600# Perl binding
601# ------------
602
603AC_ARG_ENABLE(perl, [  --disable-perl          disable the Perl binding],,
604              enable_perl="yes")
605
606if test "X$PERL" != "X"; then
607  PERLINSTALLSITEARCH=`$PERL -MConfig -e 'print $Config{installsitearch};'`
608  PERLMAN3DIR=`$PERL -MConfig -e 'print $Config{man3dir};'`
609  PERL_CFLAGS=$($PERL -V::ccflags: | tr -d "'")
610else
611  PERLINSTALLSITEARCH=none
612  PERLMAN3DIR=none
613  PERL_CFLAGS=
614fi
615AC_SUBST(PERLINSTALLSITEARCH)
616AC_SUBST(PERLMAN3DIR)
617AC_SUBST(PERL_CFLAGS)
618
619AC_MSG_CHECKING(for Perl API)
620if test "X$enable_perl" != "Xno" ; then
621  if test "X$enable_perl" != "Xyes"; then
622    PERL=$enable_perl
623  fi
624  enable_perl=yes
625fi
626
627PERL_VERSION=`$PERL -MConfig -e 'print $Config{version}' 2>/dev/null`
628if test "X$PERL_VERSION" != "X"; then
629  languages_available="$languages_available perl($PERL_VERSION)"
630  if test $enable_perl = yes; then
631    languages="$languages perl"
632  fi
633fi
634AM_CONDITIONAL([PERL_ENABLED],[test "x$enable_perl" = "xyes"])
635AC_MSG_RESULT($enable_perl)
636AC_SUBST(PERL_VERSION)
637
638
639dnl Checks for zlib library (code adapted from libxml2 configure.in)
640_cppflags="${CPPFLAGS}"
641_ldflags="${LDFLAGS}"
642
643AC_ARG_WITH(zlib,
644[  --with-zlib[[=DIR]]       use libz in DIR],[
645  if test "$withval" != "no" -a "$withval" != "yes"; then
646    Z_DIR=$withval
647    CPPFLAGS="${CPPFLAGS} -I$withval/include"
648    LDFLAGS="${LDFLAGS} -L$withval/lib"
649  fi
650])
651saved_LIB=$LIBS
652LIBS=
653AC_CHECK_HEADERS(zlib.h,
654    AC_SEARCH_LIBS(gzread, [z zlib1],[
655        AC_DEFINE([HAVE_LIBZ], [], [Have compression library])
656        if test "x${Z_DIR}" != "x"; then
657            Z_CFLAGS="-I${Z_DIR}/include"
658            Z_LIBS="-L${Z_DIR}/lib $LIBS"
659            [case ${host} in
660                *-*-solaris*)
661                    Z_LIBS="-L${Z_DIR}/lib -R${Z_DIR}/lib $LIBS"
662                    ;;
663            esac]
664        else
665            Z_LIBS="$LIBS"
666        fi]))
667LIBS=$saved_LIB
668test "z$Z_LIBS" != "z" || AC_MSG_ERROR(missing zlib)
669
670AC_SUBST(Z_CFLAGS)
671AC_SUBST(Z_LIBS)
672
673CPPFLAGS=${_cppflags}
674LDFLAGS=${_ldflags}
675
676dnl Final step, add missing programs.
677AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
678AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
679AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
680AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
681
682dnl Check if wsf is explicitly disabled.
683AC_ARG_ENABLE(wsf, [  --enable-wsf            enable experimental ID-WSF],
684		enable_wsf="yes", enable_wsf="no")
685
686AM_CONDITIONAL([WSF_ENABLED],[test "x$enable_wsf" = "xyes"])
687LASSO_WSF_SUPPORT=0
688if test "x$enable_wsf" = "xyes"; then
689	AC_DEFINE(LASSO_WSF_ENABLED, [], [Define if ID-WSF support is enabled])
690	LASSO_WSF_SUPPORT=1
691fi
692AC_SUBST(LASSO_WSF_SUPPORT)
693
694
695dnl API Reference documentation support
696# gtkdocize greps for ^GTK_DOC_CHECK and parses it, so you need to have
697# it on it's own line.
698m4_ifdef([GTK_DOC_CHECK], [
699GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
700],[
701AM_CONDITIONAL([ENABLE_GTK_DOC],[false])
702])
703
704if test "z$with_html_dir" != "z" ; then
705    LASSO_DOCDIR=$with_html_dir
706else
707    LASSO_DOCDIR='$(datadir)/doc/lasso'
708fi
709AC_SUBST(LASSO_DOCDIR)
710
711AC_ARG_WITH(html-dir, [  --with-html-dir=PATH path to installed docs ])
712
713if test "x$with_html_dir" = "x" ; then
714  HTML_DIR='${datadir}/gtk-doc/html'
715else
716  HTML_DIR=$with_html_dir
717fi
718AC_SUBST(HTML_DIR)
719
720
721dnl pkg-config path
722AC_ARG_WITH(pkg-config, [  --with-pkg-config=PATH set pkg-config metadata search path.],
723            PKG_CONFIG_PATH="${withval}", PKG_CONFIG_PATH="")
724if test "z$PKG_CONFIG_PATH" != "z"; then
725    export PKG_CONFIG_PATH
726fi
727
728PKG_CHECK_MODULES(LASSO, glib-2.0 >= 2.17.0 gobject-2.0 >= 2.17.0 libxml-2.0 xmlsec1 >= 1.2.6 xmlsec1-openssl >= 1.2.6 openssl)
729
730dnl ==========================================================================
731dnl Test suite (requires check)
732dnl ==========================================================================
733dnl Check if user disabled the tests.
734AC_ARG_ENABLE(tests, [  --disable-tests         disable the test suite],,
735              enable_tests="yes")
736if test "x$enable_tests" = xyes ; then
737  PKG_CHECK_MODULES(CHECK, check, [], [
738AC_CHECK_LIB(check, srunner_set_log, enable_tests="yes", enable_tests="no")
739CHECK_CFLAGS=""
740CHECK_LIBS="-lcheck"
741])
742  AC_SUBST(CHECK_CFLAGS)
743  AC_SUBST(CHECK_LIBS)
744  AC_CHECK_LIB(check, srunner_set_xml, [AC_DEFINE(CHECK_IS_XML, [], [Define if check available with XML support])])
745fi
746
747AM_CONDITIONAL(WITH_TESTS, [test "x$enable_tests" = "xyes"])
748
749AC_ARG_WITH(sasl2, [  --with-sasl2[=PFX]         Use Cyrus SASL library version 2 for WSF-Auth])
750if test "x$enable_wsf" = "xyes"; then
751	if test "$with_sasl2" != "no" && test "$with_sasl2" != "yes"
752	then
753		CPPFLAGS="$CPPFLAGS -I$with_sasl2/include"
754		LDFLAGS="$LDFLAGS -L$with_sasl2/lib"
755	fi
756
757	saved_LIBS="$LIBS"
758	AC_CHECK_LIB(sasl2, sasl_server_init,,
759		AC_MSG_ERROR([libsasl must be installed for WSF support]),)
760	LIBS="$saved_LIBS"
761	LASSO_LIBS="$LASSO_LIBS -lsasl2"
762fi
763
764AC_CHECK_PROGS(REST2HTML, rest2html rst2html)
765AM_CONDITIONAL(HAVE_REST2HTML, test -n "$ac_cv_prog_REST2HTML")
766
767AC_CHECK_PROGS(XSLTPROC, xsltproc)
768AM_CONDITIONAL(HAVE_XSLTPROC, test -n "$ac_cv_prog_XSLTPROC")
769
770AC_CHECK_PROGS(INKSCAPE, inkscape)
771AM_CONDITIONAL(HAVE_INKSCAPE, test -n "$ac_cv_prog_INKSCAPE")
772
773
774dnl Debug
775AC_MSG_CHECKING(for debugging)
776AC_ARG_ENABLE(debugging,   [  --enable-debugging      enable debuging optimization flags (no)])
777if test "z$enable_debugging" = "zyes" ; then
778    enable_debugging=yes
779    LASSO_DEFINES="$LASSO_DEFINES -DLASSO_DEBUG"
780    CFLAGS="$CFLAGS -O0 -g -Wall -Wextra"
781else
782    enable_debugging=no
783fi
784AM_CONDITIONAL([DEBUGGING],[test "x$enable_debugging" = "xyes"])
785AC_MSG_RESULT($enable_debugging)
786AC_SUBST(DEBUGGING)
787
788dnl Profiling
789AC_MSG_CHECKING(for profiling)
790AC_ARG_ENABLE(profiling,   [  --enable-profiling      enable profiling compilation flags (no)])
791if test "z$enable_profiling" = "zyes" ; then
792    AM_CFLAGS="$AM_CFLAGS -pg"
793    AC_MSG_RESULT(yes)
794else
795    AC_MSG_RESULT(no)
796fi
797
798dnl ==========================================================================
799dnl Pedantic compilation
800dnl ==========================================================================
801AC_MSG_CHECKING(for pedantic)
802AC_ARG_ENABLE(pedantic,   [  --enable-pedantic       enable pedantic compilation flags (no)])
803if test "z$enable_pedantic" = "zyes" ; then
804    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"
805    AC_MSG_RESULT(yes)
806else
807    AC_MSG_RESULT(no)
808fi
809
810dnl ==========================================================================
811dnl Static linking
812dnl ==========================================================================
813LASSO_STATIC_BINARIES=""
814AC_MSG_CHECKING(for static linking)
815AC_ARG_ENABLE(static_linking,   [  --enable-static-linking enable static linking (no)])
816if test "z$enable_static_linking" = "zyes" ; then
817    LASSO_STATIC_BINARIES="-static"
818    AC_MSG_RESULT(yes)
819else
820    AC_MSG_RESULT(no)
821fi
822AC_SUBST(LASSO_STATIC_BINARIES)
823
824dnl ==========================================================================
825dnl Final steps: lasso config
826dnl ==========================================================================
827LASSO_PUB_CFLAGS="$LASSO_DEFINES"
828LASSO_CORE_CFLAGS="$LASSO_CFLAGS $LASSO_DEFINES $Z_CFLAGS -DLASSO_INTERNALS"
829if test $MINGW -eq 1; then
830  LASSO_CORE_LIBS="-llasso-0"
831else
832  LASSO_CORE_LIBS="-llasso "
833fi
834AC_SUBST(LASSO_CORE_CFLAGS)
835AC_SUBST(LASSO_CORE_LIBS)
836
837LASSO_CFLAGS="$LASSO_CFLAGS"
838LASSO_LIBS="-L${libdir} $Z_LIBS $LASSO_LIBS"
839AC_SUBST(LASSO_CFLAGS)
840AC_SUBST(LASSO_LIBS)
841
842AC_SUBST(LASSO_PUB_CFLAGS)
843AC_SUBST(LASSO_DEFINES)
844AC_SUBST(LASSO_APP_DEFINES)
845AC_SUBST(CFLAGS)
846AC_SUBST(AM_CFLAGS)
847AC_SUBST(CPPFLAGS)
848AC_SUBST(LDFLAGS)
849AC_SUBST(CLASSPATH_JUNIT)
850AC_SUBST(SWIG_VERSION)
851
852dnl Dirty system often means dirty hacks...
853AM_CONDITIONAL(MINGW, test $MINGW -eq 1)
854AM_CONDITIONAL(DARWIN, test $DARWIN -eq 1)
855
856dnl bindings
857
858
859dnl ==========================================================================
860dnl Writing result files
861dnl ==========================================================================
862AC_CONFIG_FILES([lasso-src-config], [chmod +x lasso-src-config])
863AC_OUTPUT(
864[Makefile
865docs/Makefile
866docs/lasso-book/Makefile
867docs/lasso-book/figures/Makefile
868docs/reference/Makefile
869docs/reference/lasso/version.xml
870docs/reference/lasso/Makefile
871lasso/Makefile
872lasso/id-ff/Makefile
873lasso/id-wsf/Makefile
874lasso/saml-2.0/Makefile
875lasso/id-wsf-2.0/Makefile
876lasso/xml/Makefile
877lasso/xml/ecp/Makefile
878lasso/xml/saml-2.0/Makefile
879lasso/xml/soap-1.1/Makefile
880lasso/xml/id-wsf-2.0/Makefile
881lasso/xml/ws/Makefile
882lasso/xml/dsig/Makefile
883tests/Makefile
884tests/data/Makefile
885lasso.pc
886win32/Makefile
887win32/lasso.rc
888win32/msvc/Makefile
889win32/msvc/lasso.dsp
890win32/msvc/lasso_config.h
891win32/msvc/java/Makefile
892win32/msvc/php/Makefile
893win32/msvc/python/Makefile
894win32/nsis/Makefile
895win32/nsis/jlasso-lite.nsi
896win32/nsis/lasso-deps.nsi
897win32/nsis/lasso-full.nsi
898win32/nsis/lasso-lite.nsi
899win32/nsis/python.nsi
900bindings/Makefile
901bindings/java/Makefile
902bindings/python/Makefile
903bindings/python/tests/Makefile
904bindings/php5/Makefile
905bindings/php5/examples/Makefile
906bindings/php5/tests/Makefile
907bindings/php7/Makefile
908bindings/php7/examples/Makefile
909bindings/php7/tests/Makefile
910bindings/perl/Makefile
911])
912
913languages_available=`echo $languages_available | sed -e "s/^ //" `
914AC_MSG_RESULT(
915
916=============
917Configuration
918=============
919
920Main
921----
922
923Compiler:                ${CC}
924CFLAGS:                  ${AM_CFLAGS} ${CFLAGS}
925Install prefix:          ${prefix}
926Debugging:               $enable_debugging
927Experimental ID-WSF:     $enable_wsf
928
929Optionals builds
930----------------
931
932Available languages:    ${languages_available}
933
934Java binding:           ${enable_java}
935Perl binding:           ${enable_perl}
936PHP 5 binding:          ${enable_php5}
937PHP 7 binding:          ${enable_php7}
938Python binding:         ${enable_python}
939
940C API references:       ${enable_gtk_doc}
941Tests suite:            ${enable_tests}
942)
943