1dnl -------------------------------------------------------------
2dnl tecio
3dnl -------------------------------------------------------------
4AC_DEFUN([CONFIGURE_TECIO],
5[
6  AC_ARG_ENABLE(tecio,
7                AS_HELP_STRING([--disable-tecio],
8                               [build without Tecplot TecIO API support (from source)]),
9                [AS_CASE("${enableval}",
10                         [yes], [enabletecio=yes],
11                         [no],  [enabletecio=no],
12                         [AC_MSG_ERROR(bad value ${enableval} for --enable-tecio)])],
13                [enabletecio=$enableoptional])
14
15  AC_ARG_WITH(tecio-x11-include,
16              AS_HELP_STRING([--with-tecio-x11-include=PATH],
17                             [Path to X11 header files. E.g. /usr/include but _not_ /usr/include/X11]),
18              withteciox11inc=$withval,
19              withteciox11inc=no)
20
21  dnl Start off with an empty TECIO_CPPFLAGS and possibly append to it.
22  TECIO_CPPFLAGS=""
23
24  dnl Look for an X11 installation
25  AS_IF([test "x$enabletecio" = "xyes"],
26        [
27          dnl If the user specified a path to look for X11 headers in, honor
28          dnl that and don't try to look elsewhere.  If the compilation fails
29          dnl then they must figure out why on their own.
30          AS_IF([test "x$withteciox11inc" != "xno"], [TECIO_CPPFLAGS="-I$withteciox11inc"])
31
32          dnl Print a status message
33          AS_IF([test "x$TECIO_CPPFLAGS" != "x"],
34                [AC_MSG_RESULT(<<< Testing X11 headers with $TECIO_CPPFLAGS >>>)])
35
36          dnl Run AC_CHECK_HEADER to see if we can actually compile a test
37          dnl program with the TECIO_CPPFLAGS we determined.  If this doesn't
38          dnl work, we assume the X11 installation is not working and disable
39          dnl the tecio interface.
40          saved_CPPFLAGS=$CPPFLAGS
41          CPPFLAGS="$TECIO_CPPFLAGS $CPPFLAGS"
42
43          AC_CHECK_HEADER([X11/Intrinsic.h],
44                          [],
45                          [enabletecio=no])
46
47          dnl Restore original value of CPPFLAGS
48          CPPFLAGS=$saved_CPPFLAGS
49        ])
50
51  dnl The TECIO API is distributed with libmesh, so we don't have to guess
52  dnl where it might be installed...
53  AS_IF([test "x$enabletecio" = "xyes"],
54        [
55          dnl Set tecio platform-specific compiler flags.
56          AS_CASE("${host_os}",
57                  [*linux*], [TECIO_CPPFLAGS="-DLINUX $TECIO_CPPFLAGS"
58                              AC_CHECK_SIZEOF([void *])
59                              AS_IF([test "x$ac_cv_sizeof_void_p" = "x8"], [TECIO_CPPFLAGS="-DLINUX64 $TECIO_CPPFLAGS"])],
60                  [*darwin*], [TECIO_CPPFLAGS="-DDARWIN -DLONGIS64 $TECIO_CPPFLAGS"],
61                  [AC_MSG_RESULT([>>> Unrecognized TecIO platform, see contrib/tecplot/tecio/Runmake for hints on how to extend <<<])])
62
63           TECIO_INCLUDE="-I\$(top_srcdir)/contrib/tecplot/tecio/include"
64           AC_DEFINE(HAVE_TECPLOT_API, 1, [Flag indicating whether the library will be compiled with Tecplot TecIO API support])
65           AC_DEFINE(HAVE_TECPLOT_API_112, 1, [Flag indicating tecplot API understands newer features])
66           AC_MSG_RESULT(<<< Configuring library with Tecplot TecIO support >>>)
67           have_tecio=yes
68        ],
69        [
70          TECIO_INCLUDE=""
71          enabletecio=no
72          have_tecio=no
73        ])
74
75  AC_SUBST(TECIO_INCLUDE)
76  AC_SUBST(TECIO_CPPFLAGS)
77])
78