Commit 42c849a079579cb02e00df492cb364477884f4ee

Authored by Jürgen Knödlseder
1 parent 8bff97d1

Update according to recent GammaLib changes.

Showing 1 changed file with 163 additions and 124 deletions
configure.ac
@@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
29 ############################################################################# 29 #############################################################################
30 # Initialisation # 30 # Initialisation #
31 ############################################################################# 31 #############################################################################
32 -AC_INIT([ctools], [0.5.0], [jurgen.knodlseder@irap.omp.eu], [ctools]) 32 +AC_INIT([ctools], [0.5.1], [jurgen.knodlseder@irap.omp.eu], [ctools])
33 AC_CONFIG_SRCDIR([src/ctselect/ctselect.cpp]) 33 AC_CONFIG_SRCDIR([src/ctselect/ctselect.cpp])
34 AC_CONFIG_MACRO_DIR([m4]) 34 AC_CONFIG_MACRO_DIR([m4])
35 AM_INIT_AUTOMAKE([gnu no-dependencies]) 35 AM_INIT_AUTOMAKE([gnu no-dependencies])
@@ -66,10 +66,27 @@ AC_CANONICAL_HOST @@ -66,10 +66,27 @@ AC_CANONICAL_HOST
66 ############################################################################# 66 #############################################################################
67 # Check for valid C++ compiler. This has to come before the check for # 67 # Check for valid C++ compiler. This has to come before the check for #
68 # header files, otherwise we won't detect if the C++ compiler is missing. # 68 # header files, otherwise we won't detect if the C++ compiler is missing. #
  69 +# #
  70 +# A special kluge was added for Mac OS X >=10.7. As Apple switched to clang #
  71 +# we search from this version on for the clang compiler. #
69 ############################################################################# 72 #############################################################################
  73 +
  74 +# Set default compiler lists
  75 +cxx_list="g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++"
  76 +cc_list="gcc cc cl.exe clang"
  77 +
  78 +# Check if we have Mac OS X >= 10.7
  79 +if test `uname -s` = "Darwin"; then
  80 + if test `sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'` '>' 10.6; then
  81 + cxx_list="clang++ g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC"
  82 + cc_list="clang gcc cc cl.exe"
  83 + fi
  84 +fi
  85 +
  86 +# Our language is C++
70 AC_LANG(C++) 87 AC_LANG(C++)
71 -AC_PROG_CXX([g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++])  
72 -AC_PROG_CC([gcc cc cl.exe clang]) 88 +AC_PROG_CXX($cxx_list)
  89 +AC_PROG_CC($cc_list)
73 90
74 91
75 ############################################################################# 92 #############################################################################
@@ -354,16 +371,17 @@ yes) @@ -354,16 +371,17 @@ yes)
354 ;; 371 ;;
355 esac 372 esac
356 373
357 - # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the  
358 - # environment with a value that is the same as what we'll use  
359 - # in the Makefile to ensure that we'll get the same compiler  
360 - # environment during configure and build time.  
361 - MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"  
362 - export MACOSX_DEPLOYMENT_TARGET  
363 - EXPORT_MACOSX_DEPLOYMENT_TARGET=''  
364 -  
365 # Set compile, link and pre-processor flags dependent on architecture 374 # Set compile, link and pre-processor flags dependent on architecture
366 if test "${enable_universalsdk}"; then 375 if test "${enable_universalsdk}"; then
  376 +
  377 + # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
  378 + # environment with a value that is the same as what we'll use
  379 + # in the Makefile to ensure that we'll get the same compiler
  380 + # environment during configure and build time.
  381 + MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
  382 + export MACOSX_DEPLOYMENT_TARGET
  383 + EXPORT_MACOSX_DEPLOYMENT_TARGET=''
  384 +
367 UNIVERSAL_ARCH_FLAGS="" 385 UNIVERSAL_ARCH_FLAGS=""
368 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then 386 if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
369 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386" 387 UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
@@ -525,106 +543,107 @@ AC_ARG_ENABLE([python-binding], @@ -525,106 +543,107 @@ AC_ARG_ENABLE([python-binding],
525 if test "x$ac_enable_python_binding" = "xno"; then 543 if test "x$ac_enable_python_binding" = "xno"; then
526 AC_MSG_NOTICE([Python binding for ctools will not be built]) 544 AC_MSG_NOTICE([Python binding for ctools will not be built])
527 AC_MSG_NOTICE([Enable Python binding module building with --enable-python-binding]) 545 AC_MSG_NOTICE([Enable Python binding module building with --enable-python-binding])
528 -fi  
529 -  
530 -# Do we have Python and Python.h?  
531 -AM_PATH_PYTHON([2.2],  
532 - [has_python="yes"],  
533 - [AC_MSG_WARN([Python >= 2.2 not found. Python >= 2.2 is required to build python binding. Python can be obtained from http://www.python.org])])  
534 -  
535 -# It would really be weired if Python has not been found, as barely every system has Python. Maybe  
536 -# it was not found because the autoconf is so old, and in an early version of the AM_PATH_PYTHON  
537 -# there were no [Action-if-found] and [Action-if-not-found] arguments, hence $has_python is possibly  
538 -# badly set. However, the Python executable and version should be set correctly, and we can test  
539 -# for this to see whether Python is really there or not.  
540 -if test "x$has_python" = "xno"; then  
541 - AM_PYTHON_CHECK_VERSION([$PYTHON], [${PYTHON_VERSION}],  
542 - [has_python="yes"  
543 - AC_MSG_NOTICE([Wow! You're running a pretty old system. Found Python nevertheless:-)])],  
544 - [AC_MSG_WARN([Python not found.])])  
545 -fi  
546 -  
547 -# If we have Python then verify the presence of the header and set some flags  
548 -if test "x$has_python" = "xyes"; then 546 +else
549 547
550 - # Set opening and closing symbols to make setup.py compatible for versions 2 and 3  
551 - if test ${PYTHON_VERSION} '<' 3; then  
552 - PYTHON_OPEN=" "  
553 - PYTHON_CLOSE=""  
554 - else  
555 - PYTHON_OPEN="("  
556 - PYTHON_CLOSE=")"  
557 - fi  
558 - AC_SUBST(PYTHON_OPEN)  
559 - AC_SUBST(PYTHON_CLOSE)  
560 -  
561 - # Do we have distutils?  
562 - AC_MSG_CHECKING([for the distutils Python package])  
563 - ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`  
564 - if test -z "$ac_distutils_result"; then  
565 - AC_MSG_RESULT([yes])  
566 - else  
567 - AC_MSG_RESULT([no]) 548 + # Do we have Python and Python.h?
  549 + AM_PATH_PYTHON([2.2],
  550 + [has_python="yes"],
  551 + [AC_MSG_WARN([Python >= 2.2 not found. Python >= 2.2 is required to build python binding. Python can be obtained from http://www.python.org])])
  552 +
  553 + # It would really be weired if Python has not been found, as barely every system has Python. Maybe
  554 + # it was not found because the autoconf is so old, and in an early version of the AM_PATH_PYTHON
  555 + # there were no [Action-if-found] and [Action-if-not-found] arguments, hence $has_python is possibly
  556 + # badly set. However, the Python executable and version should be set correctly, and we can test
  557 + # for this to see whether Python is really there or not.
  558 + if test "x$has_python" = "xno"; then
  559 + AM_PYTHON_CHECK_VERSION([$PYTHON], [${PYTHON_VERSION}],
  560 + [has_python="yes"
  561 + AC_MSG_NOTICE([Wow! You're running a pretty old system. Found Python nevertheless:-)])],
  562 + [AC_MSG_WARN([Python not found.])])
568 fi 563 fi
569 564
570 - # If we have distutils then get python path from distutils ...  
571 - if test -z "$ac_distutils_result"; then  
572 - AC_MSG_CHECKING([for Python include path]) 565 + # If we have Python then verify the presence of the header and set some flags
  566 + if test "x$has_python" = "xyes"; then
  567 +
  568 + # Set opening and closing symbols to make setup.py compatible for versions 2 and 3
573 if test ${PYTHON_VERSION} '<' 3; then 569 if test ${PYTHON_VERSION} '<' 3; then
574 - python_path=`$PYTHON -c "import distutils.sysconfig; \  
575 - print distutils.sysconfig.get_python_inc();"` 570 + PYTHON_OPEN=" "
  571 + PYTHON_CLOSE=""
576 else 572 else
577 - python_path=`$PYTHON -c "import distutils.sysconfig; \  
578 - print(distutils.sysconfig.get_python_inc());"`  
579 - fi  
580 - if test -n "${python_path}"; then  
581 - AC_CHECK_HEADERS($python_path/Python.h, [has_python_h="yes"], [has_python_h="no"])  
582 - python_path="-I$python_path" 573 + PYTHON_OPEN="("
  574 + PYTHON_CLOSE=")"
  575 + fi
  576 + AC_SUBST(PYTHON_OPEN)
  577 + AC_SUBST(PYTHON_CLOSE)
  578 +
  579 + # Do we have distutils?
  580 + AC_MSG_CHECKING([for the distutils Python package])
  581 + ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
  582 + if test -z "$ac_distutils_result"; then
  583 + AC_MSG_RESULT([yes])
  584 + else
  585 + AC_MSG_RESULT([no])
583 fi 586 fi
584 - PYTHON_CPPFLAGS=$python_path  
585 - CPPFLAGS="${CPPFLAGS} ${python_path}"  
586 - AC_SUBST([PYTHON_CPPFLAGS])  
587 587
588 - # ... otherwise check for includes relative to exectuable (obsolete?)  
589 - else 588 + # If we have distutils then get python path from distutils ...
  589 + if test -z "$ac_distutils_result"; then
  590 + if test ${PYTHON_VERSION} '<' 3; then
  591 + python_path=`$PYTHON -c "import distutils.sysconfig; \
  592 + print distutils.sysconfig.get_python_inc();"`
  593 + else
  594 + python_path=`$PYTHON -c "import distutils.sysconfig; \
  595 + print(distutils.sysconfig.get_python_inc());"`
  596 + fi
  597 + if test -n "${python_path}"; then
  598 + AC_CHECK_HEADERS($python_path/Python.h, [has_python_h="yes"], [has_python_h="no"])
  599 + python_path="-I$python_path"
  600 + fi
  601 + PYTHON_CPPFLAGS=$python_path
  602 + CPPFLAGS="${CPPFLAGS} ${python_path}"
  603 + AC_SUBST([PYTHON_CPPFLAGS])
  604 +
  605 + # ... otherwise check for includes relative to exectuable (obsolete?)
  606 + else
590 607
591 - # Determine include path for python  
592 - AC_PATH_PROG(PY_INCLUDE, python)  
593 - PY_INCLUDE=`echo $PY_INCLUDE | sed -e "s/bin/include/"`  
594 - PY_INCLUDE="$PY_INCLUDE$PYTHON_VERSION" 608 + # Determine include path for python
  609 + AC_PATH_PROG(PY_INCLUDE, python)
  610 + PY_INCLUDE=`echo $PY_INCLUDE | sed -e "s/bin/include/"`
  611 + PY_INCLUDE="$PY_INCLUDE$PYTHON_VERSION"
595 612
596 - # Check if we have Python.h  
597 - AC_CHECK_HEADERS($PY_INCLUDE/Python.h, [has_python_h="yes"], [has_python_h="no"]) 613 + # Check if we have Python.h
  614 + AC_CHECK_HEADERS($PY_INCLUDE/Python.h, [has_python_h="yes"], [has_python_h="no"])
598 615
599 - # Signal any problem  
600 - if test "x$has_python_h" = "xno"; then  
601 - AC_MSG_WARN([No Python header file "$PY_INCLUDE/Python.h" found. Please install appropriate Python development package.]) 616 + # Signal any problem
  617 + if test "x$has_python_h" = "xno"; then
  618 + AC_MSG_WARN([No Python header file "$PY_INCLUDE/Python.h" found. Please install appropriate Python development package.])
  619 + fi
602 fi 620 fi
603 - fi  
604 621
605 -fi 622 + fi
606 623
607 -# Do we have swig?  
608 -AC_PATH_PROG([SWIG], [swig])  
609 -if test "$SWIG"; then  
610 - has_swig="yes"  
611 -fi  
612 -AM_CONDITIONAL(HAVE_SWIG, test "x$has_swig" = "xyes") 624 + # Do we have swig?
  625 + AC_PATH_PROG([SWIG], [swig])
  626 + if test "$SWIG"; then
  627 + has_swig="yes"
  628 + fi
613 629
614 -# Do we have wrappers (ctools_wrap.cpp and ctools.py)?  
615 -has_wrappers="yes"  
616 -AC_CHECK_FILES([pyext/ctools_wrap.cpp pyext/ctools.py],,  
617 - [has_wrappers="no"])  
618 -if test "x$has_wrappers" = "xno"; then  
619 - AC_MSG_WARN([Python wrapper missing. Requires swig for wrapper generation.])  
620 -fi 630 + # Do we have wrappers (ctools_wrap.cpp and ctools.py)?
  631 + has_wrappers="yes"
  632 + AC_CHECK_FILES([pyext/ctools_wrap.cpp pyext/ctools.py],,
  633 + [has_wrappers="no"])
  634 + if test "x$has_wrappers" = "xno"; then
  635 + AC_MSG_WARN([Python wrapper missing. Requires swig for wrapper generation.])
  636 + fi
621 637
622 -# Signal if Python is enabled  
623 -if test "x$ac_enable_python_binding" = "xyes" -a "x$has_python" = "xyes" -a "x$has_python_h" = "xyes"; then  
624 - if test "x$has_swig" = "xyes" -o "x$has_wrappers" = "xyes"; then  
625 - enable_python="yes" 638 + # Signal if Python is enabled
  639 + if test "x$ac_enable_python_binding" = "xyes" -a "x$has_python" = "xyes" -a "x$has_python_h" = "xyes"; then
  640 + if test "x$has_swig" = "xyes" -o "x$has_wrappers" = "xyes"; then
  641 + enable_python="yes"
  642 + fi
626 fi 643 fi
  644 +
627 fi 645 fi
  646 +AM_CONDITIONAL(HAVE_SWIG, test "x$has_swig" = "xyes")
628 AM_CONDITIONAL(WITH_PYTHON, test "x$enable_python" = "xyes") 647 AM_CONDITIONAL(WITH_PYTHON, test "x$enable_python" = "xyes")
629 648
630 # Set Python environment 649 # Set Python environment
@@ -723,6 +742,7 @@ fi @@ -723,6 +742,7 @@ fi
723 # Initialise OpenMP availability 742 # Initialise OpenMP availability
724 openmp_ok=no 743 openmp_ok=no
725 gammalib_with_openmp=no 744 gammalib_with_openmp=no
  745 +darwin_kluge=no
726 746
727 # Detect if GammaLib has been compiled with OpenMP 747 # Detect if GammaLib has been compiled with OpenMP
728 AC_MSG_CHECKING(whether GammaLib has been compiled with OpenMP) 748 AC_MSG_CHECKING(whether GammaLib has been compiled with OpenMP)
@@ -736,9 +756,6 @@ if test &quot;x$ac_cv_prog_cxx_openmp&quot; != &quot;xunsupported&quot; &amp;&amp; test &quot;x$ac_cv_prog_cxx_op @@ -736,9 +756,6 @@ if test &quot;x$ac_cv_prog_cxx_openmp&quot; != &quot;xunsupported&quot; &amp;&amp; test &quot;x$ac_cv_prog_cxx_op
736 openmp_ok=yes 756 openmp_ok=yes
737 fi 757 fi
738 758
739 -# Signal actual test  
740 -AC_MSG_CHECKING(whether to enable OpenMP)  
741 -  
742 # If OpenMP is available 759 # If OpenMP is available
743 if test "x$openmp_ok" = "xyes"; then 760 if test "x$openmp_ok" = "xyes"; then
744 761
@@ -758,12 +775,34 @@ if test &quot;x$openmp_ok&quot; = &quot;xyes&quot;; then @@ -758,12 +775,34 @@ if test &quot;x$openmp_ok&quot; = &quot;xyes&quot;; then
758 LDFLAGS=$SAVED_LDFLAGS 775 LDFLAGS=$SAVED_LDFLAGS
759 fi 776 fi
760 777
  778 + # Special Darwin test to see whether OpenMP compiles without adding the
  779 + # gomp_thread_attr global or whether we need to add this global.
  780 + if test "$ac_sys_system" = "Darwin"; then
  781 + AC_MSG_CHECKING(whether we need to add gomp_thread_attr)
  782 + SAVED_CXXFLAGS=$CXXFLAGS
  783 + CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"
  784 + AC_TRY_RUN(AC_LANG_PROGRAM([#include <omp.h>],
  785 + [omp_set_num_threads(1);]),
  786 + [AC_MSG_RESULT(no)],
  787 + [AC_TRY_RUN(AC_LANG_PROGRAM([#include <omp.h>;
  788 + #include <pthread.h>;
  789 + pthread_attr_t gomp_thread_attr;],
  790 + [omp_set_num_threads(1);]),
  791 + [AC_MSG_RESULT(yes)
  792 + darwin_kluge="yes"
  793 + AC_DEFINE([HAVE_OPENMP_DARWIN_KLUGE], [1], [Define if OpenMP Darwin kluge is needed])],
  794 + [AC_MSG_RESULT(no)
  795 + AC_MSG_WARN([Do not manage to compile OpenMP.])])])
  796 + CXXFLAGS=$SAVED_CXXFLAGS
  797 + fi
  798 +
761 # If gammalib is compiled with OpenMP, ctools must also be compiled with 799 # If gammalib is compiled with OpenMP, ctools must also be compiled with
762 # openmp 800 # openmp
763 if test "x$gammalib_with_openmp" = "xyes"; then 801 if test "x$gammalib_with_openmp" = "xyes"; then
764 enable_openmp="yes" 802 enable_openmp="yes"
765 else 803 else
766 # ... otherwise, we use it optionally 804 # ... otherwise, we use it optionally
  805 + AC_MSG_CHECKING(whether to enable OpenMP)
767 AC_ARG_ENABLE([openmp], 806 AC_ARG_ENABLE([openmp],
768 AS_HELP_STRING([--enable-openmp], 807 AS_HELP_STRING([--enable-openmp],
769 [turn on OpenMP support [default=yes]]), 808 [turn on OpenMP support [default=yes]]),
@@ -786,13 +825,13 @@ AC_SUBST(OPENMP_CXXFLAGS) @@ -786,13 +825,13 @@ AC_SUBST(OPENMP_CXXFLAGS)
786 825
787 # Set system specific settings 826 # Set system specific settings
788 OPENMP_LIB_LDFLAGS= 827 OPENMP_LIB_LDFLAGS=
789 -if test "x$enable_openmp" = "xyes"; then  
790 - case $ac_sys_system/$ac_sys_release in  
791 - Darwin/*)  
792 - OPENMP_LIB_LDFLAGS=-lgomp  
793 - ;;  
794 - esac  
795 -fi 828 +#if test "x$enable_openmp" = "xyes"; then
  829 +# case $ac_sys_system/$ac_sys_release in
  830 +# Darwin/*)
  831 +# OPENMP_LIB_LDFLAGS=-lgomp
  832 +# ;;
  833 +# esac
  834 +#fi
796 AC_SUBST(OPENMP_LIB_LDFLAGS) 835 AC_SUBST(OPENMP_LIB_LDFLAGS)
797 836
798 # Signal if ctools cannot be compiled as gammalibe requires OpenMP but ctools 837 # Signal if ctools cannot be compiled as gammalibe requires OpenMP but ctools
@@ -861,26 +900,6 @@ if test &quot;x$has_gammalib&quot; = &quot;xyes&quot;; then @@ -861,26 +900,6 @@ if test &quot;x$has_gammalib&quot; = &quot;xyes&quot;; then
861 else 900 else
862 echo " - GammaLib support (no) no gammalib library found" 901 echo " - GammaLib support (no) no gammalib library found"
863 fi 902 fi
864 -if test "x$has_python" = "xyes"; then  
865 - echo " * Python (yes)"  
866 -else  
867 - echo " - Python (no)"  
868 -fi  
869 -if test "x$has_python_h" = "xyes"; then  
870 - echo " * Python.h (yes)"  
871 -else  
872 - echo " - Python.h (no)"  
873 -fi  
874 -if test "x$has_swig" = "xyes"; then  
875 - echo " * swig (yes)"  
876 -else  
877 - echo " - swig (no)"  
878 -fi  
879 -if test "x$has_wrappers" = "xyes"; then  
880 - echo " * Python wrappers (yes)"  
881 -else  
882 - echo " - Python wrappers (no)"  
883 -fi  
884 903
885 # Dump Python binding information 904 # Dump Python binding information
886 if test "x$ac_enable_python_binding" = "xyes"; then 905 if test "x$ac_enable_python_binding" = "xyes"; then
@@ -905,6 +924,26 @@ if test &quot;x$ac_enable_python_binding&quot; = &quot;xyes&quot;; then @@ -905,6 +924,26 @@ if test &quot;x$ac_enable_python_binding&quot; = &quot;xyes&quot;; then
905 else 924 else
906 echo " - Make Python binding (no) Python not installed" 925 echo " - Make Python binding (no) Python not installed"
907 fi 926 fi
  927 + if test "x$has_python" = "xyes"; then
  928 + echo " * Python (yes)"
  929 + else
  930 + echo " - Python (no)"
  931 + fi
  932 + if test "x$has_python_h" = "xyes"; then
  933 + echo " * Python.h (yes)"
  934 + else
  935 + echo " - Python.h (no)"
  936 + fi
  937 + if test "x$has_swig" = "xyes"; then
  938 + echo " * swig (yes)"
  939 + else
  940 + echo " - swig (no)"
  941 + fi
  942 + if test "x$has_wrappers" = "xyes"; then
  943 + echo " * Python wrappers (yes)"
  944 + else
  945 + echo " - Python wrappers (no)"
  946 + fi
908 else 947 else
909 echo " - Make Python binding (no)" 948 echo " - Make Python binding (no)"
910 fi 949 fi