source: trunk/acinclude.m4 @ 1754

Revision 1754, 15.0 KB checked in by Freddie Akeroyd, 3 months ago (diff)

Enable python by default. Refs #302

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#====================================================================
2#  NeXus - Neutron & X-ray Common Data Format
3
4#  $Id$
5#
6#  Local autoconf m4 macros - these used by configure.ac
7#  and automatically added to aclocal.m4 by running the "aclocal"
8#  command (a separate file is needed becausle automake needs to
9#  add extra stuff to aclocal.m4 as well)
10
11#  Copyright (C) 2004 Freddie Akeroyd
12
13#  This library is free software; you can redistribute it and/or
14#  modify it under the terms of the GNU Lesser General Public
15#  License as published by the Free Software Foundation; either
16#  version 2 of the License, or (at your option) any later version.
17#
18#  This library is distributed in the hope that it will be useful,
19#  but WITHOUT ANY WARRANTY; without even the implied warranty of
20#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21#  Lesser General Public License for more details.
22#
23#  You should have received a copy of the GNU Lesser General Public
24#  License along with this library; if not, write to the Free
25#  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26#  MA  02111-1307  USA
27#             
28#  For further information, see <http://www.nexusformat.org/>
29#
30# AC_CHECK_COMPILER_OPTION tests for a given compiler option; we need to egrep
31# the output as well as check the status as sometimes the compiler
32# will return success for invalid options
33#
34# Argument 1 is printed and is the real name of the language
35# Argument 2 must be "Fortran 77" or "C" (language to "Push")
36# Argument 3 must be FFLAGS or CFLAGS as appropriate for argument 2
37# Argument 4 is the compiler option to check
38# Argumnet 5 is any extra program body for the test program
39#
40AC_DEFUN(
41 [AC_CHECK_COMPILER_OPTION],
42 [AC_MSG_CHECKING([for $1 compiler option $4])
43  AC_LANG_PUSH($2)
44  COMPFLAGS_SAVE=[$]$3
45  ac_compile="$ac_compile >check_compiler_option.$$ 2>&1"
46  $3="[$]$3 $4"
47  AC_COMPILE_IFELSE(
48    [AC_LANG_PROGRAM(,[$5])],
49    [COMPILER_OPTION=yes],
50    [COMPILER_OPTION=no])
51  if test $COMPILER_OPTION = "yes"; then
52    if test `$EGREP "[Uu]nrecogni[sz]ed|[Uu]nknown|[Ii]nvalid|[Ee]rror" check_compiler_option.$$ | wc -l` -gt 0; then COMPILER_OPTION="no"; fi
53  fi
54  if test $COMPILER_OPTION = "yes"; then
55    AC_MSG_RESULT([yes])
56  else
57    AC_MSG_RESULT([no])
58    $3=$COMPFLAGS_SAVE
59  fi
60  rm -f check_compiler_option.$$
61  AC_LANG_POP($2)]
62)
63#
64# AC_CHECK_C_OPTION
65#
66AC_DEFUN(
67 [AC_CHECK_C_OPTION],
68 [AC_CHECK_COMPILER_OPTION(C,C,CFLAGS,[$1],[$2])]
69)
70#
71# AC_CHECK_CPP_OPTION
72#
73AC_DEFUN(
74 [AC_CHECK_CPP_OPTION],
75 [AC_CHECK_COMPILER_OPTION(C,C,CPPFLAGS,[$1],[$2])]
76)
77#
78# AC_CHECK_F77_OPTION
79#
80AC_DEFUN(
81 [AC_CHECK_F77_OPTION],
82 [AC_CHECK_COMPILER_OPTION(Fortran 77,Fortran 77,FFLAGS,[$1],[$2])]
83)
84#
85# AC_CHECK_F90_OPTION
86# We use the F77 test, but switch the name of the compiler
87#
88AC_DEFUN(
89 [AC_CHECK_F90_OPTION],
90 [F77_SAVE=[$]F77
91  FFLAGS_SAVE=[$]FFLAGS
92  F77=[$]F90
93  FFLAGS=[$]F90FLAGS
94  AC_CHECK_COMPILER_OPTION(Fortran 90,Fortran 77,FFLAGS,[$1],[$2])
95  F77=[$]F77_SAVE
96  FFLAGS=[$]FFLAGS_SAVE
97 ]
98)
99
100AC_DEFUN([LINUX_DISTRIBUTION],
101[
102        AC_REQUIRE([AC_CANONICAL_TARGET])
103        DISTRIBUTION=""
104        case "$target" in
105                i[[3456]]86-*-linux-* | i[[3456]]86-*-linux)
106                        if test -f /etc/lsb-release ; then
107                                DISTRIBUTION=`(. /etc/lsb-release; echo $DISTRIB_DESCRIPTION)`
108                        fi
109                        if test -z "$DISTRIBUTION"; then
110                                for i in /etc/*-release; do
111                                    if test "$i" != lsb-release; then DISTRIBUTION=`cat $i | head -1`; fi
112                                done
113                        fi
114                        ;;
115        esac
116        if test -z "$DISTRIBUTION"; then DISTRIBUTION="Unknown"; fi
117        AC_SUBST([DISTRIBUTION])
118])
119
120# AC_CHECK_ROOT
121#
122# $1 = name of arg
123# $2 = root variable name to set
124# $3 = list of root paths to try. If the path is a file, assume it is
125#                                 path/bin/files and then work out path
126# $4 = file in path to locate
127# $5 = default withval
128#
129# e.g. AC_CHECK_ROOT([tcl],[TCLROOT],[/usr /usr/local],[include/tcl.h])
130#
131AC_DEFUN(
132  [AC_CHECK_ROOT],
133  [ $2=""
134    AC_SUBST([$2])
135    AC_ARG_WITH([$1],
136        AC_HELP_STRING([--with-$1=/path/to/$1_install_directory],
137                       [Specify absolute path to root of $1 install directory.]),
138        [if test x$withval != xno -a x$withval != xyes; then $2=$withval; fi],
139        [with_$1=$5])
140    if test x$with_$1 != xno; then
141        AC_MSG_CHECKING(for $1 root installation directory)
142# if --with secified a file, assume it is ROOT/bin/file
143        if test x[$]$2 != x; then
144            if test -f [$]$2; then
145                $2=`dirname [$]$2`/..
146            fi
147        fi
148# $2 should now either be empty or a valid possible root
149        for i in $3; do
150            if test x[$]$2 = x -a -r $i/$4; then $2=$i; fi
151        done
152        if test x[$]$2 = x; then
153            AC_MSG_RESULT(unknown)
154        else
155            AC_MSG_RESULT([$]$2)
156        fi
157    fi
158  ])
159
160AC_DEFUN([AC_CHECK_PYTHON_MODULE],
161[
162    if test -z "$PYTHON"; then PYTHON="python"; fi
163    AC_MSG_CHECKING(for python module $1)
164    $PYTHON -c "import $1" 2>/dev/null
165    if test $? -eq 0; then
166        eval PYTHON_$1=1
167        eval PYTHON_$1_found="yes"
168        AC_MSG_RESULT(found)
169    else
170        eval PYTHON_$1=0
171        eval PYTHON_$1_found="no"
172        AC_MSG_RESULT(not found)
173    fi
174    AC_SUBST(PYTHON_$1)
175])
176
177# http://ac-archive.sourceforge.net/ac-archive/ac_prog_java_works.html
178
179AC_DEFUN([AC_PROG_JAVA_WORKS], [
180AC_CHECK_PROG(uudecode, uudecode$EXEEXT, yes)
181if test x$uudecode = xyes; then
182AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [
183dnl /**
184dnl  * Test.java: used to test if java compiler works.
185dnl  */
186dnl public class Test
187dnl {
188dnl
189dnl public static void
190dnl main( String[] argv )
191dnl {
192dnl     System.exit (0);
193dnl }
194dnl
195dnl }
196cat << \EOF > Test.uue
197begin-base64 644 Test.class
198yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
199bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
200bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s
201YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG
202aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB
203AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB
204AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ=
205====
206EOF
207if uudecode$EXEEXT Test.uue; then
208        ac_cv_prog_uudecode_base64=yes
209else
210        echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
211        echo "configure: failed file was:" >&AC_FD_CC
212        cat Test.uue >&AC_FD_CC
213        ac_cv_prog_uudecode_base64=no
214fi
215rm -f Test.uue])
216fi
217if test x$ac_cv_prog_uudecode_base64 != xyes; then
218        rm -f Test.class
219        AC_MSG_WARN([I have to compile Test.class from scratch])
220        if test x$ac_cv_prog_javac_works = xno; then
221                AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly])
222        fi
223        if test x$ac_cv_prog_javac_works = x; then
224                AC_PROG_JAVAC
225        fi
226fi
227AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [
228JAVA_TEST=Test.java
229CLASS_TEST=Test.class
230TEST=Test
231changequote(, )dnl
232cat << \EOF > $JAVA_TEST
233/* [#]line __oline__ "configure" */
234public class Test {
235public static void main (String args[]) {
236        System.exit (0);
237} }
238EOF
239changequote([, ])dnl
240if test x$ac_cv_prog_uudecode_base64 != xyes; then
241        if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then
242                :
243        else
244          echo "configure: failed program was:" >&AC_FD_CC
245          cat $JAVA_TEST >&AC_FD_CC
246          AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?))
247        fi
248fi
249if AC_TRY_COMMAND($JAVA $JAVAFLAGS $TEST) >/dev/null 2>&1; then
250  ac_cv_prog_java_works=yes
251else
252  echo "configure: failed program was:" >&AC_FD_CC
253  cat $JAVA_TEST >&AC_FD_CC
254  AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?))
255fi
256rm -fr $JAVA_TEST $CLASS_TEST Test.uue
257])
258AC_PROVIDE([$0])dnl
259]
260)
261
262# http://ac-archive.sourceforge.net/ac-archive/ac_prog_java.html
263
264AC_DEFUN([AC_PROG_JAVA],[
265AC_REQUIRE([AC_EXEEXT])dnl
266if test x$JAVAPREFIX = x; then
267        test x$JAVA = x && AC_CHECK_PROGS(JAVA, kaffe$EXEEXT java$EXEEXT)
268else
269        test x$JAVA = x && AC_CHECK_PROGS(JAVA, kaffe$EXEEXT java$EXEEXT, $JAVAPREFIX)
270fi
271test x$JAVA = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH])
272AC_PROG_JAVA_WORKS
273AC_PROVIDE([$0])dnl
274])
275
276# http://ac-archive.sourceforge.net/ac-archive/ac_prog_javac_works.html
277
278AC_DEFUN([AC_PROG_JAVAC_WORKS],[
279AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [
280JAVA_TEST=Test.java
281CLASS_TEST=Test.class
282cat << \EOF > $JAVA_TEST
283/* [#]line __oline__ "configure" */
284public class Test {
285}
286EOF
287if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then
288  ac_cv_prog_javac_works=yes
289else
290  AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)])
291  echo "configure: failed program was:" >&AC_FD_CC
292  cat $JAVA_TEST >&AC_FD_CC
293fi
294rm -f $JAVA_TEST $CLASS_TEST
295])
296AC_PROVIDE([$0])dnl
297])
298
299
300# http://ac-archive.sourceforge.net/ac-archive/ac_prog_javac.html
301
302AC_DEFUN([AC_PROG_JAVAC],[
303AC_REQUIRE([AC_EXEEXT])dnl
304if test "x$JAVAPREFIX" = x; then
305        test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, "gcj$EXEEXT -C" guavac$EXEEXT jikes$EXEEXT javac$EXEEXT)
306else
307        test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, "gcj$EXEEXT -C" guavac$EXEEXT jikes$EXEEXT javac$EXEEXT, $JAVAPREFIX)
308fi
309test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH])
310AC_PROG_JAVAC_WORKS
311AC_PROVIDE([$0])dnl
312])
313
314# http://ac-archive.sourceforge.net/ac-archive/ac_try_compile_java.html
315
316AC_DEFUN([AC_TRY_COMPILE_JAVA],[
317AC_REQUIRE([AC_PROG_JAVAC])dnl
318cat << \EOF > Test.java
319/* [#]line __oline__ "configure" */
320ifelse([$1], , , [import $1;])
321public class Test {
322[$2]
323}
324EOF
325if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class
326then
327dnl Don't remove the temporary files here, so they can be examined.
328  ifelse([$3], , :, [$3])
329else
330  echo "configure: failed program was:" >&AC_FD_CC
331  cat Test.java >&AC_FD_CC
332ifelse([$4], , , [  rm -fr Test*
333  $4
334])dnl
335fi
336rm -fr Test*])
337
338# http://ac-archive.sourceforge.net/ac-archive/ac_check_class.html
339
340AC_DEFUN([AC_CHECK_CLASS],[
341AC_REQUIRE([AC_PROG_JAVA])
342ac_var_name=`echo $1 | sed 's/\./_/g'`
343dnl Normaly I'd use a AC_CACHE_CHECK here but since the variable name is
344dnl dynamic I need an extra level of extraction
345AC_MSG_CHECKING([for $1 class])
346AC_CACHE_VAL(ac_cv_class_$ac_var_name, [
347if test x$ac_cv_prog_uudecode_base64 = xyes; then
348dnl /**
349dnl  * Test.java: used to test dynamicaly if a class exists.
350dnl  */
351dnl public class Test
352dnl {
353dnl
354dnl public static void
355dnl main( String[] argv )
356dnl {
357dnl     Class lib;
358dnl     if (argv.length < 1)
359dnl      {
360dnl             System.err.println ("Missing argument");
361dnl             System.exit (77);
362dnl      }
363dnl     try
364dnl      {
365dnl             lib = Class.forName (argv[0]);
366dnl      }
367dnl     catch (ClassNotFoundException e)
368dnl      {
369dnl             System.exit (1);
370dnl      }
371dnl     lib = null;
372dnl     System.exit (0);
373dnl }
374dnl
375dnl }
376cat << \EOF > Test.uue
377begin-base64 644 Test.class
378yv66vgADAC0AKQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
379bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
380bWJlclRhYmxlDAAKAAsBAANlcnIBABVMamF2YS9pby9QcmludFN0cmVhbTsJ
381AA0ACQcADgEAEGphdmEvbGFuZy9TeXN0ZW0IABABABBNaXNzaW5nIGFyZ3Vt
382ZW50DAASABMBAAdwcmludGxuAQAVKExqYXZhL2xhbmcvU3RyaW5nOylWCgAV
383ABEHABYBABNqYXZhL2lvL1ByaW50U3RyZWFtDAAYABkBAARleGl0AQAEKEkp
384VgoADQAXDAAcAB0BAAdmb3JOYW1lAQAlKExqYXZhL2xhbmcvU3RyaW5nOylM
385amF2YS9sYW5nL0NsYXNzOwoAHwAbBwAgAQAPamF2YS9sYW5nL0NsYXNzBwAi
386AQAgamF2YS9sYW5nL0NsYXNzTm90Rm91bmRFeGNlcHRpb24BAAY8aW5pdD4B
387AAMoKVYMACMAJAoAAwAlAQAKU291cmNlRmlsZQEACVRlc3QuamF2YQAhAAEA
388AwAAAAAAAgAJAAUABgABAAcAAABtAAMAAwAAACkqvgSiABCyAAwSD7YAFBBN
389uAAaKgMyuAAeTKcACE0EuAAaAUwDuAAasQABABMAGgAdACEAAQAIAAAAKgAK
390AAAACgAAAAsABgANAA4ADgATABAAEwASAB4AFgAiABgAJAAZACgAGgABACMA
391JAABAAcAAAAhAAEAAQAAAAUqtwAmsQAAAAEACAAAAAoAAgAAAAQABAAEAAEA
392JwAAAAIAKA==
393====
394EOF
395                if uudecode$EXEEXT Test.uue; then
396                        :
397                else
398                        echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
399                        echo "configure: failed file was:" >&AC_FD_CC
400                        cat Test.uue >&AC_FD_CC
401                        ac_cv_prog_uudecode_base64=no
402                fi
403        rm -f Test.uue
404        if AC_TRY_COMMAND($JAVA $JAVAFLAGS Test $1) >/dev/null 2>&1; then
405                eval "ac_cv_class_$ac_var_name=yes"
406        else
407                eval "ac_cv_class_$ac_var_name=no"
408        fi
409        rm -f Test.class
410else
411        AC_TRY_COMPILE_JAVA([$1], , [eval "ac_cv_class_$ac_var_name=yes"],
412                [eval "ac_cv_class_$ac_var_name=no"])
413fi
414eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`"
415eval "HAVE_$ac_var_name=$`echo ac_cv_class_$ac_var_val`"
416HAVE_LAST_CLASS=$ac_var_val
417if test x$ac_var_val = xyes; then
418        ifelse([$2], , :, [$2])
419else
420        ifelse([$3], , :, [$3])
421fi
422])
423dnl for some reason the above statment didn't fall though here?
424dnl do scripts have variable scoping?
425eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`"
426AC_MSG_RESULT($ac_var_val)
427])
428
429# ===========================================================================
430#      http://www.gnu.org/software/autoconf-archive/ax_check_junit.html
431# ===========================================================================
432#
433# SYNOPSIS
434#
435#   AX_CHECK_JUNIT
436#
437# DESCRIPTION
438#
439#   AX_CHECK_JUNIT tests the availability of the Junit testing framework,
440#   and set some variables for conditional compilation of the test suite by
441#   automake.
442#
443#   If available, JUNIT is set to a command launching the text based user
444#   interface of Junit, @JAVA_JUNIT@ is set to $JAVA_JUNIT and @TESTS_JUNIT@
445#   is set to $TESTS_JUNIT, otherwise they are set to empty values.
446#
447#   You can use these variables in your Makefile.am file like this :
448#
449#    # Some of the following classes are built only if junit is available
450#    JAVA_JUNIT  = Class1Test.java Class2Test.java AllJunitTests.java
451#
452#    noinst_JAVA = Example1.java Example2.java @JAVA_JUNIT@
453#
454#    EXTRA_JAVA  = $(JAVA_JUNIT)
455#
456#    TESTS_JUNIT = AllJunitTests
457#
458#    TESTS       = StandaloneTest1 StandaloneTest2 @TESTS_JUNIT@
459#
460#    EXTRA_TESTS = $(TESTS_JUNIT)
461#
462#    AllJunitTests :
463#       echo "#! /bin/sh" > $@
464#       echo "exec @JUNIT@ my.package.name.AllJunitTests" >> $@
465#       chmod +x $@
466#
467# LICENSE
468#
469#   Copyright (c) 2008 Luc Maisonobe <luc@spaceroots.org>
470#
471#   Copying and distribution of this file, with or without modification, are
472#   permitted in any medium without royalty provided the copyright notice
473#   and this notice are preserved. This file is offered as-is, without any
474#   warranty.
475
476AU_ALIAS([AC_CHECK_JUNIT], [AX_CHECK_JUNIT])
477AC_DEFUN([AX_CHECK_JUNIT],[
478AC_CACHE_VAL(ac_cv_prog_JUNIT,[
479AC_CHECK_CLASS(junit.textui.TestRunner)
480if test x"`eval 'echo $ac_cv_class_junit_textui_TestRunner'`" != xno ; then
481  ac_cv_prog_JUNIT='$(CLASSPATH_ENV) $(JAVA) $(JAVAFLAGS) junit.textui.TestRunner'
482fi])
483AC_MSG_CHECKING([for junit])
484if test x"`eval 'echo $ac_cv_prog_JUNIT'`" != x ; then
485  JUNIT="$ac_cv_prog_JUNIT"
486  JAVA_JUNIT='$(JAVA_JUNIT)'
487  TESTS_JUNIT='$(TESTS_JUNIT)'
488else
489  JUNIT=
490  JAVA_JUNIT=
491  TESTS_JUNIT=
492fi
493AC_MSG_RESULT($JAVA_JUNIT)
494AC_SUBST(JUNIT)
495AC_SUBST(JAVA_JUNIT)
496AC_SUBST(TESTS_JUNIT)])
Note: See TracBrowser for help on using the repository browser.