1# -*- shell-script -*-
2#
3# Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana
4#                         University Research and Technology
5#                         Corporation.  All rights reserved.
6# Copyright (c) 2004-2010 The University of Tennessee and The University
7#                         of Tennessee Research Foundation.  All rights
8#                         reserved.
9# Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
10#                         University of Stuttgart.  All rights reserved.
11# Copyright (c) 2004-2005 The Regents of the University of California.
12#                         All rights reserved.
13# Copyright (c) 2006-2020 Cisco Systems, Inc.  All rights reserved
14# Copyright (c) 2006-2008 Sun Microsystems, Inc.  All rights reserved.
15# Copyright (c) 2006-2017 Los Alamos National Security, LLC.  All rights
16#                         reserved.
17# Copyright (c) 2009      Oak Ridge National Labs.  All rights reserved.
18# Copyright (c) 2011-2013 NVIDIA Corporation.  All rights reserved.
19# Copyright (c) 2012      Oracle and/or its affiliates.  All rights reserved.
20# Copyright (c) 2013      Mellanox Technologies, Inc.
21#                         All rights reserved.
22# Copyright (c) 2014-2020 Intel, Inc.  All rights reserved.
23# Copyright (c) 2016      IBM Corporation.  All rights reserved.
24# Copyright (c) 2016-2018 Research Organization for Information Science
25#                         and Technology (RIST). All rights reserved.
26# $COPYRIGHT$
27#
28# Additional copyrights may follow
29#
30# $HEADER$
31#
32
33
34############################################################################
35# Initialization, version number, and other random setup/init stuff
36############################################################################
37
38# Load in everything found by autogen.pl
39m4_include([config/autogen_found_items.m4])
40
41# We don't have the version number to put in here yet, and we can't
42# call PMIX_GET_VERSION (etc.) before AC_INIT.  So use the shell
43# version.
44
45AC_INIT([pmix],
46        [m4_normalize(esyscmd([config/pmix_get_version.sh VERSION --tarball]))],
47        [https://github.com/pmix/pmix/issues], [pmix])
48AC_PREREQ(2.69)
49AC_CONFIG_AUX_DIR(./config)
50# Note that this directory must *exactly* match what was specified via
51# -I in ACLOCAL_AMFLAGS in the top-level Makefile.am.
52AC_CONFIG_MACRO_DIR(./config)
53
54# autotools expects to perform tests without interference
55# from user-provided CFLAGS, particularly -Werror flags.
56# Search for them here and cache any we find
57PMIX_CFLAGS_cache=
58PMIX_CFLAGS_pass=
59for val in $CFLAGS; do
60    if echo "$val" | grep -q -e "-W"; then
61        PMIX_CFLAGS_cache="$PMIX_CFLAGS_cache $val";
62    else
63        PMIX_CFLAGS_pass="$PMIX_CFLAGS_pass $val";
64    fi
65done
66CFLAGS=$PMIX_CFLAGS_pass
67
68PMIX_CAPTURE_CONFIGURE_CLI([PMIX_CONFIGURE_CLI])
69
70# Get our platform support file.  This has to be done very, very early
71# because it twiddles random bits of autoconf
72PMIX_LOAD_PLATFORM
73
74PMIX_TOP_BUILDDIR="`pwd`"
75AC_SUBST(PMIX_TOP_BUILDDIR)
76top_buildir=`pwd`
77cd "$srcdir"
78PMIX_TOP_SRCDIR="`pwd`"
79AC_SUBST(PMIX_TOP_SRCDIR)
80cd "$PMIX_TOP_BUILDDIR"
81top_srcdir=`pwd`
82
83AC_MSG_NOTICE([builddir: $PMIX_TOP_BUILDDIR])
84AC_MSG_NOTICE([srcdir: $PMIX_TOP_SRCDIR])
85if test "$PMIX_TOP_BUILDDIR" != "$PMIX_TOP_SRCDIR"; then
86    AC_MSG_NOTICE([Detected VPATH build])
87fi
88
89# setup configure options (e.g., show_title and friends)
90PMIX_CONFIGURE_SETUP
91pmix_show_title "Configuring PMIx"
92
93# This must be before AM_INIT_AUTOMAKE
94AC_CANONICAL_TARGET
95
96# Init automake
97AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects no-define 1.13.4])
98
99# SILENT_RULES is new in AM 1.11, but we require 1.13.4 or higher via
100# autogen.  Limited testing shows that calling SILENT_RULES directly
101# works in more cases than adding "silent-rules" to INIT_AUTOMAKE
102# (even though they're supposed to be identical).  Shrug.
103AM_SILENT_RULES([yes])
104
105# set the language
106AC_LANG([C])
107
108# AC_USE_SYSTEM_EXTENSIONS will modify CFLAGS if nothing was in there
109# beforehand.  We don't want that.  So if there was nothing in
110# CFLAGS, put nothing back in there.
111PMIX_VAR_SCOPE_PUSH([CFLAGS_save])
112CFLAGS_save=$CFLAGS
113AC_USE_SYSTEM_EXTENSIONS
114AS_IF([test -z "$CFLAGS_save"], [CFLAGS=])
115PMIX_VAR_SCOPE_POP
116
117####################################################################
118# Setup the configure header files
119####################################################################
120
121AH_TOP([/* -*- c -*-
122 *
123 * Copyright (c) 2004-2005 The Trustees of Indiana University.
124 *                         All rights reserved.
125 * Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
126 *                         All rights reserved.
127 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
128 *                         University of Stuttgart.  All rights reserved.
129 * Copyright (c) 2004-2005 The Regents of the University of California.
130 *                         All rights reserved.
131 * Copyright (c) 2013-2015 Intel, Inc. All rights reserved
132 * Copyright (c) 2016      IBM Corporation.  All rights reserved.
133 * $COPYRIGHT$
134 *
135 * Additional copyrights may follow
136 *
137 * $HEADER$
138 *
139 * This file is automatically generated by configure.  Edits will be lost
140 * the next time you run configure!
141 */
142
143#ifndef PMIX_CONFIG_H
144#define PMIX_CONFIG_H
145
146#include "src/include/pmix_config_top.h"
147
148])
149AH_BOTTOM([
150#include "src/include/pmix_config_bottom.h"
151#endif /* PMIX_CONFIG_H */
152])
153
154############################################################################
155# Setup Libtool
156############################################################################
157
158# We want new Libtool.  None of that old stuff.  Pfft.
159m4_ifdef([LT_PREREQ], [],
160         [m4_fatal([libtool version 2.2.6 or higher is required], [63])])
161LT_PREREQ([2.2.6])
162
163#
164# Enable static so that we have the --with tests done up here and can
165# check for OS.  Save the values of $enable_static and $enable_shared
166# before setting the defaults, because if the user specified
167# --[en|dis]able-[static|shared] on the command line, they'll already
168# be set.  In this way, we can tell if the user requested something or
169# if the default was set here.
170#
171
172pmix_enable_shared="$enable_shared"
173pmix_enable_static="$enable_static"
174AS_IF([test ! -z "$enable_static" && test "$enable_static" = "yes"],
175      [CFLAGS="$CFLAGS -fPIC"])
176
177AM_ENABLE_SHARED
178AM_DISABLE_STATIC
179
180# This did not exist pre AM 1.11.x (where x is somewhere >0 and <3),
181# but it is necessary in AM 1.12.x.
182m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
183AM_PROG_LEX
184
185############################################################################
186# Configuration options
187############################################################################
188
189# Set the MCA prefix
190PMIX_SET_MCA_PREFIX([PMIX_MCA_])
191PMIX_SET_MCA_CMD_LINE_ID([pmca])
192
193# Define PMIx configure arguments
194PMIX_DEFINE_ARGS
195# Define some basic useful values
196PMIX_BASIC_SETUP
197
198# If debug mode, add -g
199AS_IF([test "$pmix_debug" = "1"],
200      [CFLAGS="$CFLAGS -g"])
201
202LT_INIT()
203LT_LANG([C])
204
205############################################################################
206# Setup the core
207############################################################################
208
209# Setup the pmix core
210PMIX_SETUP_CORE()
211
212# Run the AM_CONDITIONALs
213PMIX_DO_AM_CONDITIONALS
214
215####################################################################
216# Setup C compiler
217####################################################################
218
219AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
220AS_IF([test -z "$CC_FOR_BUILD"],[
221    AC_SUBST([CC_FOR_BUILD], [$CC])
222])
223
224# restore any user-provided Werror flags
225AS_IF([test ! -z "$PMIX_CFLAGS_cache"], [CFLAGS="$CFLAGS $PMIX_CFLAGS_cache"])
226
227# Delay setting pickyness until here so we
228# don't break configure code tests
229#if test "$WANT_PICKY_COMPILER" = "1"; then
230#    CFLAGS="$CFLAGS -Wall -Wextra -Werror"
231#fi
232
233# Cleanup duplicate flags
234PMIX_FLAGS_UNIQ(CFLAGS)
235PMIX_FLAGS_UNIQ(CPPFLAGS)
236PMIX_FLAGS_UNIQ(LDFLAGS)
237PMIX_FLAGS_UNIQ(LIBS)
238
239#
240# Delayed the substitution of CFLAGS and CXXFLAGS until now because
241# they may have been modified throughout the course of this script.
242#
243
244AC_SUBST(CFLAGS)
245AC_SUBST(CPPFLAGS)
246
247pmix_show_title "Final compiler flags"
248
249AC_MSG_CHECKING([final CPPFLAGS])
250AC_MSG_RESULT([$CPPFLAGS])
251
252AC_MSG_CHECKING([final CFLAGS])
253AC_MSG_RESULT([$CFLAGS])
254
255AC_MSG_CHECKING([final LDFLAGS])
256AC_MSG_RESULT([$LDFLAGS])
257
258AC_MSG_CHECKING([final LIBS])
259AC_MSG_RESULT([$LIBS])
260
261####################################################################
262# Setup variables for pkg-config file (maint/pmix.pc.in)
263####################################################################
264
265#
266# Dependencies that themselves have a pkg-config file available.
267#
268PC_REQUIRES=""
269AS_IF([test "$pmix_hwloc_support_will_build" = "yes" && test "$pmix_hwloc_source" != "embedded"],
270      [PC_REQUIRES="$PC_REQUIRES hwloc"])
271AS_IF([test $pmix_libevent_support -eq 1 && test "$pmix_libevent_source" != "embedded"],
272      [PC_REQUIRES="$PC_REQUIRES libevent"])
273AS_IF([test "$pmix_zlib_support" = "1"],
274      [PC_REQUIRES="$PC_REQUIRES zlib"])
275AC_SUBST([PC_REQUIRES], ["$PC_REQUIRES"])
276
277#
278# Dependencies that don't have a pkg-config file available.
279# In this case we need to manually add -L<path> and -l<lib>
280# to the PC_PRIVATE_LIBS variable.
281#
282PC_PRIVATE_LIBS=""
283AS_IF([test $pmix_libev_support -eq 1],
284      [PC_PRIVATE_LIBS="$PC_PRIVATE_LIBS $pmix_libev_LDFLAGS $pmix_libev_LIBS"])
285AC_SUBST([PC_PRIVATE_LIBS], ["$PC_PRIVATE_LIBS"])
286
287####################################################################
288# -Werror for CI scripts
289####################################################################
290
291AC_ARG_ENABLE(werror,
292    AC_HELP_STRING([--enable-werror],
293                   [Treat compiler warnings as errors]),
294[
295    CFLAGS="$CFLAGS -Werror"
296])
297
298####################################################################
299# Version information
300####################################################################
301
302# PMIX_VERSION was setup by PMIX_SETUP_CORE above.
303
304# Make configure depend on the VERSION file, since it's used in AC_INIT
305AC_SUBST([CONFIGURE_DEPENDENCIES], ['$(top_srcdir)/VERSION'])
306
307. $srcdir/VERSION
308AC_SUBST([libpmix_so_version])
309AC_SUBST([libpmi_so_version])
310AC_SUBST([libpmi2_so_version])
311AC_SUBST([libmca_common_dstore_so_version])
312
313AC_CONFIG_FILES(pmix_config_prefix[contrib/Makefile]
314                pmix_config_prefix[examples/Makefile]
315                pmix_config_prefix[test/Makefile]
316                pmix_config_prefix[test/simple/Makefile]
317                pmix_config_prefix[maint/pmix.pc])
318
319pmix_show_title "Configuration complete"
320
321AC_OUTPUT
322
323PMIX_SUMMARY_PRINT
324