1dnl -*- shell-script -*-
2dnl
3dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4dnl                         University Research and Technology
5dnl                         Corporation.  All rights reserved.
6dnl Copyright (c) 2004-2005 The University of Tennessee and The University
7dnl                         of Tennessee Research Foundation.  All rights
8dnl                         reserved.
9dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10dnl                         University of Stuttgart.  All rights reserved.
11dnl Copyright (c) 2004-2006 The Regents of the University of California.
12dnl                         All rights reserved.
13dnl Copyright (c) 2009      Cisco Systems, Inc.  All rights reserved.
14dnl Copyright (c) 2008-2012 University of Houston. All rights reserved.
15dnl Copyright (c) 2015      Research Organization for Information Science
16dnl                         and Technology (RIST). All rights reserved.
17dnl $COPYRIGHT$
18dnl
19dnl Additional copyrights may follow
20dnl
21dnl $HEADER$
22dnl
23
24# OMPI_CHECK_PLFS(prefix, [action-if-found], [action-if-not-found])
25# --------------------------------------------------------
26# check if PLFS support can be found.  sets prefix_{CPPFLAGS,
27# LDFLAGS, LIBS} as needed and runs action-if-found if there is
28# support, otherwise executes action-if-not-found
29AC_DEFUN([OMPI_CHECK_PLFS],[
30
31    check_plfs_CPPFLAGS=
32    check_plfs_LDFLAGS=
33    check_plfs_LIBS=
34
35    check_plfs_save_LIBS="$LIBS"
36    check_plfs_save_LDFLAGS="$LDFLAGS"
37    check_plfs_save_CPPFLAGS="$CPPFLAGS"
38
39    check_plfs_configuration="none"
40    ompi_check_plfs_happy="yes"
41
42
43    # Get some configuration information
44    AC_ARG_WITH([plfs],
45        [AC_HELP_STRING([--with-plfs(=DIR)],
46             [Build Plfs support, optionally adding DIR/include, DIR/lib, and DIR/lib64 to the search path for headers and libraries])])
47    OPAL_CHECK_WITHDIR([plfs], [$with_plfs], [include/plfs.h])
48
49    AC_ARG_WITH([plfs-libs],
50        [AC_HELP_STRING([--with-plfs-libs=LIBS],
51                       [Libraries to link with for plfs])])
52
53    temp_with_plfs="$with_plfs"
54    AS_IF([test -z "$with_plfs"],
55          [with_plfs="/usr/local"])
56
57    temp_with_plfs_libs="$with_plfs_libs"
58    AS_IF([test -z "$with_plfs_libs"],
59	[with_plfs_libs="plfs pthread"])
60
61    # Add correct -I and -L flags
62    AS_IF([test -d "$with_plfs/include"],
63        [check_plfs_CPPFLAGS="-I$with_plfs/include"
64            $1_CPPFLAGS="$check_plfs_CPPFLAGS"
65            CPPFLAGS="$CPPFLAGS $check_plfs_CPPFLAGS"],
66	[ompi_check_plfs_happy="no"])
67
68    AS_IF([test "$ompi_check_plfs_happy" = "yes"],
69	[AS_IF([test -d "$with_plfs/lib"],
70		[check_plfs_LDFLAGS="-L$with_plfs/lib"
71		    $1_LDFLAGS="$check_plfs_LDFLAGS"
72		    LDFLAGS="$LDFLAGS $check_plfs_LDFLAGS"],
73		[ompi_check_plfs_happy="no"])
74    ],[])
75
76    # Try to find all the plfs libraries
77    AS_IF([test "$ompi_check_plfs_happy" = "yes"],
78	[ AS_IF([test -n "$with_plfs_libs"]
79		[for lib in $with_plfs_libs ; do
80		    check_plfs_LIBS="$check_plfs_LIBS -l$lib"
81		    done])
82
83	    $1_LIBS="$check_plfs_LIBS"
84	    LIBS="$LIBS $check_plfs_LIBS"
85
86            # check for plfs
87	    AC_CHECK_HEADERS([plfs.h],
88		[AC_MSG_CHECKING([if possible to link PLFS])
89		    AC_LINK_IFELSE(
90			[AC_LANG_PROGRAM(
91				[[#include <plfs.h>]],
92				[[is_plfs_path(NULL);]])],
93			[AC_MSG_RESULT([yes])
94			    ompi_check_plfs_happy="yes"],
95			[AC_MSG_RESULT([no])
96			    ompi_check_plfs_happy="no"])],
97		[ompi_check_plfs_happy="no"])
98    ])
99
100
101    LDFLAGS="$check_plfs_save_LDFLAGS"
102    CPPFLAGS="$check_plfs_save_CPPFLAGS"
103    LIBS="$check_plfs_save_LIBS"
104    AS_IF([test "$ompi_check_plfs_happy" = "yes"],
105          [$2],
106          [AS_IF([test ! -z "$with_plfs" && test "$with_plfs" != "no"],
107                  [echo PLFS support not found])
108              $3])
109
110    with_plfs="$temp_with_plfs"
111    with_plfs_libs="$temp_with_plfs_libs"
112
113])
114
115