Commit 3b1bd84b4eb00b09d767c87bab979801482a37d5

Authored by knodlseder
1 parent 65ca2bba

add --enable-univseralsdk and --with-univeral-archs options for Darwin (code in…

…spired from Python configure script) and disable automake dependency tracking
Showing 1 changed file with 382 additions and 71 deletions
configure.ac
1   -# Configuration for ctools - a set of tools for science analysis of CTA data
2   -#
3   -# Copyright (C) 2011 Jurgen Knodlseder
4   -#
5   -# This program is free software: you can redistribute it and/or modify
6   -# it under the terms of the GNU General Public License as published by
7   -# the Free Software Foundation, either version 3 of the License, or
8   -# (at your option) any later version.
9   -#
10   -# This program is distributed in the hope that it will be useful,
11   -# but WITHOUT ANY WARRANTY; without even the implied warranty of
12   -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   -# GNU General Public License for more details.
14   -#
15   -# You should have received a copy of the GNU General Public License
16   -# along with this program. If not, see <http://www.gnu.org/licenses/>.
17   -#
18   -# Process this file with autoconf to produce a configure script
19   -
  1 +#############################################################################
  2 +# Configuration for ctools - a set of tools for science analysis of CTA #
  3 +# data #
  4 +# ------------------------------------------------------------------------- #
  5 +# Copyright (C) 2011 Jurgen Knodlseder #
  6 +# ------------------------------------------------------------------------- #
  7 +# #
  8 +# This program is free software: you can redistribute it and/or modify #
  9 +# it under the terms of the GNU General Public License as published by #
  10 +# the Free Software Foundation, either version 3 of the License, or #
  11 +# (at your option) any later version. #
  12 +# #
  13 +# This program is distributed in the hope that it will be useful, #
  14 +# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  15 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  16 +# GNU General Public License for more details. #
  17 +# #
  18 +# You should have received a copy of the GNU General Public License #
  19 +# along with this program. If not, see <http://www.gnu.org/licenses/>. #
  20 +# #
  21 +# ------------------------------------------------------------------------- #
  22 +# Process this file with autoconf to produce a configure script. #
  23 +# ------------------------------------------------------------------------- #
  24 +# ToDo: #
  25 +# - add possibility to build as Framework on Darwin #
  26 +# - strip "-Wstrict-prototypes" for C++ compiling #
  27 +#############################################################################
  28 +
  29 +#############################################################################
  30 +# Initialisation #
  31 +#############################################################################
20 32 AC_INIT([ctools], [0.3.0], [knodlseder@cesr.fr], [ctools])
21 33 AC_CONFIG_SRCDIR([src/ctselect/ctselect.cpp])
22 34 AC_CONFIG_MACRO_DIR([m4])
  35 +AM_INIT_AUTOMAKE([gnu no-dependencies])
23 36 AC_CONFIG_HEADERS([config.h])
24   -AM_INIT_AUTOMAKE
25 37  
26 38  
27   -dnl ==========
28   -dnl Set prefix
29   -dnl ==========
  39 +#############################################################################
  40 +# Set prefix #
  41 +# ------------------------------------------------------------------------- #
  42 +# By default, ctools get installed into "/usr/local/gamma". The default #
  43 +# can be overwritten using the --prefix option. #
  44 +#############################################################################
30 45 AC_PREFIX_DEFAULT([/usr/local/gamma])
31 46 if test "x$prefix" = xNONE; then
32 47 ctools_prefix="/usr/local/gamma"
... ... @@ -36,44 +51,294 @@ fi
36 51 AC_DEFINE_UNQUOTED([PACKAGE_PREFIX], "${ctools_prefix}", [Location where library is installed])
37 52  
38 53  
39   -dnl ===========================
40   -dnl things required by automake
41   -dnl ===========================
42   -dnl AC_ARG_PROGRAM
  54 +#############################################################################
  55 +# Check for programs that are required by automake #
  56 +#############################################################################
43 57 AC_PROG_MAKE_SET
44 58  
45 59  
46   -dnl =========================
47   -dnl Check for system services
48   -dnl =========================
  60 +#############################################################################
  61 +# Determine the build and host system type #
  62 +#############################################################################
49 63 AC_CANONICAL_HOST
50 64  
51 65  
52   -dnl ===================
53   -dnl Checks for programs
54   -dnl ===================
  66 +#############################################################################
  67 +# Determine the C and C++ compilers. This has to come before the check for #
  68 +# header files, otherwise we won't detect if the C++ compiler is missing. #
  69 +#############################################################################
  70 +AC_PROG_CC
55 71 AC_PROG_CXX
56   -AC_PROG_INSTALL
57   -AC_PROG_LIBTOOL
58   -
59 72  
60   -dnl =======================
61   -dnl Checks for header files
62   -dnl =======================
63   -AC_STDC_HEADERS
64   -
65   -
66   -dnl =============================================================
67   -dnl Checks for typedefs, structures, and compiler characteristics
68   -dnl =============================================================
69   -AC_TYPE_SIZE_T
70   -AC_C_CONST
71   -AC_C_INLINE
72 73  
  74 +#############################################################################
  75 +# Darwin option: Determine if a universal library should be built #
  76 +# ------------------------------------------------------------------------- #
  77 +# --enable-universalsdk=PATH takes an optional argument that specifies #
  78 +# which OSX SDK should be used to perform the build. This defaults to #
  79 +# "/Developer/SDKs/MacOSX.10.4u.sdk". Specify "/" when building on a 10.5 #
  80 +# system or larger, especially when building 64-bit code. #
  81 +#############################################################################
  82 +AC_MSG_CHECKING([for --enable-universalsdk])
  83 +AC_ARG_ENABLE(universalsdk,
  84 + AS_HELP_STRING([--enable-universalsdk@<:@=SDKDIR@:>@], [Build against Mac OS X 10.4u SDK (ppc/i386)]),
  85 +[
  86 + case $enableval in
  87 + yes)
  88 + enableval=/Developer/SDKs/MacOSX10.4u.sdk
  89 + if test ! -d "${enableval}"
  90 + then
  91 + enableval=/
  92 + fi
  93 + ;;
  94 + esac
  95 + case $enableval in
  96 + no)
  97 + UNIVERSALSDK=
  98 + enable_universalsdk=
  99 + ;;
  100 + *)
  101 + UNIVERSALSDK=$enableval
  102 + if test ! -d "${UNIVERSALSDK}"
  103 + then
  104 + AC_MSG_ERROR([--enable-universalsdk specifies non-existing SDK: ${UNIVERSALSDK}])
  105 + fi
  106 + ;;
  107 + esac
  108 +
  109 +],[
  110 + UNIVERSALSDK=
  111 + enable_universalsdk=
  112 +])
  113 +if test -n "${UNIVERSALSDK}"
  114 +then
  115 + AC_MSG_RESULT(${UNIVERSALSDK})
  116 +else
  117 + AC_MSG_RESULT(no)
  118 +fi
  119 +AC_SUBST(UNIVERSALSDK)
  120 +
  121 +
  122 +#############################################################################
  123 +# Darwin option: Determine archirecture of universal library to be built #
  124 +# ------------------------------------------------------------------------- #
  125 +# --with-univeral-archs=VALUE, where VALUE is one of "32-bit", "64-bit", #
  126 +# "3-way", "intel" or "all". Defaults to "32-bit". #
  127 +#############################################################################
  128 +UNIVERSAL_ARCHS="32-bit"
  129 +AC_SUBST(LIPO_32BIT_FLAGS)
  130 +AC_MSG_CHECKING(for --with-universal-archs)
  131 +AC_ARG_WITH(universal-archs,
  132 + AS_HELP_STRING([--with-universal-archs=ARCH], [select architectures for universal build ("32-bit", "64-bit", "3-way", "intel" or "all")]),
  133 +[
  134 + AC_MSG_RESULT($withval)
  135 + UNIVERSAL_ARCHS="$withval"
  136 + if test "${enable_universalsdk}" ; then
  137 + :
  138 + else
  139 + AC_MSG_ERROR([--with-universal-archs without --enable-universalsdk.])
  140 + fi
  141 +],
  142 +[
  143 + AC_MSG_RESULT(32-bit)
  144 +])
  145 +
  146 +
  147 +#############################################################################
  148 +# Record MACOSX_DEPLOYMENT_TARGET #
  149 +# ------------------------------------------------------------------------- #
  150 +# Record the configure-time value of MACOSX_DEPLOYMENT_TARGET, it may #
  151 +# influence the way we can build extensions, so distutils needs to check it #
  152 +#############################################################################
  153 +AC_SUBST(CONFIGURE_MACOSX_DEPLOYMENT_TARGET)
  154 +AC_SUBST(EXPORT_MACOSX_DEPLOYMENT_TARGET)
  155 +CONFIGURE_MACOSX_DEPLOYMENT_TARGET=
  156 +EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
  157 +
  158 +
  159 +#############################################################################
  160 +# Set name for machine-dependent library files #
  161 +#############################################################################
  162 +AC_SUBST(MACHDEP)
  163 +AC_MSG_CHECKING(MACHDEP)
  164 +if test -z "$MACHDEP"; then
  165 + ac_sys_system=`uname -s`
  166 + if test "$ac_sys_system" = "AIX" \
  167 + -o "$ac_sys_system" = "UnixWare" -o "$ac_sys_system" = "OpenUNIX"; then
  168 + ac_sys_release=`uname -v`
  169 + else
  170 + ac_sys_release=`uname -r`
  171 + fi
  172 + ac_md_system=`echo $ac_sys_system |
  173 + tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
  174 + ac_md_release=`echo $ac_sys_release |
  175 + tr -d '[/ ]' | sed 's/^[[A-Z]]\.//' | sed 's/\..*//'`
  176 +
  177 + # Set MACHDEP
  178 + MACHDEP="$ac_md_system$ac_md_release"
  179 + case $MACHDEP in
  180 + cygwin*) MACHDEP="cygwin";;
  181 + darwin*) MACHDEP="darwin";;
  182 + atheos*) MACHDEP="atheos";;
  183 + irix646) MACHDEP="irix6";;
  184 + '') MACHDEP="unknown";;
  185 + esac
  186 +fi
  187 +AC_MSG_CHECKING(machine type as reported by uname -m)
  188 +ac_sys_machine=`uname -m`
  189 +AC_MSG_RESULT($ac_sys_machine)
  190 +
  191 +
  192 +#############################################################################
  193 +# Set -arch flags for universal builds on OSX and tweak BASECFLAGS based on #
  194 +# compiler and platform (note that BASECFLAGS are not yet used). #
  195 +#############################################################################
  196 +# Initialise the -arch flags for universal builds on OSX
  197 +UNIVERSAL_ARCH_FLAGS=
  198 +AC_SUBST(UNIVERSAL_ARCH_FLAGS)
  199 +
  200 +# Tweak BASECFLAGS based on compiler and platform
  201 +case $GCC in
  202 +yes)
  203 +
  204 + # if using gcc on alpha, use -mieee to get (near) full IEEE 754
  205 + # support. Without this, treatment of subnormals doesn't follow
  206 + # the standard.
  207 + case $ac_sys_machine in
  208 + alpha*)
  209 + BASECFLAGS="$BASECFLAGS -mieee"
  210 + ;;
  211 + esac
  212 +
  213 + case $ac_sys_system in
  214 + SCO_SV*)
  215 + BASECFLAGS="$BASECFLAGS -m486 -DSCO5"
  216 + ;;
  217 + # is there any other compiler on Darwin besides gcc?
  218 + Darwin*)
  219 + # -Wno-long-double, -no-cpp-precomp, and -mno-fused-madd
  220 + # used to be here, but non-Apple gcc doesn't accept them.
  221 + if test "${CC}" = gcc; then
  222 + AC_MSG_CHECKING(which compiler should be used)
  223 + case "${UNIVERSALSDK}" in
  224 + */MacOSX10.4u.sdk)
  225 + # Build using 10.4 SDK, force usage of gcc when the
  226 + # compiler is gcc, otherwise the user will get very
  227 + # confusing error messages when building on OSX 10.6
  228 + CC=gcc-4.0
  229 + CXX=g++-4.0
  230 + CPP=cpp-4.0
  231 + ac_ct_CC="$CC"
  232 + ac_ct_CXX="$CXX"
  233 + ac_cv_prog_ac_ct_CC="$ac_ct_CC"
  234 + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX"
  235 + ;;
  236 + esac
  237 + AC_MSG_RESULT($CXX)
  238 + fi
73 239  
74   -dnl =================================
75   -dnl Checks for debugging or profiling
76   -dnl =================================
  240 + # Calculate the right deployment target for this build.
  241 + #
  242 + cur_target=`sw_vers -productVersion | sed 's/\(10\.[[0-9]]*\).*/\1/'`
  243 + if test ${cur_target} '>' 10.2; then
  244 + cur_target=10.3
  245 + if test ${enable_universalsdk}; then
  246 + if test "${UNIVERSAL_ARCHS}" = "all"; then
  247 + # Ensure that the default platform for a
  248 + # 4-way universal build is OSX 10.5,
  249 + # that's the first OS release where
  250 + # 4-way builds make sense.
  251 + cur_target='10.5'
  252 + elif test "${UNIVERSAL_ARCHS}" = "3-way"; then
  253 + cur_target='10.5'
  254 + elif test "${UNIVERSAL_ARCHS}" = "intel"; then
  255 + cur_target='10.5'
  256 + elif test "${UNIVERSAL_ARCHS}" = "64-bit"; then
  257 + cur_target='10.5'
  258 + elif test `/usr/bin/arch` = "i386"; then
  259 + # On Intel macs default to a deployment
  260 + # target of 10.4, that's the first OSX
  261 + # release with Intel support.
  262 + cur_target="10.4"
  263 + fi
  264 + else
  265 + if test `/usr/bin/arch` = "i386"; then
  266 + # On Intel macs default to a deployment
  267 + # target of 10.4, that's the first OSX
  268 + # release with Intel support.
  269 + cur_target="10.4"
  270 + fi
  271 + fi
  272 + fi
  273 + CONFIGURE_MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET-${cur_target}}
  274 +
  275 + # Make sure that MACOSX_DEPLOYMENT_TARGET is set in the
  276 + # environment with a value that is the same as what we'll use
  277 + # in the Makefile to ensure that we'll get the same compiler
  278 + # environment during configure and build time.
  279 + MACOSX_DEPLOYMENT_TARGET="$CONFIGURE_MACOSX_DEPLOYMENT_TARGET"
  280 + export MACOSX_DEPLOYMENT_TARGET
  281 + EXPORT_MACOSX_DEPLOYMENT_TARGET=''
  282 +
  283 + # Set compile, link and pre-processor flags dependent on architecture
  284 + if test "${enable_universalsdk}"; then
  285 + UNIVERSAL_ARCH_FLAGS=""
  286 + if test "$UNIVERSAL_ARCHS" = "32-bit" ; then
  287 + UNIVERSAL_ARCH_FLAGS="-arch ppc -arch i386"
  288 + ARCH_RUN_32BIT=""
  289 + LIPO_32BIT_FLAGS=""
  290 + elif test "$UNIVERSAL_ARCHS" = "64-bit" ; then
  291 + UNIVERSAL_ARCH_FLAGS="-arch ppc64 -arch x86_64"
  292 + LIPO_32BIT_FLAGS=""
  293 + ARCH_RUN_32BIT="true"
  294 + elif test "$UNIVERSAL_ARCHS" = "all" ; then
  295 + UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch ppc64 -arch x86_64"
  296 + LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
  297 + ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
  298 + elif test "$UNIVERSAL_ARCHS" = "intel" ; then
  299 + UNIVERSAL_ARCH_FLAGS="-arch i386 -arch x86_64"
  300 + LIPO_32BIT_FLAGS="-extract i386"
  301 + ARCH_RUN_32BIT="/usr/bin/arch -i386"
  302 + elif test "$UNIVERSAL_ARCHS" = "3-way" ; then
  303 + UNIVERSAL_ARCH_FLAGS="-arch i386 -arch ppc -arch x86_64"
  304 + LIPO_32BIT_FLAGS="-extract ppc7400 -extract i386"
  305 + ARCH_RUN_32BIT="/usr/bin/arch -i386 -ppc"
  306 + else
  307 + AC_MSG_ERROR([proper usage is --with-universal-arch=32-bit|64-bit|all|intel|3-way])
  308 + fi
  309 + CXXFLAGS="${UNIVERSAL_ARCH_FLAGS} ${CXXFLAGS}"
  310 + if test "${UNIVERSALSDK}" != "/"; then
  311 + CPPFLAGS="-isysroot ${UNIVERSALSDK} ${CPPFLAGS}"
  312 + LDFLAGS="-isysroot ${UNIVERSALSDK} ${LDFLAGS}"
  313 + CXXFLAGS="-isysroot ${UNIVERSALSDK} ${CXXFLAGS}"
  314 + fi
  315 + fi
  316 + ;;
  317 + OSF*)
  318 + BASECFLAGS="$BASECFLAGS -mieee"
  319 + ;;
  320 + esac
  321 + ;;
  322 +*)
  323 + case $ac_sys_system in
  324 + OpenUNIX*|UnixWare*)
  325 + BASECFLAGS="$BASECFLAGS -K pentium,host,inline,loop_unroll,alloca "
  326 + ;;
  327 + OSF*)
  328 + BASECFLAGS="$BASECFLAGS -ieee -std"
  329 + ;;
  330 + SCO_SV*)
  331 + BASECFLAGS="$BASECFLAGS -belf -Ki486 -DSCO5"
  332 + ;;
  333 + esac
  334 + ;;
  335 +esac
  336 +
  337 +
  338 +#############################################################################
  339 +# Checks for debugging and profiling options #
  340 +#############################################################################
  341 +# Check for debugging option
77 342 AC_MSG_CHECKING(whether to enable debugging)
78 343 AC_ARG_ENABLE([debug],
79 344 AS_HELP_STRING([--enable-debug],
... ... @@ -89,6 +354,8 @@ if test &quot;x$enable_debug&quot; = &quot;xyes&quot;; then
89 354 else
90 355 AC_MSG_RESULT(no)
91 356 fi
  357 +
  358 +# Check for profiling option
92 359 AC_MSG_CHECKING(whether to enable profiling)
93 360 AC_ARG_ENABLE([profiling],
94 361 AS_HELP_STRING([--enable-profiling],
... ... @@ -106,14 +373,59 @@ else
106 373 fi
107 374  
108 375  
109   -dnl =========================================================================
110   -dnl Checks if Python bindings are to be build. Python binding requires Python
111   -dnl and either the files ctools_wrap.cpp and ctools.py or swig to create
112   -dnl these files. The following conditionals are set:
113   -dnl WITH_PYTHON - Python bindings will be built
114   -dnl HAVE_SWIG - swig is available
115   -dnl =========================================================================
  376 +#############################################################################
  377 +# Set linker options #
  378 +#############################################################################
  379 +case $ac_sys_system/$ac_sys_release in
  380 +Darwin/*)
  381 + # Use -undefined dynamic_lookup whenever possible (10.3 and later).
  382 + # This allows an extension to be used in any Python
  383 + if test ${MACOSX_DEPLOYMENT_TARGET} '>' 10.2; then
  384 + if test "${enable_universalsdk}"; then
  385 + LDFLAGS="${UNIVERSAL_ARCH_FLAGS} -isysroot ${UNIVERSALSDK} ${LDFLAGS}"
  386 + fi
  387 + fi
  388 + ;;
  389 +esac
116 390  
  391 +
  392 +#############################################################################
  393 +# Checks for header files #
  394 +#############################################################################
  395 +AC_HEADER_STDC
  396 +
  397 +
  398 +#############################################################################
  399 +# Checks for installer #
  400 +#############################################################################
  401 +AC_PROG_INSTALL
  402 +
  403 +
  404 +#############################################################################
  405 +# Checks for libtool. We need to do this after the compiler has been #
  406 +# determined. #
  407 +#############################################################################
  408 +AC_PROG_LIBTOOL
  409 +
  410 +
  411 +#############################################################################
  412 +# Checks for typedefs, structures, and compiler characteristics #
  413 +#############################################################################
  414 +AC_TYPE_SIZE_T
  415 +# AC_TYPE_LONG_LONG_INT
  416 +AC_C_CONST
  417 +AC_C_INLINE
  418 +
  419 +
  420 +#############################################################################
  421 +# Checks if Python bindings are to be build #
  422 +# ------------------------------------------------------------------------- #
  423 +# Python binding requires Python and either the files ctools_wrap.cpp and #
  424 +# ctools.py or swig to create these files. The following conditionals are #
  425 +# set: #
  426 +# WITH_PYTHON - Python bindings will be built #
  427 +# HAVE_SWIG - swig is available #
  428 +#############################################################################
117 429 # Initialise flags
118 430 enable_python="no"
119 431 has_python="no"
... ... @@ -233,10 +545,9 @@ else
233 545 fi
234 546  
235 547  
236   -dnl ===========================
237   -dnl Checks for GammaLib library
238   -dnl ===========================
239   -
  548 +#############################################################################
  549 +# Checks for GammaLib library #
  550 +#############################################################################
240 551 # Initialise GammaLib availability
241 552 has_gammalib="no"
242 553  
... ... @@ -295,9 +606,9 @@ root directory of GammaLib.])
295 606 fi
296 607  
297 608  
298   -dnl ==================
299   -dnl Build static code?
300   -dnl ==================
  609 +#############################################################################
  610 +# Build static code? #
  611 +#############################################################################
301 612 if test "x$enable_profiling" = "xyes"; then
302 613 AC_MSG_NOTICE([Link executables statically.])
303 614 LIB_LINK_OPTION="-all-static"
... ... @@ -318,9 +629,9 @@ fi
318 629 AC_SUBST(LIB_LINK_OPTION)
319 630  
320 631  
321   -dnl ==========================
322   -dnl Create configuration files
323   -dnl ==========================
  632 +#############################################################################
  633 +# Set list of output files to be created #
  634 +#############################################################################
324 635 AC_CONFIG_FILES([Makefile
325 636 src/Makefile
326 637 src/ctselect/Makefile
... ... @@ -342,9 +653,9 @@ AC_CONFIG_FILES([Makefile
342 653 AC_OUTPUT
343 654  
344 655  
345   -dnl ===========================
346   -dnl Print configuration summary
347   -dnl ===========================
  656 +#############################################################################
  657 +# Print configuration summary to console #
  658 +#############################################################################
348 659 echo
349 660 echo " ctools configuration summary"
350 661 echo " =============================="
... ...