1dnl -*- shell-script -*-
2dnl
3dnl Copyright (c) 2004-2010 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-2005 The Regents of the University of California.
12dnl                         All rights reserved.
13dnl Copyright (c) 2006-2016 Cisco Systems, Inc.  All rights reserved.
14dnl Copyright (c) 2007      Sun Microsystems, Inc.  All rights reserved.
15dnl Copyright (c) 2009-2018 IBM Corporation.  All rights reserved.
16dnl Copyright (c) 2009      Los Alamos National Security, LLC.  All rights
17dnl                         reserved.
18dnl Copyright (c) 2009-2011 Oak Ridge National Labs.  All rights reserved.
19dnl Copyright (c) 2011-2013 NVIDIA Corporation.  All rights reserved.
20dnl Copyright (c) 2013-2020 Intel, Inc.  All rights reserved.
21dnl Copyright (c) 2015-2019 Research Organization for Information Science
22dnl                         and Technology (RIST).  All rights reserved.
23dnl Copyright (c) 2016      Mellanox Technologies, Inc.
24dnl                         All rights reserved.
25dnl
26dnl Copyright (c) 2021      Nanook Consulting.  All rights reserved.
27dnl $COPYRIGHT$
28dnl
29dnl Additional copyrights may follow
30dnl
31dnl $HEADER$
32dnl
33
34AC_DEFUN([PMIX_SETUP_CORE],[
35
36    AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
37    AC_REQUIRE([AC_CANONICAL_TARGET])
38
39    # AM_PROG_CC_C_O AC_REQUIREs AC_PROG_CC, so we have to be a little
40    # careful about ordering here, and AC_REQUIRE these things so that
41    # they get stamped out in the right order.
42    AC_REQUIRE([_PMIX_START_SETUP_CC])
43    AC_REQUIRE([_PMIX_PROG_CC])
44    AC_REQUIRE([AM_PROG_CC_C_O])
45
46
47    # initialize
48    PMIX_EMBEDDED_LDFLAGS=
49    PMIX_EMBEDDED_LIBS=
50    PMIX_EMBEDDED_CPPFLAGS=
51
52    # If no prefix was defined, set a good value
53    m4_ifval([$1],
54             [m4_define([pmix_config_prefix],[$1/])],
55             [m4_define([pmix_config_prefix], [])])
56
57    # Get pmix's absolute top builddir (which may not be the same as
58    # the real $top_builddir)
59    PMIX_startdir=`pwd`
60    if test x"pmix_config_prefix" != "x" && test ! -d "pmix_config_prefix"; then
61        mkdir -p "pmix_config_prefix"
62    fi
63    if test x"pmix_config_prefix" != "x"; then
64        cd "pmix_config_prefix"
65    fi
66    PMIX_top_builddir=`pwd`
67    AC_SUBST(PMIX_top_builddir)
68
69    # Get pmix's absolute top srcdir (which may not be the same as the
70    # real $top_srcdir.  First, go back to the startdir incase the
71    # $srcdir is relative.
72
73    cd "$PMIX_startdir"
74    cd "$srcdir"/pmix_config_prefix
75    PMIX_top_srcdir="`pwd`"
76    AC_SUBST(PMIX_top_srcdir)
77
78    # Go back to where we started
79    cd "$PMIX_startdir"
80
81    AC_MSG_NOTICE([pmix builddir: $PMIX_top_builddir])
82    AC_MSG_NOTICE([pmix srcdir: $PMIX_top_srcdir])
83    if test "$PMIX_top_builddir" != "$PMIX_top_srcdir"; then
84        AC_MSG_NOTICE([Detected VPATH build])
85    fi
86
87    # Get the version of pmix that we are installing
88    AC_MSG_CHECKING([for pmix version])
89    PMIX_VERSION="`$PMIX_top_srcdir/config/pmix_get_version.sh $PMIX_top_srcdir/VERSION`"
90    if test "$?" != "0"; then
91        AC_MSG_ERROR([Cannot continue])
92    fi
93    AC_MSG_RESULT([$PMIX_VERSION])
94    AC_SUBST(PMIX_VERSION)
95    AC_DEFINE_UNQUOTED([PMIX_VERSION], ["$PMIX_VERSION"],
96                       [The library version is always available, contrary to VERSION])
97
98    PMIX_RELEASE_DATE="`$PMIX_top_srcdir/config/pmix_get_version.sh $PMIX_top_srcdir/VERSION --release-date`"
99    AC_SUBST(PMIX_RELEASE_DATE)
100
101    # Save the breakdown the version information
102    PMIX_MAJOR_VERSION="`$PMIX_top_srcdir/config/pmix_get_version.sh $PMIX_top_srcdir/VERSION --major`"
103    if test "$?" != "0"; then
104        AC_MSG_ERROR([Cannot continue])
105    fi
106    AC_SUBST(PMIX_MAJOR_VERSION)
107    AC_DEFINE_UNQUOTED([PMIX_MAJOR_VERSION], [$PMIX_MAJOR_VERSION],
108                       [The library major version is always available, contrary to VERSION])
109
110    PMIX_MINOR_VERSION="`$PMIX_top_srcdir/config/pmix_get_version.sh $PMIX_top_srcdir/VERSION --minor`"
111    if test "$?" != "0"; then
112        AC_MSG_ERROR([Cannot continue])
113    fi
114    AC_SUBST(PMIX_MINOR_VERSION)
115    AC_DEFINE_UNQUOTED([PMIX_MINOR_VERSION], [$PMIX_MINOR_VERSION],
116                       [The library minor version is always available, contrary to VERSION])
117
118    PMIX_RELEASE_VERSION="`$PMIX_top_srcdir/config/pmix_get_version.sh $PMIX_top_srcdir/VERSION --release`"
119    if test "$?" != "0"; then
120        AC_MSG_ERROR([Cannot continue])
121    fi
122    AC_SUBST(PMIX_RELEASE_VERSION)
123    AC_DEFINE_UNQUOTED([PMIX_RELEASE_VERSION], [$PMIX_RELEASE_VERSION],
124                       [The library release version is always available, contrary to VERSION])
125
126    pmixmajor=${PMIX_MAJOR_VERSION}L
127    pmixminor=${PMIX_MINOR_VERSION}L
128    pmixrelease=${PMIX_RELEASE_VERSION}L
129    pmixnumeric=$(printf 0x%4.4x%2.2x%2.2x $PMIX_MAJOR_VERSION $PMIX_MINOR_VERSION $PMIX_RELEASE_VERSION)
130    AC_SUBST(pmixmajor)
131    AC_SUBST(pmixminor)
132    AC_SUBST(pmixrelease)
133    AC_SUBST(pmixnumeric)
134    AC_CONFIG_FILES(pmix_config_prefix[include/pmix_version.h])
135
136    PMIX_GREEK_VERSION="`$PMIX_top_srcdir/config/pmix_get_version.sh $PMIX_top_srcdir/VERSION --greek`"
137    if test "$?" != "0"; then
138        AC_MSG_ERROR([Cannot continue])
139    fi
140    AC_SUBST(PMIX_GREEK_VERSION)
141
142    PMIX_REPO_REV="`$PMIX_top_srcdir/config/pmix_get_version.sh $PMIX_top_srcdir/VERSION --repo-rev`"
143    if test "$?" != "0"; then
144        AC_MSG_ERROR([Cannot continue])
145    fi
146    AC_SUBST(PMIX_REPO_REV)
147
148    PMIX_RELEASE_DATE="`$PMIX_top_srcdir/config/pmix_get_version.sh $PMIX_top_srcdir/VERSION --release-date`"
149    if test "$?" != "0"; then
150        AC_MSG_ERROR([Cannot continue])
151    fi
152    AC_SUBST(PMIX_RELEASE_DATE)
153
154    # Debug mode?
155    AC_MSG_CHECKING([if want pmix maintainer support])
156    pmix_debug=
157    AS_IF([test "$pmix_debug" = "" && test "$enable_debug" = "yes"],
158          [pmix_debug=1
159           pmix_debug_msg="enabled"])
160    AS_IF([test "$pmix_debug" = ""],
161          [pmix_debug=0
162           pmix_debug_msg="disabled"])
163    # Grr; we use #ifndef for PMIX_DEBUG!  :-(
164    AH_TEMPLATE(PMIX_ENABLE_DEBUG, [Whether we are in debugging mode or not])
165    AS_IF([test "$pmix_debug" = "1"], [AC_DEFINE([PMIX_ENABLE_DEBUG])])
166    AC_MSG_RESULT([$pmix_debug_msg])
167
168    AC_MSG_CHECKING([for pmix directory prefix])
169    AC_MSG_RESULT(m4_ifval([$1], pmix_config_prefix, [(none)]))
170
171    # Note that private/config.h *MUST* be listed first so that it
172    # becomes the "main" config header file.  Any AC-CONFIG-HEADERS
173    # after that (pmix/config.h) will only have selective #defines
174    # replaced, not the entire file.
175    AC_CONFIG_HEADERS(pmix_config_prefix[src/include/pmix_config.h])
176
177
178    # Add any extra lib?
179    AC_ARG_WITH([pmix-extra-lib],
180                AC_HELP_STRING([--with-pmix-extra-lib=LIB],
181                               [Link the output PMIx library to this extra lib (used in embedded mode)]))
182    AC_MSG_CHECKING([for extra lib])
183    AS_IF([test ! -z "$with_pmix_extra_lib"],
184          [AS_IF([test "$with_pmix_extra_lib" = "yes" || test "$with_pmix_extra_lib" = "no"],
185                 [AC_MSG_RESULT([ERROR])
186                  AC_MSG_WARN([Invalid value for --with-extra-pmix-lib:])
187                  AC_MSG_WARN([    $with_pmix_extra_lib])
188                  AC_MSG_WARN([Must be path name of the library to add])
189                  AC_MSG_ERROR([Cannot continue])],
190                 [AC_MSG_RESULT([$with_pmix_extra_lib])
191                  PMIX_EXTRA_LIB=$with_pmix_extra_lib])],
192          [AC_MSG_RESULT([no])
193           PMIX_EXTRA_LIB=])
194    AC_SUBST(PMIX_EXTRA_LIB)
195
196    # Add any extra libtool lib?
197    AC_ARG_WITH([pmix-extra-ltlib],
198                AC_HELP_STRING([--with-pmix-extra-ltlib=LIB],
199                               [Link any embedded components/tools that require it to the provided libtool lib (used in embedded mode)]))
200    AC_MSG_CHECKING([for extra ltlib])
201    AS_IF([test ! -z "$with_pmix_extra_ltlib"],
202          [AS_IF([test "$with_pmix_extra_ltlib" = "yes" || test "$with_pmix_extra_ltlib" = "no"],
203                 [AC_MSG_RESULT([ERROR])
204                  AC_MSG_WARN([Invalid value for --with-pmix-extra-ltlib:])
205                  AC_MSG_WARN([    $with_pmix_extra_ltlib])
206                  AC_MSG_WARN([Must be path name of the library to add])
207                  AC_MSG_ERROR([Cannot continue])],
208                 [AC_MSG_RESULT([$with_pmix_extra_ltlib])
209                  PMIX_EXTRA_LTLIB=$with_pmix_extra_ltlib])],
210          [AC_MSG_RESULT([no])
211           PMIX_EXTRA_LTLIB=])
212    AC_SUBST(PMIX_EXTRA_LTLIB)
213
214    #
215    # Package/brand string
216    #
217    AC_MSG_CHECKING([if want package/brand string])
218    AC_ARG_WITH([pmix-package-string],
219         [AC_HELP_STRING([--with-pmix-package-string=STRING],
220                         [Use a branding string throughout PMIx])])
221    if test "$with_pmix_package_string" = "" || test "$with_pmix_package_string" = "no"; then
222        with_package_string="PMIx $PMIX_CONFIGURE_USER@$PMIX_CONFIGURE_HOST Distribution"
223    fi
224    AC_DEFINE_UNQUOTED([PMIX_PACKAGE_STRING], ["$with_package_string"],
225         [package/branding string for PMIx])
226    AC_MSG_RESULT([$with_package_string])
227
228
229    # GCC specifics.
230    if test "x$GCC" = "xyes"; then
231        PMIX_GCC_CFLAGS="-Wall -Wmissing-prototypes -Wundef"
232        PMIX_GCC_CFLAGS="$PMIX_GCC_CFLAGS -Wpointer-arith -Wcast-align"
233    fi
234
235    ############################################################################
236    # Check for compilers and preprocessors
237    ############################################################################
238    pmix_show_title "Compiler and preprocessor tests"
239
240    PMIX_SETUP_CC
241
242    #
243    # Check for some types
244    #
245
246    AC_CHECK_TYPES(int8_t)
247    AC_CHECK_TYPES(uint8_t)
248    AC_CHECK_TYPES(int16_t)
249    AC_CHECK_TYPES(uint16_t)
250    AC_CHECK_TYPES(int32_t)
251    AC_CHECK_TYPES(uint32_t)
252    AC_CHECK_TYPES(int64_t)
253    AC_CHECK_TYPES(uint64_t)
254    AC_CHECK_TYPES(__int128)
255    AC_CHECK_TYPES(uint128_t)
256    AC_CHECK_TYPES(long long)
257
258    AC_CHECK_TYPES(intptr_t)
259    AC_CHECK_TYPES(uintptr_t)
260    AC_CHECK_TYPES(ptrdiff_t)
261
262    #
263    # Check for type sizes
264    #
265
266    AC_CHECK_SIZEOF(_Bool)
267    AC_CHECK_SIZEOF(char)
268    AC_CHECK_SIZEOF(short)
269    AC_CHECK_SIZEOF(int)
270    AC_CHECK_SIZEOF(long)
271    if test "$ac_cv_type_long_long" = yes; then
272        AC_CHECK_SIZEOF(long long)
273    fi
274    AC_CHECK_SIZEOF(float)
275    AC_CHECK_SIZEOF(double)
276
277    AC_CHECK_SIZEOF(void *)
278    AC_CHECK_SIZEOF(size_t)
279    if test "$ac_cv_type_ssize_t" = yes ; then
280        AC_CHECK_SIZEOF(ssize_t)
281    fi
282    if test "$ac_cv_type_ptrdiff_t" = yes; then
283        AC_CHECK_SIZEOF(ptrdiff_t)
284    fi
285    AC_CHECK_SIZEOF(wchar_t)
286
287    AC_CHECK_SIZEOF(pid_t)
288
289    #
290    # Check for type alignments
291    #
292
293    PMIX_C_GET_ALIGNMENT(bool, PMIX_ALIGNMENT_BOOL)
294    PMIX_C_GET_ALIGNMENT(int8_t, PMIX_ALIGNMENT_INT8)
295    PMIX_C_GET_ALIGNMENT(int16_t, PMIX_ALIGNMENT_INT16)
296    PMIX_C_GET_ALIGNMENT(int32_t, PMIX_ALIGNMENT_INT32)
297    PMIX_C_GET_ALIGNMENT(int64_t, PMIX_ALIGNMENT_INT64)
298    PMIX_C_GET_ALIGNMENT(char, PMIX_ALIGNMENT_CHAR)
299    PMIX_C_GET_ALIGNMENT(short, PMIX_ALIGNMENT_SHORT)
300    PMIX_C_GET_ALIGNMENT(wchar_t, PMIX_ALIGNMENT_WCHAR)
301    PMIX_C_GET_ALIGNMENT(int, PMIX_ALIGNMENT_INT)
302    PMIX_C_GET_ALIGNMENT(long, PMIX_ALIGNMENT_LONG)
303    if test "$ac_cv_type_long_long" = yes; then
304        PMIX_C_GET_ALIGNMENT(long long, PMIX_ALIGNMENT_LONG_LONG)
305    fi
306    PMIX_C_GET_ALIGNMENT(float, PMIX_ALIGNMENT_FLOAT)
307    PMIX_C_GET_ALIGNMENT(double, PMIX_ALIGNMENT_DOUBLE)
308    if test "$ac_cv_type_long_double" = yes; then
309        PMIX_C_GET_ALIGNMENT(long double, PMIX_ALIGNMENT_LONG_DOUBLE)
310    fi
311    PMIX_C_GET_ALIGNMENT(void *, PMIX_ALIGNMENT_VOID_P)
312    PMIX_C_GET_ALIGNMENT(size_t, PMIX_ALIGNMENT_SIZE_T)
313
314
315    #
316    # Does the C compiler native support "bool"? (i.e., without
317    # <stdbool.h> or any other help)
318    #
319
320    PMIX_VAR_SCOPE_PUSH([MSG])
321    AC_MSG_CHECKING(for C bool type)
322    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
323                                          AC_INCLUDES_DEFAULT],
324                                       [[bool bar, foo = true; bar = foo;]])],
325                      [PMIX_NEED_C_BOOL=0 MSG=yes],[PMIX_NEED_C_BOOL=1 MSG=no])
326    AC_DEFINE_UNQUOTED(PMIX_NEED_C_BOOL, $PMIX_NEED_C_BOOL,
327                       [Whether the C compiler supports "bool" without any other help (such as <stdbool.h>)])
328    AC_MSG_RESULT([$MSG])
329    AC_CHECK_SIZEOF(_Bool)
330    PMIX_VAR_SCOPE_POP
331
332    #
333    # Check for other compiler characteristics
334    #
335
336    PMIX_VAR_SCOPE_PUSH([PMIX_CFLAGS_save])
337    if test "$GCC" = "yes"; then
338
339        # gcc 2.96 will emit oodles of warnings if you use "inline" with
340        # -pedantic (which we do in developer builds).  However,
341        # "__inline__" is ok.  So we have to force gcc to select the
342        # right one.  If you use -pedantic, the AC_C_INLINE test will fail
343        # (because it names a function foo() -- without the (void)).  So
344        # we turn off all the picky flags, turn on -ansi mode (which is
345        # implied by -pedantic), and set warnings to be errors.  Hence,
346        # this does the following (for 2.96):
347        #
348        # - causes the check for "inline" to emit a warning, which then
349        # fails
350        # - checks for __inline__, which then emits no error, and works
351        #
352        # This also works nicely for gcc 3.x because "inline" will work on
353        # the first check, and all is fine.  :-)
354
355        PMIX_CFLAGS_save=$CFLAGS
356        CFLAGS="$PMIX_CFLAGS_BEFORE_PICKY -Werror -ansi"
357    fi
358    AC_C_INLINE
359    if test "$GCC" = "yes"; then
360        CFLAGS=$PMIX_CFLAGS_save
361    fi
362    PMIX_VAR_SCOPE_POP
363
364    if test "x$CC" = "xicc"; then
365        PMIX_CHECK_ICC_VARARGS
366    fi
367
368
369    ##################################
370    # Only after setting up
371    # C do we check compiler attributes.
372    ##################################
373
374    pmix_show_subtitle "Compiler characteristics"
375
376    PMIX_CHECK_ATTRIBUTES
377    PMIX_CHECK_COMPILER_VERSION_ID
378
379    ##################################
380    # Assembler Configuration
381    ##################################
382
383    pmix_show_subtitle "Assembler"
384
385    AM_PROG_AS
386    AC_PATH_PROG(PERL, perl, perl)
387    PMIX_CONFIG_ASM
388
389
390    ##################################
391    # Header files
392    ##################################
393
394    pmix_show_title "Header file tests"
395
396    AC_CHECK_HEADERS([arpa/inet.h \
397                      fcntl.h ifaddrs.h inttypes.h libgen.h \
398                      net/uio.h netinet/in.h \
399                      stdint.h stddef.h \
400                      stdlib.h string.h strings.h \
401                      sys/ioctl.h sys/param.h \
402                      sys/select.h sys/socket.h sys/sockio.h \
403                      stdarg.h sys/stat.h sys/time.h \
404                      sys/types.h sys/un.h sys/uio.h \
405                      sys/wait.h syslog.h \
406                      time.h unistd.h dirent.h \
407                      crt_externs.h signal.h \
408                      ioLib.h sockLib.h hostLib.h limits.h \
409                      sys/fcntl.h sys/statfs.h sys/statvfs.h \
410                      netdb.h ucred.h zlib.h sys/auxv.h \
411                      sys/sysctl.h termio.h termios.h pty.h \
412                      libutil.h util.h grp.h sys/cdefs.h utmp.h stropts.h \
413                      sys/utsname.h])
414
415    AC_CHECK_HEADERS([sys/mount.h], [], [],
416                     [AC_INCLUDES_DEFAULT
417                      #if HAVE_SYS_PARAM_H
418                      #include <sys/param.h>
419                      #endif
420                      ])
421
422    AC_CHECK_HEADERS([sys/sysctl.h], [], [],
423                     [AC_INCLUDES_DEFAULT
424                      #if HAVE_SYS_PARAM_H
425                      #include <sys/param.h>
426                      #endif
427                      ])
428
429    # Needed to work around Darwin requiring sys/socket.h for
430    # net/if.h
431    AC_CHECK_HEADERS([net/if.h], [], [],
432                     [#include <stdio.h>
433                      #if STDC_HEADERS
434                      # include <stdlib.h>
435                      # include <stddef.h>
436                      #else
437                      # if HAVE_STDLIB_H
438                      #  include <stdlib.h>
439                      # endif
440                      #endif
441                      #if HAVE_SYS_SOCKET_H
442                      # include <sys/socket.h>
443                      #endif
444                      ])
445
446    # Note that sometimes we have <stdbool.h>, but it doesn't work (e.g.,
447    # have both Portland and GNU installed; using pgcc will find GNU's
448    # <stdbool.h>, which all it does -- by standard -- is define "bool" to
449    # "_Bool" [see
450    # http://pmixw.opengroup.org/onlinepubs/009695399/basedefs/stdbool.h.html],
451    # and Portland has no idea what to do with _Bool).
452
453    # So first figure out if we have <stdbool.h> (i.e., check the value of
454    # the macro HAVE_STDBOOL_H from the result of AC_CHECK_HEADERS,
455    # above).  If we do have it, then check to see if it actually works.
456    # Define PMIX_USE_STDBOOL_H as approrpaite.
457    AC_CHECK_HEADERS([stdbool.h], [have_stdbool_h=1], [have_stdbool_h=0])
458    AC_MSG_CHECKING([if <stdbool.h> works])
459    if test "$have_stdbool_h" = "1"; then
460        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT[
461                                                   #if HAVE_STDBOOL_H
462                                                   #include <stdbool.h>
463                                                   #endif
464                                               ]],
465                                           [[bool bar, foo = true; bar = foo;]])],
466                          [PMIX_USE_STDBOOL_H=1 MSG=yes],[PMIX_USE_STDBOOL_H=0 MSG=no])
467    else
468        PMIX_USE_STDBOOL_H=0
469        MSG="no (don't have <stdbool.h>)"
470    fi
471    AC_DEFINE_UNQUOTED(PMIX_USE_STDBOOL_H, $PMIX_USE_STDBOOL_H,
472                       [Whether to use <stdbool.h> or not])
473    AC_MSG_RESULT([$MSG])
474
475    # checkpoint results
476    AC_CACHE_SAVE
477
478    ##################################
479    # Types
480    ##################################
481
482    pmix_show_title "Type tests"
483
484    AC_CHECK_TYPES([socklen_t, struct sockaddr_in, struct sockaddr_un,
485                    struct sockaddr_in6, struct sockaddr_storage],
486                   [], [], [AC_INCLUDES_DEFAULT
487                            #if HAVE_SYS_SOCKET_H
488                            #include <sys/socket.h>
489                            #endif
490                            #if HAVE_SYS_UN_H
491                            #include <sys/un.h>
492                            #endif
493                            #ifdef HAVE_NETINET_IN_H
494                            #include <netinet/in.h>
495                            #endif
496                           ])
497
498    AC_CHECK_DECLS([AF_UNSPEC, PF_UNSPEC, AF_INET6, PF_INET6],
499                   [], [], [AC_INCLUDES_DEFAULT
500                            #if HAVE_SYS_SOCKET_H
501                            #include <sys/socket.h>
502                            #endif
503                            #ifdef HAVE_NETINET_IN_H
504                            #include <netinet/in.h>
505                            #endif
506                           ])
507
508    # SA_RESTART in signal.h
509    PMIX_VAR_SCOPE_PUSH([MSG2])
510    AC_MSG_CHECKING([if SA_RESTART defined in signal.h])
511                        AC_EGREP_CPP(yes, [
512                                            #include <signal.h>
513                                            #ifdef SA_RESTART
514                                            yes
515                                            #endif
516                                        ], [MSG2=yes VALUE=1], [MSG2=no VALUE=0])
517    AC_DEFINE_UNQUOTED(PMIX_HAVE_SA_RESTART, $VALUE,
518                       [Whether we have SA_RESTART in <signal.h> or not])
519    AC_MSG_RESULT([$MSG2])
520    PMIX_VAR_SCOPE_POP
521
522    AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [
523                         #include <sys/types.h>
524                         #if HAVE_SYS_SOCKET_H
525                         #include <sys/socket.h>
526                         #endif
527                     ])
528
529    AC_CHECK_MEMBERS([struct dirent.d_type], [], [], [
530                         #include <sys/types.h>
531                         #include <dirent.h>])
532
533    AC_CHECK_MEMBERS([siginfo_t.si_fd],,,[#include <signal.h>])
534    AC_CHECK_MEMBERS([siginfo_t.si_band],,,[#include <signal.h>])
535
536    #
537    # Checks for struct member names in struct statfs
538    #
539    AC_CHECK_MEMBERS([struct statfs.f_type], [], [], [
540                         AC_INCLUDES_DEFAULT
541                         #ifdef HAVE_SYS_VFS_H
542                         #include <sys/vfs.h>
543                         #endif
544                         #ifdef HAVE_SYS_STATFS_H
545                         #include <sys/statfs.h>
546                         #endif
547                     ])
548
549    AC_CHECK_MEMBERS([struct statfs.f_fstypename], [], [], [
550                         AC_INCLUDES_DEFAULT
551                         #ifdef HAVE_SYS_PARAM_H
552                         #include <sys/param.h>
553                         #endif
554                         #ifdef HAVE_SYS_MOUNT_H
555                         #include <sys/mount.h>
556                         #endif
557                         #ifdef HAVE_SYS_VFS_H
558                         #include <sys/vfs.h>
559                         #endif
560                         #ifdef HAVE_SYS_STATFS_H
561                         #include <sys/statfs.h>
562                         #endif
563                     ])
564
565    #
566    # Checks for struct member names in struct statvfs
567    #
568    AC_CHECK_MEMBERS([struct statvfs.f_basetype], [], [], [
569                         AC_INCLUDES_DEFAULT
570                         #ifdef HAVE_SYS_STATVFS_H
571                         #include <sys/statvfs.h>
572                         #endif
573                     ])
574
575    AC_CHECK_MEMBERS([struct statvfs.f_fstypename], [], [], [
576                         AC_INCLUDES_DEFAULT
577                         #ifdef HAVE_SYS_STATVFS_H
578                         #include <sys/statvfs.h>
579                         #endif
580                     ])
581
582    AC_CHECK_MEMBERS([struct ucred.uid, struct ucred.cr_uid, struct sockpeercred.uid],
583                     [], [],
584                     [#include <sys/types.h>
585                      #include <sys/socket.h> ])
586
587    #
588    # Check for ptrdiff type.  Yes, there are platforms where
589    # sizeof(void*) != sizeof(long) (64 bit Windows, apparently).
590    #
591    AC_MSG_CHECKING([for pointer diff type])
592    if test $ac_cv_type_ptrdiff_t = yes ; then
593        pmix_ptrdiff_t="ptrdiff_t"
594        pmix_ptrdiff_size=$ac_cv_sizeof_ptrdiff_t
595    elif test $ac_cv_sizeof_void_p -eq $ac_cv_sizeof_long ; then
596        pmix_ptrdiff_t="long"
597        pmix_ptrdiff_size=$ac_cv_sizeof_long
598    elif test $ac_cv_type_long_long = yes && test $ac_cv_sizeof_void_p -eq $ac_cv_sizeof_long_long ; then
599        pmix_ptrdiff_t="long long"
600        pmix_ptrdiff_size=$ac_cv_sizeof_long_long
601        #else
602        #    AC_MSG_ERROR([Could not find datatype to emulate ptrdiff_t.  Cannot continue])
603    fi
604    AC_DEFINE_UNQUOTED([PMIX_PTRDIFF_TYPE], [$pmix_ptrdiff_t],
605                       [type to use for ptrdiff_t])
606    AC_MSG_RESULT([$pmix_ptrdiff_t (size: $pmix_ptrdiff_size)])
607
608    ##################################
609    # Linker characteristics
610    ##################################
611
612    AC_MSG_CHECKING([the linker for support for the -fini option])
613    PMIX_VAR_SCOPE_PUSH([LDFLAGS_save])
614    LDFLAGS_save=$LDFLAGS
615    LDFLAGS="$LDFLAGS_save -Wl,-fini -Wl,finalize"
616    AC_TRY_LINK([void finalize (void) {}], [], [AC_MSG_RESULT([yes])
617            pmix_ld_have_fini=1], [AC_MSG_RESULT([no])
618            pmix_ld_have_fini=0])
619    LDFLAGS=$LDFLAGS_save
620    PMIX_VAR_SCOPE_POP
621
622    pmix_destructor_use_fini=0
623    pmix_no_destructor=0
624    if test x$pmix_cv___attribute__destructor = x0 ; then
625        if test x$pmix_ld_have_fini = x1 ; then
626            pmix_destructor_use_fini=1
627        else
628            pmix_no_destructor=1;
629        fi
630    fi
631
632    AC_DEFINE_UNQUOTED(PMIX_NO_LIB_DESTRUCTOR, [$pmix_no_destructor],
633        [Whether libraries can be configured with destructor functions])
634    AM_CONDITIONAL(PMIX_DESTRUCTOR_USE_FINI, [test x$pmix_destructor_use_fini = x1])
635
636    ##################################
637    # Libraries
638    ##################################
639
640    pmix_show_title "Library and Function tests"
641
642    # Darwin doesn't need -lutil, as it's something other than this -lutil.
643    PMIX_SEARCH_LIBS_CORE([openpty], [util])
644
645    PMIX_SEARCH_LIBS_CORE([gethostbyname], [nsl])
646
647    PMIX_SEARCH_LIBS_CORE([socket], [socket])
648
649    # IRIX and CentOS have dirname in -lgen, usually in libc
650    PMIX_SEARCH_LIBS_CORE([dirname], [gen])
651
652    # Darwin doesn't need -lm, as it's a symlink to libSystem.dylib
653    PMIX_SEARCH_LIBS_CORE([ceil], [m])
654
655    # -lrt might be needed for clock_gettime
656    PMIX_SEARCH_LIBS_CORE([clock_gettime], [rt])
657
658    AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf strsignal socketpair strncpy_s usleep statfs statvfs getpeereid getpeerucred strnlen posix_fallocate tcgetpgrp setpgid ptsname openpty setenv fork execve waitpid])
659
660    # On some hosts, htonl is a define, so the AC_CHECK_FUNC will get
661    # confused.  On others, it's in the standard library, but stubbed with
662    # the magic glibc foo as not implemented.  and on other systems, it's
663    # just not there.  This covers all cases.
664    AC_CACHE_CHECK([for htonl define],
665                   [pmix_cv_htonl_define],
666                   [AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
667                                                          #ifdef HAVE_SYS_TYPES_H
668                                                          #include <sys/types.h>
669                                                          #endif
670                                                          #ifdef HAVE_NETINET_IN_H
671                                                          #include <netinet/in.h>
672                                                          #endif
673                                                          #ifdef HAVE_ARPA_INET_H
674                                                          #include <arpa/inet.h>
675                                                          #endif],[
676                                                          #ifndef ntohl
677                                                          #error "ntohl not defined"
678                                                          #endif
679                                                      ])], [pmix_cv_htonl_define=yes], [pmix_cv_htonl_define=no])])
680    AC_CHECK_FUNC([htonl], [pmix_have_htonl=yes], [pmix_have_htonl=no])
681    AS_IF([test "$pmix_cv_htonl_define" = "yes" || test "$pmix_have_htonl" = "yes"],
682          [AC_DEFINE_UNQUOTED([HAVE_UNIX_BYTESWAP], [1],
683                              [whether unix byteswap routines -- htonl, htons, nothl, ntohs -- are available])])
684
685    #
686    # Make sure we can copy va_lists (need check declared, not linkable)
687    #
688
689    AC_CHECK_DECL(va_copy, PMIX_HAVE_VA_COPY=1, PMIX_HAVE_VA_COPY=0,
690                  [#include <stdarg.h>])
691    AC_DEFINE_UNQUOTED(PMIX_HAVE_VA_COPY, $PMIX_HAVE_VA_COPY,
692                       [Whether we have va_copy or not])
693
694    AC_CHECK_DECL(__va_copy, PMIX_HAVE_UNDERSCORE_VA_COPY=1,
695                  PMIX_HAVE_UNDERSCORE_VA_COPY=0, [#include <stdarg.h>])
696    AC_DEFINE_UNQUOTED(PMIX_HAVE_UNDERSCORE_VA_COPY, $PMIX_HAVE_UNDERSCORE_VA_COPY,
697                       [Whether we have __va_copy or not])
698
699    AC_CHECK_DECLS(__func__)
700
701    # checkpoint results
702    AC_CACHE_SAVE
703
704    ##################################
705    # System-specific tests
706    ##################################
707
708    pmix_show_title "System-specific tests"
709
710    AC_C_BIGENDIAN
711    PMIX_CHECK_BROKEN_QSORT
712
713    #
714    # Check out what thread support we have
715    #
716    PMIX_CONFIG_THREADS
717
718    CFLAGS="$CFLAGS $THREAD_CFLAGS"
719    CPPFLAGS="$CPPFLAGS $THREAD_CPPFLAGS"
720    LDFLAGS="$LDFLAGS $THREAD_LDFLAGS"
721    LIBS="$LIBS $THREAD_LIBS"
722
723    #
724    # What is the local equivalent of "ln -s"
725    #
726
727    AC_PROG_LN_S
728
729    # Check for some common system programs that we need
730    AC_PROG_GREP
731    AC_PROG_EGREP
732
733    ##################################
734    # Visibility
735    ##################################
736
737    # Check the visibility declspec at the end to avoid problem with
738    # the previous tests that are not necessarily prepared for
739    # the visibility feature.
740    pmix_show_title "Symbol visibility feature"
741
742    PMIX_CHECK_VISIBILITY
743
744    ##################################
745    # Libevent
746    ##################################
747    pmix_show_title "Event libraries"
748
749    PMIX_LIBEV_CONFIG
750    PMIX_LIBEVENT_CONFIG
751
752    AS_IF([test $pmix_libevent_support -eq 1 && test $pmix_libev_support -eq 1],
753      [AC_MSG_WARN([Both libevent and libev support have been specified.])
754       AC_MSG_WARN([Only one can be configured against at a time. Please])
755       AC_MSG_WARN([remove one from the configure command line.])
756       AC_MSG_ERROR([Cannot continue])])
757
758    AS_IF([test $pmix_libevent_support -eq 0 && test $pmix_libev_support -eq 0],
759          [AC_MSG_WARN([Either libevent or libev support is required, but neither])
760           AC_MSG_WARN([was found. Please use the configure options to point us])
761           AC_MSG_WARN([to where we can find one or the other library])
762           AC_MSG_ERROR([Cannot continue])])
763
764
765    ##################################
766    # HWLOC
767    ##################################
768    pmix_show_title "HWLOC"
769
770    PMIX_HWLOC_CONFIG
771
772
773    ##################################
774    # ZLIB
775    ##################################
776    pmix_show_title "ZLIB"
777
778    PMIX_ZLIB_CONFIG
779
780
781    ##################################
782    # Dstore Locking
783    ##################################
784
785    pmix_show_title "Dstore Locking"
786
787    PMIX_CHECK_DSTOR_LOCK
788
789
790    ##################################
791    # MCA
792    ##################################
793
794    pmix_show_title "Modular Component Architecture (MCA) setup"
795
796    #
797    # Do we want to show component load error messages by default?
798    #
799
800    AC_MSG_CHECKING([for default value of mca_base_component_show_load_errors])
801    AC_ARG_ENABLE([show-load-errors-by-default],
802                  [AC_HELP_STRING([--enable-show-load-errors-by-default],
803                                  [Set the default value for the MCA parameter
804                                   mca_base_component_show_load_errors (but can be
805                                   overridden at run time by the usual
806                                   MCA-variable-setting mechansism).  This MCA variable
807                                   controls whether warnings are displayed when an MCA
808                                   component fails to load at run time due to an error.
809                                   (default: enabled in --enable-debug builds, meaning that
810                                   mca_base_component_show_load_errors is enabled
811                                   by default when configured with --enable-debug])])
812    if test "$enable_show_load_errors_by_default" = "no" ; then
813        PMIX_SHOW_LOAD_ERRORS_DEFAULT=0
814        AC_MSG_RESULT([disabled by default])
815    else
816        PMIX_SHOW_LOAD_ERRORS_DEFAULT=$WANT_DEBUG
817        if test "$WANT_DEBUG" = "1"; then
818            AC_MSG_RESULT([enabled by default])
819        else
820            AC_MSG_RESULT([disabled by default])
821        fi
822    fi
823    AC_DEFINE_UNQUOTED(PMIX_SHOW_LOAD_ERRORS_DEFAULT, $PMIX_SHOW_LOAD_ERRORS_DEFAULT,
824                       [Default value for mca_base_component_show_load_errors MCA variable])
825
826    AC_MSG_CHECKING([for subdir args])
827    PMIX_CONFIG_SUBDIR_ARGS([pmix_subdir_args])
828    AC_MSG_RESULT([$pmix_subdir_args])
829
830    PMIX_MCA
831
832
833    ############################################################################
834    # final compiler config
835    ############################################################################
836
837    pmix_show_subtitle "Set path-related compiler flags"
838
839    #
840    # This is needed for VPATH builds, so that it will -I the appropriate
841    # include directory.  We delayed doing it until now just so that
842    # '-I$(top_srcdir)' doesn't show up in any of the configure output --
843    # purely aesthetic.
844    #
845    # Because pmix_config.h is created by AC_CONFIG_HEADERS, we
846    # don't need to -I the builddir for pmix/include. However, if we
847    # are VPATH building, we do need to include the source directories.
848    #
849    if test "$PMIX_top_builddir" != "$PMIX_top_srcdir"; then
850        # Note the embedded m4 directives here -- we must embed them
851        # rather than have successive assignments to these shell
852        # variables, lest the $(foo) names try to get evaluated here.
853        # Yuck!
854        cpp_includes="$PMIX_top_builddir $PMIX_top_srcdir $PMIX_top_srcdir/src $PMIX_top_builddir/include"
855    else
856        cpp_includes="$PMIX_top_srcdir $PMIX_top_srcdir/src"
857    fi
858    CPP_INCLUDES="$(echo $cpp_includes | $SED 's/[[^ \]]* */'"$pmix_cc_iquote"'&/g')"
859    CPPFLAGS="$CPP_INCLUDES -I$PMIX_top_srcdir/include $CPPFLAGS $PMIX_FINAL_CPPFLAGS"
860    LDFLAGS="$LDFLAGS $PMIX_FINAL_LDFLAGS"
861    LIBS="$LIBS $PMIX_FINAL_LIBS"
862
863    ############################################################################
864    # pmixdatadir, pmixlibdir, and pmixinclude are essentially the same as
865    # pkg*dir, but will always be */pmix.
866    pmixdatadir='${datadir}/pmix'
867    pmixlibdir='${libdir}/pmix'
868    pmixincludedir='${includedir}/pmix'
869    AC_SUBST(pmixdatadir)
870    AC_SUBST(pmixlibdir)
871    AC_SUBST(pmixincludedir)
872
873    ############################################################################
874    # setup "make check"
875    ############################################################################
876    PMIX_BUILT_TEST_PREFIX=$PMIX_top_builddir
877    AC_SUBST(PMIX_BUILT_TEST_PREFIX)
878    # expose the mca component library paths in the build system
879    pathfile=$PMIX_top_srcdir/config/mca_library_paths.txt
880    PMIX_COMPONENT_LIBRARY_PATHS=`cat $pathfile`
881    AC_SUBST(PMIX_COMPONENT_LIBRARY_PATHS)
882    AC_CONFIG_FILES(pmix_config_prefix[test/run_tests00.pl], [chmod +x test/run_tests00.pl])
883    AC_CONFIG_FILES(pmix_config_prefix[test/run_tests01.pl], [chmod +x test/run_tests01.pl])
884    AC_CONFIG_FILES(pmix_config_prefix[test/run_tests02.pl], [chmod +x test/run_tests02.pl])
885    AC_CONFIG_FILES(pmix_config_prefix[test/run_tests03.pl], [chmod +x test/run_tests03.pl])
886    AC_CONFIG_FILES(pmix_config_prefix[test/run_tests04.pl], [chmod +x test/run_tests04.pl])
887    AC_CONFIG_FILES(pmix_config_prefix[test/run_tests05.pl], [chmod +x test/run_tests05.pl])
888    AC_CONFIG_FILES(pmix_config_prefix[test/run_tests06.pl], [chmod +x test/run_tests06.pl])
889    AC_CONFIG_FILES(pmix_config_prefix[test/run_tests07.pl], [chmod +x test/run_tests07.pl])
890    AC_CONFIG_FILES(pmix_config_prefix[test/run_tests08.pl], [chmod +x test/run_tests08.pl])
891    AC_CONFIG_FILES(pmix_config_prefix[test/run_tests09.pl], [chmod +x test/run_tests09.pl])
892    AC_CONFIG_FILES(pmix_config_prefix[test/run_tests10.pl], [chmod +x test/run_tests10.pl])
893    AC_CONFIG_FILES(pmix_config_prefix[test/run_tests11.pl], [chmod +x test/run_tests11.pl])
894    AC_CONFIG_FILES(pmix_config_prefix[test/run_tests12.pl], [chmod +x test/run_tests12.pl])
895    AC_CONFIG_FILES(pmix_config_prefix[test/run_tests13.pl], [chmod +x test/run_tests13.pl])
896#    AC_CONFIG_FILES(pmix_config_prefix[test/run_tests14.pl], [chmod +x test/run_tests14.pl])
897#    AC_CONFIG_FILES(pmix_config_prefix[test/run_tests15.pl], [chmod +x test/run_tests15.pl])
898
899
900    ############################################################################
901    # final output
902    ############################################################################
903
904    pmix_show_subtitle "Final output"
905
906    AC_CONFIG_HEADERS(pmix_config_prefix[include/pmix_common.h])
907
908    AC_CONFIG_FILES(
909        pmix_config_prefix[Makefile]
910        pmix_config_prefix[config/Makefile]
911        pmix_config_prefix[etc/Makefile]
912        pmix_config_prefix[include/Makefile]
913        pmix_config_prefix[src/Makefile]
914        pmix_config_prefix[src/util/keyval/Makefile]
915        pmix_config_prefix[src/mca/base/Makefile]
916        pmix_config_prefix[src/tools/pevent/Makefile]
917        pmix_config_prefix[src/tools/pmix_info/Makefile]
918        pmix_config_prefix[src/tools/plookup/Makefile]
919        pmix_config_prefix[src/tools/pps/Makefile]
920        )
921
922    # publish any embedded flags so external wrappers can use them
923    AC_SUBST(PMIX_EMBEDDED_LIBS)
924    AC_SUBST(PMIX_EMBEDDED_LDFLAGS)
925    AC_SUBST(PMIX_EMBEDDED_CPPFLAGS)
926
927    # Success
928    $2
929])dnl
930
931AC_DEFUN([PMIX_DEFINE_ARGS],[
932    # do we want dlopen support ?
933    AC_MSG_CHECKING([if want dlopen support])
934    AC_ARG_ENABLE([dlopen],
935        [AC_HELP_STRING([--enable-dlopen],
936                        [Whether build should attempt to use dlopen (or
937                         similar) to dynamically load components.
938                         (default: enabled)])])
939    AS_IF([test "$enable_dlopen" = "unknown"],
940          [AC_MSG_WARN([enable_dlopen variable has been overwritten by configure])
941           AC_MSG_WARN([This is an internal error that should be reported to PMIx developers])
942           AC_MSG_ERROR([Cannot continue])])
943    AS_IF([test "$enable_dlopen" = "no"],
944          [enable_mca_dso="no"
945           enable_mca_static="yes"
946           PMIX_ENABLE_DLOPEN_SUPPORT=0
947           AC_MSG_RESULT([no])],
948          [PMIX_ENABLE_DLOPEN_SUPPORT=1
949           AC_MSG_RESULT([yes])])
950    AC_DEFINE_UNQUOTED(PMIX_ENABLE_DLOPEN_SUPPORT, $PMIX_ENABLE_DLOPEN_SUPPORT,
951                      [Whether we want to enable dlopen support])
952
953    # Embedded mode, or standalone?
954    AC_MSG_CHECKING([if embedded mode is enabled])
955    AC_ARG_ENABLE([embedded-mode],
956        [AC_HELP_STRING([--enable-embedded-mode],
957                [Using --enable-embedded-mode causes PMIx to skip a few configure checks and install nothing.  It should only be used when building PMIx within the scope of a larger package.])])
958    AS_IF([test "$enable_embedded_mode" = "yes"],
959          [pmix_mode=embedded
960           pmix_install_primary_headers=no
961           AC_MSG_RESULT([yes])],
962          [pmix_mode=standalone
963           pmix_install_primary_headers=yes
964           AC_MSG_RESULT([no])])
965
966#
967# Is this a developer copy?
968#
969
970if test -e $PMIX_TOP_SRCDIR/.git; then
971    PMIX_DEVEL=1
972    # check for Flex
973    AC_PROG_LEX
974    if test "x$LEX" != xflex; then
975        AC_MSG_WARN([PMIx requires Flex to build from non-tarball sources,])
976        AC_MSG_WARN([but Flex was not found. Please install Flex into])
977        AC_MSG_WARN([your path and try again])
978        AC_MSG_ERROR([Cannot continue])
979    fi
980else
981    PMIX_DEVEL=0
982fi
983
984
985#
986# Developer picky compiler options
987#
988
989AC_MSG_CHECKING([if want developer-level compiler pickyness])
990AC_ARG_ENABLE(picky,
991    AC_HELP_STRING([--enable-picky],
992                   [enable developer-level compiler pickyness when building PMIx (default: disabled)]))
993if test "$enable_picky" = "yes"; then
994    AC_MSG_RESULT([yes])
995    WANT_PICKY_COMPILER=1
996else
997    AC_MSG_RESULT([no])
998    WANT_PICKY_COMPILER=0
999fi
1000#################### Early development override ####################
1001if test "$WANT_PICKY_COMPILER" = "0" && test -z "$enable_picky" && test "$PMIX_DEVEL" = "1"; then
1002    WANT_PICKY_COMPILER=1
1003    echo "--> developer override: enable picky compiler by default"
1004fi
1005#################### Early development override ####################
1006
1007#
1008# Developer debugging
1009#
1010
1011AC_MSG_CHECKING([if want developer-level debugging code])
1012AC_ARG_ENABLE(debug,
1013    AC_HELP_STRING([--enable-debug],
1014                   [enable developer-level debugging code (not for general PMIx users!) (default: disabled)]))
1015if test "$enable_debug" = "yes"; then
1016    AC_MSG_RESULT([yes])
1017    WANT_DEBUG=1
1018else
1019    AC_MSG_RESULT([no])
1020    WANT_DEBUG=0
1021fi
1022
1023if test "$WANT_DEBUG" = "0"; then
1024    CFLAGS="-DNDEBUG $CFLAGS"
1025fi
1026
1027AC_DEFINE_UNQUOTED(PMIX_ENABLE_DEBUG, $WANT_DEBUG,
1028                   [Whether we want developer-level debugging code or not])
1029
1030AC_ARG_ENABLE(debug-symbols,
1031              AC_HELP_STRING([--disable-debug-symbols],
1032                             [Disable adding compiler flags to enable debugging symbols if --enable-debug is specified.  For non-debugging builds, this flag has no effect.]))
1033
1034#
1035# Do we want to install the internal devel headers?
1036#
1037AC_MSG_CHECKING([if want to install project-internal header files])
1038AC_ARG_WITH(devel-headers,
1039    AC_HELP_STRING([--with-devel-headers],
1040                   [normal PMIx users/applications do not need this (pmix.h and friends are ALWAYS installed).  Developer headers are only necessary for authors doing deeper integration (default: disabled).]))
1041if test "$with_devel_headers" = "yes"; then
1042    AC_MSG_RESULT([yes])
1043    WANT_INSTALL_HEADERS=1
1044    pmix_install_primary_headers=yes
1045else
1046    AC_MSG_RESULT([no])
1047    WANT_INSTALL_HEADERS=0
1048fi
1049
1050# Install tests and examples?
1051AC_MSG_CHECKING([if tests and examples are to be installed])
1052AC_ARG_WITH([tests-examples],
1053    [AC_HELP_STRING([--with-tests-examples],
1054            [Whether or not to install the tests and example programs.])])
1055AS_IF([test "$pmix_install_primary_headers" = "no"],
1056      [AS_IF([test -z "$with_tests_examples" || test "$with_tests_examples" = "no"],
1057             [pmix_tests=no
1058              AC_MSG_RESULT([no])],
1059             [AC_MSG_RESULT([no])
1060              AC_MSG_WARN([Cannot install tests/examples without installing primary headers.])
1061              AC_MSG_WARN([This situation arises when configured in embedded mode])
1062              AC_MSG_WARN([and without devel headers.])
1063              AC_MSG_ERROR([Please correct the configure line and retry])])],
1064      [AS_IF([test ! -z "$with_tests_examples" && test "$with_tests_examples" = "no"],
1065             [pmix_tests=no
1066              AC_MSG_RESULT([no])],
1067             [pmix_tests=yes
1068              AC_MSG_RESULT([yes])])])
1069
1070#
1071# Support per-user config files?
1072#
1073AC_ARG_ENABLE([per-user-config-files],
1074   [AC_HELP_STRING([--enable-per-user-config-files],
1075      [Disable per-user configuration files, to save disk accesses during job start-up.  This is likely desirable for large jobs.  Note that this can also be acheived by environment variables at run-time.  (default: enabled)])])
1076if test "$enable_per_user_config_files" = "no" ; then
1077  result=0
1078else
1079  result=1
1080fi
1081AC_DEFINE_UNQUOTED([PMIX_WANT_HOME_CONFIG_FILES], [$result],
1082     [Enable per-user config files])
1083
1084#
1085# Do we want the pretty-print stack trace feature?
1086#
1087
1088AC_MSG_CHECKING([if want pretty-print stacktrace])
1089AC_ARG_ENABLE([pretty-print-stacktrace],
1090              [AC_HELP_STRING([--enable-pretty-print-stacktrace],
1091                              [Pretty print stacktrace on process signal (default: enabled)])])
1092if test "$enable_pretty_print_stacktrace" = "no" ; then
1093    AC_MSG_RESULT([no])
1094    WANT_PRETTY_PRINT_STACKTRACE=0
1095else
1096    AC_MSG_RESULT([yes])
1097    WANT_PRETTY_PRINT_STACKTRACE=1
1098fi
1099AC_DEFINE_UNQUOTED([PMIX_WANT_PRETTY_PRINT_STACKTRACE],
1100                   [$WANT_PRETTY_PRINT_STACKTRACE],
1101                   [if want pretty-print stack trace feature])
1102
1103#
1104# Use pthread-based locking
1105#
1106DSTORE_PTHREAD_LOCK="1"
1107AC_MSG_CHECKING([if want dstore pthread-based locking])
1108AC_ARG_ENABLE([dstore-pthlck],
1109              [AC_HELP_STRING([--disable-dstore-pthlck],
1110                              [Disable pthread-based locking in dstor (default: enabled)])])
1111if test "$enable_dstore_pthlck" = "no" ; then
1112    AC_MSG_RESULT([no])
1113    DSTORE_PTHREAD_LOCK="0"
1114else
1115    AC_MSG_RESULT([yes])
1116    DSTORE_PTHREAD_LOCK="1"
1117fi
1118
1119#
1120# Ident string
1121#
1122AC_MSG_CHECKING([if want ident string])
1123AC_ARG_WITH([ident-string],
1124            [AC_HELP_STRING([--with-ident-string=STRING],
1125                            [Embed an ident string into PMIx object files])])
1126if test "$with_ident_string" = "" || test "$with_ident_string" = "no"; then
1127    with_ident_string="%VERSION%"
1128fi
1129# This is complicated, because $PMIX_VERSION may have spaces in it.
1130# So put the whole sed expr in single quotes -- i.e., directly
1131# substitute %VERSION% for (not expanded) $PMIX_VERSION.
1132with_ident_string="`echo $with_ident_string | sed -e 's/%VERSION%/$PMIX_VERSION/'`"
1133
1134# Now eval an echo of that so that the "$PMIX_VERSION" token is
1135# replaced with its value.  Enclose the whole thing in "" so that it
1136# ends up as 1 token.
1137with_ident_string="`eval echo $with_ident_string`"
1138
1139AC_DEFINE_UNQUOTED([PMIX_IDENT_STRING], ["$with_ident_string"],
1140                   [ident string for PMIX])
1141AC_MSG_RESULT([$with_ident_string])
1142
1143#
1144# Timing support
1145#
1146AC_MSG_CHECKING([if want developer-level timing support])
1147AC_ARG_ENABLE(pmix-timing,
1148              AC_HELP_STRING([--enable-pmix-timing],
1149                             [enable PMIx developer-level timing code (default: disabled)]))
1150if test "$enable_pmix_timing" = "yes"; then
1151    AC_MSG_RESULT([yes])
1152    WANT_PMIX_TIMING=1
1153else
1154    AC_MSG_RESULT([no])
1155    WANT_PMIX_TIMING=0
1156fi
1157
1158AC_DEFINE_UNQUOTED([PMIX_ENABLE_TIMING], [$WANT_PMIX_TIMING],
1159                   [Whether we want developer-level timing support or not])
1160
1161#
1162#
1163# Install backward compatibility support for PMI-1 and PMI-2
1164#
1165AC_MSG_CHECKING([if want backward compatibility for PMI-1 and PMI-2])
1166AC_ARG_ENABLE(pmi-backward-compatibility,
1167              AC_HELP_STRING([--enable-pmi-backward-compatibility],
1168                             [enable PMIx support for PMI-1 and PMI-2 (default: enabled)]))
1169if test "$enable_pmi_backward_compatibility" = "no"; then
1170    AC_MSG_RESULT([no])
1171    WANT_PMI_BACKWARD=0
1172else
1173    AC_MSG_RESULT([yes])
1174    WANT_PMI_BACKWARD=1
1175fi
1176
1177AM_CONDITIONAL([WANT_INSTALL_HEADERS], [test $WANT_INSTALL_HEADERS -eq 1])
1178
1179#
1180# Do we want to install binaries?
1181#
1182AC_MSG_CHECKING([if want to disable binaries])
1183AC_ARG_ENABLE(pmix-binaries,
1184              AC_HELP_STRING([--enable-pmix-binaries],
1185                             [enable PMIx tools]))
1186if test "$enable_pmix_binaries" = "no"; then
1187    AC_MSG_RESULT([no])
1188    WANT_PMIX_BINARIES=0
1189else
1190    AC_MSG_RESULT([yes])
1191    WANT_PMIX_BINARIES=1
1192fi
1193
1194AM_CONDITIONAL([PMIX_INSTALL_BINARIES], [test $WANT_PMIX_BINARIES -eq 1])
1195
1196# see if they want to disable non-RTLD_GLOBAL dlopen
1197AC_MSG_CHECKING([if want to support dlopen of non-global namespaces])
1198AC_ARG_ENABLE([nonglobal-dlopen],
1199              AC_HELP_STRING([--enable-nonglobal-dlopen],
1200                             [enable non-global dlopen (default: enabled)]))
1201if test "$enable_nonglobal_dlopen" = "no"; then
1202    AC_MSG_RESULT([no])
1203    pmix_need_libpmix=0
1204else
1205    AC_MSG_RESULT([yes])
1206    pmix_need_libpmix=1
1207fi
1208
1209# if someone enables embedded mode but doesn't want to install the
1210# devel headers, then default nonglobal-dlopen to false
1211AS_IF([test -z "$enable_nonglobal_dlopen" && test "x$pmix_mode" = "xembedded" && test $WANT_INSTALL_HEADERS -eq 0 && test $pmix_need_libpmix -eq 1],
1212      [pmix_need_libpmix=0])
1213
1214#
1215# Do we want PTY support?
1216#
1217
1218AC_MSG_CHECKING([if want pty support])
1219AC_ARG_ENABLE(pty-support,
1220    AC_HELP_STRING([--enable-pty-support],
1221                   [Enable/disable PTY support for STDIO forwarding.  (default: enabled)]))
1222if test "$enable_pty_support" = "no" ; then
1223    AC_MSG_RESULT([no])
1224    PMIX_ENABLE_PTY_SUPPORT=0
1225else
1226    AC_MSG_RESULT([yes])
1227    PMIX_ENABLE_PTY_SUPPORT=1
1228fi
1229AC_DEFINE_UNQUOTED([PMIX_ENABLE_PTY_SUPPORT], [$PMIX_ENABLE_PTY_SUPPORT],
1230                   [Whether user wants PTY support or not])
1231
1232#
1233# psec/dummy_handshake
1234#
1235
1236AC_MSG_CHECKING([if want build psec/dummy_handshake])
1237AC_ARG_ENABLE(dummy-handshake,
1238              AC_HELP_STRING([--enable-dummy-handshake],
1239                             [Enables psec dummy component intended to check the PTL handshake scenario (default: disabled)]))
1240if test "$enable_dummy_handshake" != "yes"; then
1241    AC_MSG_RESULT([no])
1242    eval "DISABLE_psec_dummy_handshake=1"
1243else
1244    AC_MSG_RESULT([yes])
1245    eval "DISABLE_psec_dummy_handshake=0"
1246fi
1247AM_CONDITIONAL(MCA_BUILD_PSEC_DUMMY_HANDSHAKE, test "$DISABLE_psec_dummy_handshake" = "0")
1248])dnl
1249
1250# This must be a standalone routine so that it can be called both by
1251# PMIX_INIT and an external caller (if PMIX_INIT is not invoked).
1252AC_DEFUN([PMIX_DO_AM_CONDITIONALS],[
1253    AS_IF([test "$pmix_did_am_conditionals" != "yes"],[
1254        AM_CONDITIONAL([PMIX_EMBEDDED_MODE], [test "x$pmix_mode" = "xembedded"])
1255        AM_CONDITIONAL([PMIX_TESTS_EXAMPLES], [test "x$pmix_tests" = "xyes"])
1256        AM_CONDITIONAL([PMIX_COMPILE_TIMING], [test "$WANT_TIMING" = "1"])
1257        AM_CONDITIONAL([PMIX_WANT_MUNGE], [test "$pmix_munge_support" = "1"])
1258        AM_CONDITIONAL([PMIX_WANT_SASL], [test "$pmix_sasl_support" = "1"])
1259        AM_CONDITIONAL([WANT_DSTORE], [test "x$enable_dstore" != "xno"])
1260        AM_CONDITIONAL([WANT_PRIMARY_HEADERS], [test "x$pmix_install_primary_headers" = "xyes"])
1261        AM_CONDITIONAL(WANT_INSTALL_HEADERS, test "$WANT_INSTALL_HEADERS" = 1)
1262        AM_CONDITIONAL(WANT_PMI_BACKWARD, test "$WANT_PMI_BACKWARD" = 1)
1263        AM_CONDITIONAL(NEED_LIBPMIX, [test "$pmix_need_libpmix" = "1"])
1264    ])
1265    pmix_did_am_conditionals=yes
1266])dnl
1267