~ubuntu-branches/ubuntu/maverick/openturns/maverick

« back to all changes in this revision

Viewing changes to lib/m4/examples/m4/ot_check_openturns.m4

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2008-11-18 06:32:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20081118063222-pa0qncclrerrqkg2
Tags: 0.12.2-1
* New upstream release
* Bug fix: "New upstream release available (0.12.2)", thanks to Jerome
  Robert (Closes: #506005).
* Applied patch by J. Robert.
* debian/control: build-depends on libxml2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#                                               -*- Autoconf -*-
 
2
#
 
3
#  ot_check_openturns.m4
 
4
#
 
5
#  (C) Copyright 2005-2007 EDF-EADS-Phimeca
 
6
#
 
7
#  This library is free software; you can redistribute it and/or
 
8
#  modify it under the terms of the GNU Lesser General Public
 
9
#  License as published by the Free Software Foundation; either
 
10
#  version 2.1 of the License.
 
11
#
 
12
#  This library is distributed in the hope that it will be useful
 
13
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
#  Lesser General Public License for more details.
 
16
#
 
17
#  You should have received a copy of the GNU Lesser General Public
 
18
#  License along with this library; if not, write to the Free Software
 
19
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 
20
#
 
21
#  @author: $LastChangedBy: dutka $
 
22
#  @date:   $LastChangedDate: 2008-09-22 11:34:11 +0200 (Mon, 22 Sep 2008) $
 
23
#  Id:      $Id: ot_check_openturns.m4 941 2008-09-22 09:34:11Z dutka $
 
24
#  serial   0.11.0
 
25
#
 
26
#
 
27
# This file is intended to be include in configure.in file
 
28
# of any project that embed Open TURNS. It allows the correct
 
29
# detection of Open TURNS by the embedding project without
 
30
# it knowing its intrinsics.
 
31
#
 
32
# OT_CHECK_OPENTURNS( [OPENTURNS_INSTALL_PATH = /usr] )
 
33
# -----------------------------------------------------
 
34
#
 
35
AC_DEFUN([OT_CHECK_OPENTURNS],
 
36
[
 
37
  AC_ARG_WITH([openturns],
 
38
              AC_HELP_STRING([--with-openturns=<path>],
 
39
                             [add Open TURNS support. <Path> should point to a actual install path of Open TURNS library and headers. If ommitted, assume that Open TURNS is installed in /usr, ie <path>=/usr. Default is to support Open TURNS.]),
 
40
              [], [withval=yes])
 
41
 
 
42
  WITH_OPENTURNS=0
 
43
 
 
44
  # saving values for compilation variables
 
45
  saved_CPPFLAGS=$CPPFLAGS
 
46
  saved_LDFLAGS=$LDFLAGS
 
47
  saved_LIBS=$LIBS
 
48
 
 
49
  openturns_default_path=m4_default([$1], /usr)
 
50
  if ! test x${withval} = xno
 
51
  then
 
52
    AC_CACHE_CHECK([for Open TURNS install path],  [ot_cv_openturns_install_path], [])
 
53
    AC_CACHE_CHECK([for Open TURNS include flags], [ot_cv_openturns_cppflags], [])
 
54
    AC_CACHE_CHECK([for Open TURNS library flags], [ot_cv_openturns_ldflags],  [])
 
55
    AC_CACHE_CHECK([for Open TURNS libraries],     [ot_cv_openturns_libs],     [])
 
56
    AC_CACHE_CHECK([for Open TURNS wrapper include flags], [ot_cv_openturns_wrapper_cppflags], [])
 
57
    AC_CACHE_CHECK([for Open TURNS wrapper library flags], [ot_cv_openturns_wrapper_ldflags],  [])
 
58
    AC_CACHE_CHECK([for Open TURNS wrapper library],       [ot_cv_openturns_wrapper_libs],     [])
 
59
    AC_CACHE_CHECK([for Open TURNS wrapper DTD path],      [ot_cv_openturns_wrapper_dtd_path], [])
 
60
 
 
61
    if test -z "$ot_cv_openturns_install_path" || test -z "$ot_cv_openturns_cppflags" || test -z "$ot_cv_openturns_ldflags" || test -z "$ot_cv_openturns_libs" || test -z "$ot_cv_openturns_wrapper_cppflags" || test -z "$ot_cv_openturns_wrapper_ldflags" || test -z "$ot_cv_openturns_wrapper_libs"
 
62
    then
 
63
      # ask for Open TURNS support
 
64
      AC_MSG_NOTICE([checking whether Open TURNS library and headers are here and working])
 
65
 
 
66
      # we're trying to find the correct Open TURNS installation path
 
67
      openturns_install_path=$openturns_default_path
 
68
      test x${withval} = xyes || openturns_install_path=$withval
 
69
 
 
70
      AC_MSG_CHECKING([Open TURNS install path])
 
71
      test -d ${openturns_install_path} || AC_MSG_ERROR([$openturns_install_path: incorrect path])
 
72
      AC_MSG_RESULT([$openturns_install_path])
 
73
 
 
74
      AC_LANG_PUSH(C++)
 
75
      # we test the header file presence and usability
 
76
      openturns_cppflags="-I$openturns_install_path/include/openturns"
 
77
      CPPFLAGS="${CPPFLAGS} ${openturns_cppflags}"
 
78
      AC_CHECK_HEADER([OT.hxx],
 
79
                      [openturns_header_found=yes],
 
80
                      [openturns_header_found=no],
 
81
                      [])
 
82
      test x${openturns_header_found} = xno && AC_MSG_ERROR([Open TURNS include file NOT FOUND])
 
83
 
 
84
      # we test the library file presence and usability
 
85
      openturns_ldflags="-L$openturns_install_path/lib/openturns"
 
86
      openturns_libs="-lOT"
 
87
      LDFLAGS="${LDFLAGS} ${openturns_ldflags}"
 
88
      AC_CHECK_LIB([OT],
 
89
                   [openturns_library_ok],
 
90
                   [openturns_lib_found=yes],
 
91
                   [openturns_lib_found=no],
 
92
                   [])
 
93
      test x${openturns_lib_found} = xno && AC_MSG_ERROR([Open TURNS library NOT FOUND])
 
94
      AC_LANG_POP(C++)
 
95
 
 
96
      AC_LANG_PUSH(C)
 
97
      # we test the wrapper header file presence and usability
 
98
      openturns_wrapper_cppflags="-I$openturns_install_path/include/openturns"
 
99
      CPPFLAGS="${CPPFLAGS} ${openturns_wrapper_cppflags}"
 
100
      AC_CHECK_HEADER([WrapperCommon.h],
 
101
                      [openturns_wrapper_header_found=yes],
 
102
                      [openturns_wrapper_header_found=no],
 
103
                      [])
 
104
      test x${openturns_wrapper_header_found} = xno && AC_MSG_ERROR([Open TURNS wrapper include file NOT FOUND])
 
105
 
 
106
      openturns_wrapper_ldflags=
 
107
      openturns_wrapper_libs=
 
108
      AC_LANG_POP(C)
 
109
 
 
110
      # we look for the file wrapper.dtd to set its path
 
111
      for ot_dir in $openturns_install_path/share/openturns/wrappers
 
112
      do
 
113
        if test -f $ot_dir/wrapper.dtd
 
114
        then
 
115
          openturns_wrapper_dtd_path=$ot_dir
 
116
          break
 
117
        fi
 
118
      done
 
119
 
 
120
      # We write the values into the cache file
 
121
      OT_SET_OPENTURNS_CACHE_VALUES
 
122
    fi
 
123
 
 
124
    # we reset the values of Open TURNS flags from the cached values
 
125
    OPENTURNS_INSTALL_PATH=$ot_cv_openturns_install_path
 
126
    AC_SUBST(OPENTURNS_INSTALL_PATH)
 
127
 
 
128
    OPENTURNS_CPPFLAGS=$ot_cv_openturns_cppflags
 
129
    OPENTURNS_LDFLAGS=$ot_cv_openturns_ldflags
 
130
    OPENTURNS_LIBS=$ot_cv_openturns_libs
 
131
    AC_SUBST(OPENTURNS_CPPFLAGS)
 
132
    AC_SUBST(OPENTURNS_LDFLAGS)
 
133
    AC_SUBST(OPENTURNS_LIBS)
 
134
 
 
135
    OPENTURNS_WRAPPER_CPPFLAGS=$ot_cv_openturns_wrapper_cppflags
 
136
    OPENTURNS_WRAPPER_LDFLAGS=$ot_cv_openturns_wrapper_ldflags
 
137
    OPENTURNS_WRAPPER_LIBS=$ot_cv_openturns_wrapper_libs
 
138
    AC_SUBST(OPENTURNS_WRAPPER_CPPFLAGS)
 
139
    AC_SUBST(OPENTURNS_WRAPPER_LDFLAGS)
 
140
    AC_SUBST(OPENTURNS_WRAPPER_LIBS)
 
141
 
 
142
    OPENTURNS_WRAPPER_DTD_PATH=$ot_cv_openturns_wrapper_dtd_path
 
143
    AC_SUBST(OPENTURNS_WRAPPER_DTD_PATH)
 
144
 
 
145
    # after all tests are successful, we support Open TURNS
 
146
    WITH_OPENTURNS=1
 
147
    AC_MSG_NOTICE([Open TURNS support is OK])
 
148
 
 
149
  else
 
150
    # no Open TURNS support
 
151
    AC_MSG_NOTICE([No Open TURNS support])
 
152
  fi
 
153
 
 
154
  # Propagate test into Makefiles
 
155
  AM_CONDITIONAL(WITH_OPENTURNS, test $WITH_OPENTURNS = 1)
 
156
 
 
157
  # restoring saved values
 
158
  CPPFLAGS=$saved_CPPFLAGS
 
159
  LDFLAGS=$saved_LDFLAGS
 
160
  LIBS=$saved_LIBS
 
161
 
 
162
])
 
163
 
 
164
# OT_SET_OPENTURNS_CACHE_VALUES
 
165
# ------------------------------
 
166
#
 
167
AC_DEFUN([OT_SET_OPENTURNS_CACHE_VALUES],
 
168
[
 
169
  AC_CACHE_CHECK([for Open TURNS install path],  [ot_cv_openturns_install_path], [ot_cv_openturns_install_path=$openturns_install_path])
 
170
  AC_CACHE_CHECK([for Open TURNS include flags], [ot_cv_openturns_cppflags], [ot_cv_openturns_cppflags=$openturns_cppflags])
 
171
  AC_CACHE_CHECK([for Open TURNS library flags], [ot_cv_openturns_ldflags],  [ot_cv_openturns_ldflags=$openturns_ldflags])
 
172
  AC_CACHE_CHECK([for Open TURNS libraries],     [ot_cv_openturns_libs],     [ot_cv_openturns_libs=$openturns_libs])
 
173
 
 
174
  AC_CACHE_CHECK([for Open TURNS wrapper include flags], [ot_cv_openturns_wrapper_cppflags], [ot_cv_openturns_wrapper_cppflags=$openturns_wrapper_cppflags])
 
175
  AC_CACHE_CHECK([for Open TURNS wrapper library flags], [ot_cv_openturns_wrapper_ldflags],  [ot_cv_openturns_wrapper_ldflags=$openturns_wrapper_ldflags])
 
176
  AC_CACHE_CHECK([for Open TURNS wrapper library],       [ot_cv_openturns_wrapper_libs],     [ot_cv_openturns_wrapper_libs=$openturns_wrapper_libs])
 
177
 
 
178
  AC_CACHE_CHECK([for Open TURNS wrapper DTD path],      [ot_cv_openturns_wrapper_dtd_path], [ot_cv_openturns_wrapper_dtd_path=$openturns_wrapper_dtd_path])
 
179
 
 
180
])