there was an #include directive missing
[openmpi-llc.git] / config / ompi_mca.m4
blobff2caac8c085a79b26ee0e7798d4a9f783bfe795
1 dnl -*- shell-script -*-
2 dnl
3 dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4 dnl                         University Research and Technology
5 dnl                         Corporation.  All rights reserved.
6 dnl Copyright (c) 2004-2005 The University of Tennessee and The University
7 dnl                         of Tennessee Research Foundation.  All rights
8 dnl                         reserved.
9 dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
10 dnl                         University of Stuttgart.  All rights reserved.
11 dnl Copyright (c) 2004-2005 The Regents of the University of California.
12 dnl                         All rights reserved.
13 dnl $COPYRIGHT$
14 dnl 
15 dnl Additional copyrights may follow
16 dnl 
17 dnl $HEADER$
18 dnl
20 # OMPI_EVAL_ARG(arg)
21 # ------------------
22 # evaluates and returns argument
23 AC_DEFUN([OMPI_EVAL_ARG], [$1])
25 ######################################################################
27 # OMPI_MCA
29 # configure the MCA (modular component architecture).  Works hand in hand
30 # with Open MPI's autogen.sh, requiring it's specially formatted lists
31 # of frameworks, components, etc.
33 # USAGE:
34 #   OMPI_MCA()
36 ######################################################################
37 AC_DEFUN([OMPI_MCA],[
38     # Find which components should be built as run-time loadable components
39     # Acceptable combinations:
40     #
41     # [default -- no option given]
42     # --enable-mca-dso
43     # --enable-mca-dso=[.+,]*COMPONENT_TYPE[.+,]*
44     # --enable-mca-dso=[.+,]*COMPONENT_TYPE-COMPONENT_NAME[.+,]*
45     # --disable-mca-dso
46     #
47     AC_ARG_ENABLE([mca-no-build],
48         [AC_HELP_STRING([--enable-mca-no-build=LIST],
49                         [Comma-separated list of <type>-<component> pairs 
50                          that will not be built.  Example: "--enable-mca-no-build=maffinity-libnuma,btl-portals" will disable building both the "libnuma" maffinity and "portals" btl components.])])
51     AC_ARG_ENABLE(mca-dso,
52         AC_HELP_STRING([--enable-mca-dso=LIST],
53                        [Comma-separated list of types and/or
54                         type-component pairs that will be built as
55                         run-time loadable components (as opposed to
56                         statically linked in), if supported on this
57                         platform.  The default is to build all components
58                         as DSOs.]))
59     AC_ARG_ENABLE(mca-static,
60         AC_HELP_STRING([--enable-mca-static=LIST],
61                        [Comma-separated list of types and/or
62                         type-component pairs that will be built statically
63                         linked into the library.  The default (if DSOs are
64                         supported) is to build all components as DSOs.
65                         Enabling a component as static disables it
66                         building as a DSO.]))
67     AC_ARG_ENABLE(mca-direct,
68         AC_HELP_STRING([--enable-mca-direct=LIST],
69                        [Comma-separated list of type-component pairs that
70                         will be hard coded as the one component to use for
71                         a given component type, saving the (small)
72                         overhead of the component architecture.  LIST must
73                         not be empty and implies given component pairs are
74                         build as static components.]))
76     AC_MSG_CHECKING([which components should be disabled])
77     if test "$enable_mca_no_build" = "yes"; then
78         AC_MSG_RESULT([yes])
79         AC_MSG_ERROR([*** The enable-mca-no-build flag requires an explicit list
80 *** of type-component pairs.  For example, --enable-mca-direct=pml-teg])
81     else
82         ifs_save="$IFS"
83         IFS="${IFS}$PATH_SEPARATOR,"
84         msg=
85         for item in $enable_mca_no_build; do
86             type="`echo $item | cut -f1 -d-`"
87             comp="`echo $item | cut -f2- -d-`"
88             if test -z $type -o -z $comp ; then
89                 AC_MSG_ERROR([*** The enable-no-build flag requires a
90 *** list of type-component pairs.  Invalid input detected.])
91             else
92                 str="`echo DISABLE_${type}_${comp}=1 | sed s/-/_/g`"
93                 eval $str
94                 msg="$item $msg"
95             fi
96         done
97         IFS="$ifs_save"
98     fi
99     AC_MSG_RESULT([$msg])
100     unset msg
102     #
103     # First, add all the mca-direct components / types into the mca-static
104     # lists and create a list of component types that are direct compile,
105     # in the form DIRECT_[type]=[component]
106     #
107     AC_MSG_CHECKING([which components should be direct-linked into the library])
108     if test "$enable_mca_direct" = "yes" ; then
109         AC_MSG_RESULT([yes])
110         AC_MSG_ERROR([*** The enable-mca-direct flag requires an explicit list of
111 *** type-component pairs.  For example, --enable-mca-direct=pml-teg,coll-basic])
112     elif test ! -z "$enable_mca_direct" -a "$enable_mca_direct" != "" ; then
113         #
114         # we need to add this into the static list, unless the static list
115         # is everything
116         #
117         if test "$enable_mca_static" = "no" ; then
118             AC_MSG_WARN([*** Re-enabling static component support for direct call])
119             enable_mca_static="$enable_mca_direct"
120         elif test -z "$enable_mca_static" ; then
121             enable_mca_static="$enable_mca_direct"
122         elif test "$enable_mca_static" != "yes" ; then
123             enable_mca_static="$enable_mca_direct,$enable_mca_static"
124         fi
126         ifs_save="$IFS"
127         IFS="${IFS}$PATH_SEPARATOR,"
128         msg=
129         for item in $enable_mca_direct; do
130             type="`echo $item | cut -f1 -d-`"
131             comp="`echo $item | cut -f2- -d-`"
132             if test -z $type -o -z $comp ; then
133                 AC_MSG_ERROR([*** The enable-mca-direct flag requires a
134 *** list of type-component pairs.  Invalid input detected.])
135             else
136                 str="`echo DIRECT_$type=$comp | sed s/-/_/g`"
137                 eval $str
138                 msg="$item $msg"
139             fi
140         done
141         IFS="$ifs_save"
142     fi
143     AC_MSG_RESULT([$msg])
144     unset msg
146     #
147     # Second, set the DSO_all and STATIC_all variables.  conflict
148     # resolution (prefer static) is done in the big loop below
149     #
150     AC_MSG_CHECKING([which components should be run-time loadable])
151     if test "$enable_static" != "no"; then
152         DSO_all=0
153         msg=none
154     elif test -z "$enable_mca_dso" -o "$enable_mca_dso" = "yes"; then
155         DSO_all=1
156         msg=all
157     elif test "$enable_mca_dso" = "no"; then
158         DSO_all=0
159         msg=none
160     else
161         DSO_all=0
162         ifs_save="$IFS"
163         IFS="${IFS}$PATH_SEPARATOR,"
164         msg=
165         for item in $enable_mca_dso; do
166             str="`echo DSO_$item=1 | sed s/-/_/g`"
167             eval $str
168             msg="$item $msg"
169         done
170         IFS="$ifs_save"
171     fi
172     AC_MSG_RESULT([$msg])
173     unset msg
174     if test "$enable_static" != "no"; then
175         AC_MSG_WARN([*** Shared libraries have been disabled (--disable-shared)])
176         AC_MSG_WARN([*** Building MCA components as DSOs automatically disabled])
177     fi
179     AC_MSG_CHECKING([which components should be static])
180     if test "$enable_mca_static" = "yes"; then
181         STATIC_all=1
182         msg=all
183     elif test -z "$enable_mca_static" -o "$enable_mca_static" = "no"; then
184         STATIC_all=0
185         msg=none
186     else
187         STATIC_all=0
188         ifs_save="$IFS"
189         IFS="${IFS}$PATH_SEPARATOR,"
190         msg=
191         for item in $enable_mca_static; do
192             str="`echo STATIC_$item=1 | sed s/-/_/g`"
193             eval $str
194             msg="$item $msg"
195         done
196         IFS="$ifs_save"
197     fi
198     AC_MSG_RESULT([$msg])
199     unset msg
201     AC_MSG_CHECKING([for projects containing MCA frameworks])
202     AC_MSG_RESULT([mca_project_list])
204     # if there isn't a project list, abort
205     m4_ifdef([mca_project_list], [],
206              [m4_fatal([Could not find project list - rerun autogen.sh without -l])])
208     # now configre all the projects, frameworks, and components.  Most
209     # of the hard stuff is in here
210     MCA_PROJECT_SUBDIRS=
211     m4_foreach(mca_project, [mca_project_list], 
212                [MCA_PROJECT_SUBDIRS="$MCA_PROJECT_SUBDIRS mca_project"
213                 MCA_CONFIGURE_PROJECT(mca_project)])
215     # BWB - fix me...  need to automate this somehow
216     MCA_SETUP_DIRECT_CALL(pml, ompi)
218     # make all the config output statements for the no configure
219     # components
220     MCA_NO_CONFIG_CONFIG_FILES()
222     AC_SUBST(MCA_PROJECT_SUBDIRS)
226 ######################################################################
228 # MCA_CONFIGURE_PROJECT
230 # Configure all frameworks inside the given project name.  Assumes that
231 # the frameworks are located in [project_name]/mca/[frameworks] and that
232 # there is an m4_defined list named mca_[project]_framework_list with
233 # the list of frameworks.
235 # USAGE:
236 #   MCA_CONFIGURE_PROJECT(project_name)
238 ######################################################################
239 AC_DEFUN([MCA_CONFIGURE_PROJECT],[
240     # can't use a variable rename here because these need to be evaled
241     # at auto* time.
243     ompi_show_subtitle "Configuring MCA for $1"
245     AC_MSG_CHECKING([for frameworks for $1])
246     AC_MSG_RESULT([mca_$1_framework_list])
248     # iterate through the list of frameworks.  There is something
249     # funky with m4 foreach if the list is defined, but empty.  It
250     # will call the 3rd argument once with an empty value for the
251     # first argument.  Protect against calling MCA_CONFIGURE_FRAMEWORK
252     # with an empty second argument.  Grrr....
253     # if there isn't a project list, abort
254     #
255     # Also setup two variables for Makefiles:
256     #  MCA_project_FRAMEWORKS     - list of frameworks in that project
257     #  MCA_project_FRAMEWORK_LIBS - list of libraries (or variables pointing
258     #                               to more libraries) that must be included
259     #                               in the project's main library
260     m4_ifdef([mca_$1_framework_list], [], 
261              [m4_fatal([Could not find mca_$1_framework_list - rerun autogen.sh without -l])])
263     MCA_$1_FRAMEWORKS=
264     MCA_$1_FRAMEWORKS_SUBDIRS=
265     MCA_$1_FRAMEWORK_COMPONENT_ALL_SUBDIRS=
266     MCA_$1_FRAMEWORK_COMPONENT_DSO_SUBDIRS=
267     MCA_$1_FRAMEWORK_COMPONENT_STATIC_SUBDIRS=
268     MCA_$1_FRAMEWORK_LIBS=
269     
270     m4_foreach(mca_framework, [mca_$1_framework_list],
271                [m4_ifval(mca_framework, 
272                          [# common has to go up front
273                           if test "mca_framework" = "common" ; then
274                               MCA_$1_FRAMEWORKS="mca_framework $MCA_$1_FRAMEWORKS"
275                               MCA_$1_FRAMEWORKS_SUBDIRS="[mca/]mca_framework $MCA_$1_FRAMEWORKS_SUBDIRS"
276                               MCA_$1_FRAMEWORK_COMPONENT_ALL_SUBDIRS="[\$(MCA_]mca_framework[_ALL_SUBDIRS)] $MCA_$1_FRAMEWORK_COMPONENT_ALL_SUBDIRS"
277                               MCA_$1_FRAMEWORK_COMPONENT_DSO_SUBDIRS="[\$(MCA_]mca_framework[_DSO_SUBDIRS)] $MCA_$1_FRAMEWORK_COMPONENT_DSO_SUBDIRS"
278                               MCA_$1_FRAMEWORK_COMPONENT_STATIC_SUBDIRS="[\$(MCA_]mca_framework[_STATIC_SUBDIRS)] $MCA_$1_FRAMEWORK_COMPONENT_STATIC_SUBDIRS"
279                           else
280                               MCA_$1_FRAMEWORKS="$MCA_$1_FRAMEWORKS mca_framework"
281                               MCA_$1_FRAMEWORKS_SUBDIRS="$MCA_$1_FRAMEWORKS_SUBDIRS [mca/]mca_framework"
282                               MCA_$1_FRAMEWORK_COMPONENT_ALL_SUBDIRS="$MCA_$1_FRAMEWORK_COMPONENT_ALL_SUBDIRS [\$(MCA_]mca_framework[_ALL_SUBDIRS)]"
283                               MCA_$1_FRAMEWORK_COMPONENT_DSO_SUBDIRS="$MCA_$1_FRAMEWORK_COMPONENT_DSO_SUBDIRS [\$(MCA_]mca_framework[_DSO_SUBDIRS)]"
284                               MCA_$1_FRAMEWORK_COMPONENT_STATIC_SUBDIRS="$MCA_$1_FRAMEWORK_COMPONENT_STATIC_SUBDIRS [\$(MCA_]mca_framework[_STATIC_SUBDIRS)]"
285                           fi
286                           if test "mca_framework" != "common" ; then
287                               MCA_$1_FRAMEWORK_LIBS="$MCA_$1_FRAMEWORK_LIBS [mca/]mca_framework[/libmca_]mca_framework[.la]"
288                           fi
289                           MCA_$1_FRAMEWORK_LIBS="$MCA_$1_FRAMEWORK_LIBS [\$(MCA_]mca_framework[_STATIC_LTLIBS)]"
290                           m4_ifdef([MCA_]mca_framework[_CONFIG],
291                                    [MCA_]mca_framework[_CONFIG]($1, mca_framework),
292                                    [MCA_CONFIGURE_FRAMEWORK($1, mca_framework)])])])
294     AC_SUBST(MCA_$1_FRAMEWORKS)
295     AC_SUBST(MCA_$1_FRAMEWORKS_SUBDIRS)
296     AC_SUBST(MCA_$1_FRAMEWORK_COMPONENT_ALL_SUBDIRS)
297     AC_SUBST(MCA_$1_FRAMEWORK_COMPONENT_DSO_SUBDIRS)
298     AC_SUBST(MCA_$1_FRAMEWORK_COMPONENT_STATIC_SUBDIRS)
299     AC_SUBST(MCA_$1_FRAMEWORK_LIBS)
302 ######################################################################
304 # MCA_CONFIGURE_FRAMEWORK
306 # Configure the given framework and all components inside the
307 # framework.  Assumes that the framework is located in
308 # [project_name]/mca/[framework], and that all components are
309 # available under the framework directory.  Will configure all
310 # no-configure and builtin components, then search for components with
311 # configure scripts.  Assumes that no component is marked as builtin
312 # AND has a configure script.
314 # USAGE:
315 #   MCA_CONFIGURE_PROJECT(project_name, framework_name)
317 ######################################################################
318 AC_DEFUN([MCA_CONFIGURE_FRAMEWORK],[
319     ompi_show_subsubtitle "Configuring MCA framework $2"
321     # setup for framework
322     all_components=
323     static_components=
324     dso_components=
325     static_ltlibs=
327     # Ensure that the directory where the #include file is to live
328     # exists.  Need to do this for VPATH builds, because the directory
329     # may not exist yet.  For the "common" type, it's not really a
330     # component, so it doesn't have a base.
331     if test "$2" = "common" ; then
332         outdir=$1/mca/common
333     else
334         outdir=$1/mca/$2/base
335     fi
336     AS_MKDIR_P([$outdir])
338     # remove any previously generated #include files
339     outfile_real=$outdir/static-components.h
340     outfile=$outfile_real.new
341     rm -f $outfile $outfile.struct $outfile.extern
342     touch $outfile.struct $outfile.extern
344     # print some nice messages about what we're about to do...
345     AC_MSG_CHECKING([for no configure components in framework $2])
346     AC_MSG_RESULT([mca_$2_no_config_component_list])
347     AC_MSG_CHECKING([for m4 configure components in framework $2])
348     AC_MSG_RESULT([mca_$2_m4_config_component_list])
350     # if we only want the first successful component, set the variable
351     # happy_value to 0 so we stop on first assignment.  Otherwise, set
352     # it to zero so that components_looking_for_succeed is always 1
353     m4_if(OMPI_EVAL_ARG([MCA_]mca_framework[_CONFIGURE_MODE]), 
354           [STOP_AT_FIRST],
355           [happy_value=0],
356           [happy_value=1])
358     components_looking_for_succeed=1
360     # configure components that don't have any component-specific
361     # configuration.  See comment in CONFIGURE_PROJECT about the
362     # m4_ifval
363     # if there isn't a component list, abort
364     m4_ifdef([mca_$2_no_config_component_list], [], 
365              [m4_fatal([Could not find mca_$2_no_config_component_list - rerun autogen.sh without -l])])
366     m4_foreach(mca_component, [mca_$2_no_config_component_list],
367                [m4_ifval(mca_component,
368                   [MCA_CONFIGURE_NO_CONFIG_COMPONENT($1, $2, mca_component, 
369                                                      [all_components],
370                                                      [static_components],
371                                                      [dso_components],
372                                                      [static_ltlibs],
373                                                      [$components_looking_for_succeed])])])
375     # configure components that use built-in configuration scripts
376     # see comment in CONFIGURE_PROJECT about the m4_ifval
377     # if there isn't a component list, abort
378     m4_ifdef([mca_$2_m4_config_component_list], [], 
379              [m4_fatal([Could not find mca_$2_m4_config_component_list - rerun autogen.sh without -l])])
380     m4_foreach(mca_component, [mca_$2_m4_config_component_list],
381                [m4_ifval(mca_component,
382                   [MCA_CONFIGURE_M4_CONFIG_COMPONENT($1, $2, mca_component, 
383                                                      [all_components],
384                                                      [static_components],
385                                                      [dso_components],
386                                                      [static_ltlibs],
387                                                      [$components_looking_for_succeed],
388                                                      [components_looking_for_succeed="$happy_value"])])])
390     # configure components that provide their own configure script.
391     # It would be really hard to run these for "find first that
392     # works", so we don't :)
393     AS_IF([test "$happy_value" = "1"],
394           [MCA_CONFIGURE_ALL_CONFIG_COMPONENTS($1, $2, [all_components],
395                                                [static_components], [dso_components],
396                                                [static_ltlibs])])
398     MCA_$2_ALL_COMPONENTS="$all_components"
399     MCA_$2_STATIC_COMPONENTS="$static_components"
400     MCA_$2_DSO_COMPONENTS="$dso_components"
401     MCA_$2_STATIC_LTLIBS="$static_ltlibs"
403     AC_SUBST(MCA_$2_ALL_COMPONENTS)
404     AC_SUBST(MCA_$2_STATIC_COMPONENTS)
405     AC_SUBST(MCA_$2_DSO_COMPONENTS)
406     AC_SUBST(MCA_$2_STATIC_LTLIBS)
408     OMPI_MCA_MAKE_DIR_LIST(MCA_$2_ALL_SUBDIRS, $2, [$all_components])
409     OMPI_MCA_MAKE_DIR_LIST(MCA_$2_STATIC_SUBDIRS, $2, [$static_components])
410     OMPI_MCA_MAKE_DIR_LIST(MCA_$2_DSO_SUBDIRS, $2, [$dso_components])
412     # add all the makefiles for the framework to the CONFIG_FILES.
413     # Don't add common/base, since it doesn't exist
414     AC_CONFIG_FILES([$1/mca/$2/Makefile])
416     # Create the final .h file that will be included in the type's
417     # top-level glue.  This lists all the static components.  We don't
418     # need to do this for "common".
419     if test "$2" != "common"; then
420         cat > $outfile <<EOF
422  * \$HEADER\$
423  */
425 `cat $outfile.extern`
427 const mca_base_component_t *mca_$2_base_static_components[[]] = {
428 `cat $outfile.struct`
429   NULL
432         # Only replace the header file if a) it doesn't previously
433         # exist, or b) the contents are different.  Do this to not
434         # trigger recompilation of certain .c files just because the
435         # timestamp changed on $outfile_real (similar to the way AC
436         # handles AC_CONFIG_HEADER files).
437         diff $outfile $outfile_real > /dev/null 2>&1
438         if test "$?" != "0"; then
439             mv $outfile $outfile_real
440         else
441             rm -f $outfile
442         fi
443     fi
444     rm -f $outfile.struct $outfile.extern 
446     unset all_components static_components dso_components outfile outfile_real
450 ######################################################################
452 # MCA_CONFIGURE_NO_CONFIG_COMPONENT
454 # Configure the given framework and all components inside the framework.
455 # Assumes that the framework is located in [project_name]/mca/[framework],
456 # and that all components are available under the framework directory.
457 # Will configure all builtin components, then search for components with
458 # configure scripts.  Assumes that no component is marked as builtin
459 # AND has a configure script.
461 # USAGE:
462 #   MCA_CONFIGURE_PROJECT(project_name, framework_name, component_name
463 #                         all_components_variable, 
464 #                         static_components_variable,
465 #                         dso_components_variable,
466 #                         static_ltlibs_variable,
467 #                         allowed_to_succeed)
469 ######################################################################
470 AC_DEFUN([MCA_CONFIGURE_NO_CONFIG_COMPONENT],[
471     ompi_show_subsubsubtitle "MCA component $2:$3 (no configuration)"
473     MCA_COMPONENT_BUILD_CHECK($1, $2, $3, 
474                               [should_build=$8], [should_build=0])
475     MCA_COMPONENT_COMPILE_MODE($1, $2, $3, compile_mode)
477     if test "$should_build" = "1" ; then
478         MCA_PROCESS_COMPONENT($1, $2, $3, $4, $5, $6, $7, $compile_mode)
479     else
480         MCA_PROCESS_DEAD_COMPONENT($1, $2, $3)
481         # add component to all component list
482         $4="$$4 $3"
483     fi
485     # set the AM_CONDITIONAL on how we should build
486     if test "$compile_mode" = "dso" ; then
487         BUILD_$2_$3_DSO=1
488     else
489         BUILD_$2_$3_DSO=0
490     fi
491     AM_CONDITIONAL(OMPI_BUILD_$2_$3_DSO, test "$BUILD_$2_$3_DSO" = "1")
493     unset compile_mode
497 ######################################################################
499 # MCA_CONFIGURE_M4_CONFIG_COMPONENT
502 # USAGE:
503 #   MCA_CONFIGURE_PROJECT(project_name, framework_name, component_name
504 #                         all_components_variable, 
505 #                         static_components_variable,
506 #                         dso_components_variable,
507 #                         static_ltlibs_variable,
508 #                         allowed_to_succeed,
509 #                         [eval if should build], 
510 #                         [eval if should not build])
512 ######################################################################
513 AC_DEFUN([MCA_CONFIGURE_M4_CONFIG_COMPONENT],[
514     ompi_show_subsubsubtitle "MCA component $2:$3 (m4 configuration macro)"
516     MCA_COMPONENT_BUILD_CHECK($1, $2, $3, [should_build=$8], [should_build=0])
517     # Allow the component to override the build mode if it really wants to.
518     # It is, of course, free to end up calling MCA_COMPONENT_COMPILE_MODE
519     m4_ifdef([MCA_$2_$3_COMPILE_MODE],
520              [MCA_$2_$3_COMPILE_MODE($1, $2, $3, compile_mode)],
521              [MCA_COMPONENT_COMPILE_MODE($1, $2, $3, compile_mode)])
523     # try to configure the component.  pay no attention to
524     # --enable-dist, since we'll always have makefiles.
525     AS_IF([test "$should_build" = "1"],
526           [MCA_$2_$3_CONFIG([should_build=1], 
527                             [should_build=0])])
529     AS_IF([test "$should_build" = "1"],
530           [MCA_PROCESS_COMPONENT($1, $2, $3, $4, $5, $6, $7, $compile_mode)],
531           [MCA_PROCESS_DEAD_COMPONENT($1, $2, $3)
532            # add component to all component list
533            $4="$$4 $3"])
535     # set the AM_CONDITIONAL on how we should build
536     AS_IF([test "$compile_mode" = "dso"], 
537           [BUILD_$2_$3_DSO=1],
538           [BUILD_$2_$3_DSO=0])
539     AM_CONDITIONAL(OMPI_BUILD_$2_$3_DSO, test "$BUILD_$2_$3_DSO" = "1")
541     AS_IF([test "$should_build" = "1"], [$9], [$10])
543     unset compile_mode
547 ######################################################################
549 # MCA_CONFIGURE_ALL_CONFIG_COMPONENTS
551 # configure all components in the given framework that have configure
552 # scripts and should be configured according to the usual rules...
554 # USAGE:
555 #   MCA_CONFIGURE_ALL_CONFIG_COMPONENTS(project_name, 
556 #                         framework_name,
557 #                         all_components_variable, 
558 #                         static_components_variable,
559 #                         dso_components_variable,
560 #                         static_ltlibs_variable)
562 ######################################################################
563 AC_DEFUN([MCA_CONFIGURE_ALL_CONFIG_COMPONENTS],[
564     for component_path in $srcdir/$1/mca/$2/* ; do
565         component="`basename $component_path`"
566         if test -d $component_path -a -x $component_path/configure ; then
567             ompi_show_subsubsubtitle "MCA component $2:$component (need to configure)"
569             MCA_COMPONENT_BUILD_CHECK($1, $2, $component, 
570                                       [should_build=1], [should_build=0])
571             MCA_COMPONENT_COMPILE_MODE($1, $2, $component, compile_mode)
573             if test "$should_build" = "1" ; then
574                 OMPI_CONFIG_SUBDIR([$1/mca/$2/$component],
575                                    [$ompi_subdir_args],
576                                    [should_build=1], [should_build=2])
577             fi
579             if test "$should_build" = "1" ; then
580                 MCA_PROCESS_COMPONENT($1, $2, $component, $3, $4, $5, $6, $compile_mode)
581             else
582                 MCA_PROCESS_DEAD_COMPONENT($1, $2, $component)
583             fi
584         fi
585     done
589 ######################################################################
591 # MCA_COMPONENT_COMPILE_MODE
593 # set compile_mode_variable to the compile mode for the given component
595 # USAGE:
596 #   MCA_COMPONENT_COMPILE_MODE(project_name, 
597 #                              framework_name, component_name
598 #                              compile_mode_variable)
600 #   NOTE: component_name may not be determined until runtime....
602 ######################################################################
603 AC_DEFUN([MCA_COMPONENT_COMPILE_MODE],[
604     project=$1
605     framework=$2
606     component=$3
608     # Is this component going to built staic or shared?  $component
609     # might not be known until configure time, so have to use eval
610     # tricks - can't set variable names at autogen time.
611     str="SHARED_FRAMEWORK=\$DSO_$framework"
612     eval $str
613     str="SHARED_COMPONENT=\$DSO_${framework}_$component"
614     eval $str
616     str="STATIC_FRAMEWORK=\$STATIC_$framework"
617     eval $str
618     str="STATIC_COMPONENT=\$STATIC_${framework}_$component"
619     eval $str
621     shared_mode_override=static
623     # Setup for either shared or static
624     if test "$STATIC_FRAMEWORK" = "1" -o \
625         "$STATIC_COMPONENT" = "1" -o \
626         "$STATIC_all" = "1" ; then
627         $4="static"
628     elif test "$shared_mode_override" = "dso" -o \
629         "$SHARED_FRAMEWORK" = "1" -o \
630         "$SHARED_COMPONENT" = "1" -o \
631         "$DSO_all" = "1"; then
632         $4="dso"
633     else
634         $4="static"
635     fi
637     AC_MSG_CHECKING([for MCA component $framework:$component compile mode])
638     if test "$DIRECT_$2" = "$component" ; then
639         AC_MSG_RESULT([$$4 - direct])
640     else
641         AC_MSG_RESULT([$$4])
642     fi
646 ######################################################################
648 # MCA_PROCESS_COMPONENT
650 # does all setup work for given component.  It should be known before
651 # calling that this component can build properly (and exists)
653 # USAGE:
654 #   MCA_CONFIGURE_ALL_CONFIG_COMPONENTS(project_name, 
655 #                         framework_name, component_name
656 #                         all_components_variable (4), 
657 #                         static_components_variable (5),
658 #                         dso_components_variable (6),
659 #                         static_ltlibs_variable (7),
660 #                         compile_mode_variable (8))
662 #   NOTE: component_name may not be determined until runtime....
664 ######################################################################
665 AC_DEFUN([MCA_PROCESS_COMPONENT],[
666     project=$1
667     framework=$2
668     component=$3
670     # See if it dropped an output file for us to pick up some
671     # shell variables in.  
672     infile="$srcdir/$project/mca/$framework/$component/post_configure.sh"
674     # Add this subdir to the mast list of all MCA component subdirs
675     $4="$$4 $component"
677     if test "$8" = "dso" ; then
678         $6="$$6 $component"
679     else
680         $7="mca/$framework/$component/libmca_${framework}_${component}.la $$7"
681         echo "extern const mca_base_component_t mca_${framework}_${component}_component;" >> $outfile.extern
682         echo "  &mca_${framework}_${component}_component, " >> $outfile.struct
683         $5="$$5 $component"
684     fi
686     # Output pretty results
687     AC_MSG_CHECKING([if MCA component $framework:$component can compile])
688     AC_MSG_RESULT([yes])
689     
690     # If there's an output file, add the values to
691     # scope_EXTRA_flags.
692     if test -f $infile; then
694         # First check for the ABORT tag
695         line="`grep ABORT= $infile | cut -d= -f2-`"
696         if test -n "$line" -a "$line" != "no"; then
697             AC_MSG_WARN([MCA component configure script told me to abort])
698             AC_MSG_ERROR([cannot continue])
699         fi
701         # Check for flags passed up from the component.  If we're
702         # compiling statically, then take all flags passed up from the
703         # component.
704         if test "$8" = "static"; then
705             m4_foreach(flags, [LDFLAGS, LIBS],
706                [[line="`grep WRAPPER_EXTRA_]flags[= $infile | cut -d= -f2-`"]
707                 eval "line=$line"
708                 if test -n "$line"; then
709                     $1[_WRAPPER_EXTRA_]flags[="$]$1[_WRAPPER_EXTRA_]flags[ $line"]
710                 fi
711             ])dnl
712         fi
714         dnl check for direct call header to include.  This will be
715         dnl AC_SUBSTed later.
716         if test "$DIRECT_$2" = "$component" ; then
717             if test "`grep DIRECT_CALL_HEADER $infile`" != "" ; then
718                 line="`grep DIRECT_CALL_HEADER $infile | cut -d= -f2-`"
719                 str="MCA_${framework}_DIRECT_CALL_HEADER=\\\"$line\\\""
720                 eval $str
721             else
722 AC_MSG_ERROR([*** ${framework} component ${component} was supposed to be direct-called, but
723 *** does not appear to support direct calling.
724 *** Aborting])
725             fi
726         fi
727     else
728         # were we supposed to have found something in the 
729         # post_configure.sh, but the file didn't exist?
730         if test "$DIRECT_$2" = "$component" ; then
731 AC_MSG_ERROR([*** ${framework} component ${component} was supposed to be direct-called, but
732 *** does not appear to support direct calling.
733 *** Aborting])
734         fi
735     fi
737     # now add the flags that were set in the environment variables
738     # framework_component_FOO (for example, the flags set by
739     # m4_configure components)
740     #
741     # Check for flags passed up from the component.  If we're
742     # compiling statically, then take all flags passed up from the
743     # component.
744     if test "$8" = "static"; then
745         m4_foreach(flags, [LDFLAGS, LIBS],
746             [[str="line=\$${framework}_${component}_WRAPPER_EXTRA_]flags["]
747              eval "$str"
748              if test -n "$line" ; then
749                  $1[_WRAPPER_EXTRA_]flags[="$]$1[_WRAPPER_EXTRA_]flags[ $line"]
750              fi
751              ])dnl
752     fi
756 ######################################################################
758 # MCA_PROCESS_DEAD_COMPONENT
760 # process a component that can not be built.  Do the last minute checks
761 # to make sure the user isn't doing something stupid.
763 # USAGE:
764 #   MCA_PROCESS_DEAD_COMPONENT(project_name, 
765 #                         framework_name, component_name)
767 #   NOTE: component_name may not be determined until runtime....
769 ######################################################################
770 AC_DEFUN([MCA_PROCESS_DEAD_COMPONENT],[
771     AC_MSG_CHECKING([if MCA component $2:$3 can compile])
772     AC_MSG_RESULT([no])
774     # If this component was requested as the default for this
775     # type, then abort.
776     if test "$with_$2" = "$3" ; then
777         AC_MSG_WARN([MCA component "$3" failed to configure properly])
778         AC_MSG_WARN([This component was selected as the default])
779         AC_MSG_ERROR([Cannot continue])
780         exit 1
781     fi
783     if test ! -z "$DIRECT_$2" ; then
784         if test "$DIRECT_$2" = "$3" ; then
785             AC_MSG_WARN([MCA component "$3" failed to configure properly])
786             AC_MSG_WARN([This component was selected as the default (direct call)])
787             AC_MSG_ERROR([Cannot continue])
788             exit 1
789         fi
790     fi
795 ######################################################################
797 # MCA_COMPONENT_BUILD_CHECK
799 # checks the standard rules of component building to see if the 
800 # given component should be built.
802 # USAGE:
803 #    MCA_COMPONENT_BUILD_CHECK(project, framework, component, 
804 #                              action-if-build, action-if-not-build)
806 ######################################################################
807 AC_DEFUN([MCA_COMPONENT_BUILD_CHECK],[
808     project=$1
809     framework=$2
810     component=$3
811     component_path="$srcdir/$project/mca/$framework/$component"
812     want_component=0
814     # build if:
815     # - the component type is direct and we are that component
816     # - there is no ompi_ignore file
817     # - there is an ompi_ignore, but there is an empty ompi_unignore
818     # - there is an ompi_ignore, but username is in ompi_unignore
819     if test -d $component_path ; then
820         # decide if we want the component to be built or not.  This
821         # is spread out because some of the logic is a little complex
822         # and test's syntax isn't exactly the greatest.  We want to
823         # build the component by default.
824         want_component=1
825         if test -f $component_path/.ompi_ignore ; then
826             # If there is an ompi_ignore file, don't build
827             # the component.  Note that this decision can be
828             # overriden by the unignore logic below.
829             want_component=0
830         fi
831         if test -f $component_path/.ompi_unignore ; then
832             # if there is an empty ompi_unignore, that is
833             # equivalent to having your userid in the unignore file.
834             # If userid is in the file, unignore the ignore file.
835             if test ! -s $component_path/.ompi_unignore ; then
836                 want_component=1
837             elif test ! -z "`grep $USER $component_path/.ompi_unignore`" ; then
838                 want_component=1
839             fi
840         fi
841         # if this component type is direct and we are not it, we don't want
842         # to be built.  Otherwise, we do want to be built.
843         if test ! -z "$DIRECT_$2" ; then
844             if test "$DIRECT_$2" = "$component" ; then
845                 want_component=1
846             else
847                 want_component=0
848             fi
849         fi
850     fi
852     # if we were explicitly disabled, don't build :)
853     str="DISABLED_COMPONENT_CHECK=\$DISABLE_${framework}_$component"
854     eval $str
855     if test "$DISABLED_COMPONENT_CHECK" = "1" ; then
856         want_component=0
857     fi
859     AS_IF([test "$want_component" = "1"], [$4], [$5])
863 ######################################################################
865 # MCA_SETUP_DIRECT_CALL
867 # Do all the things necessary to setup the given framework for direct
868 # call building
870 # USAGE:
871 #   MCA_SETUP_DIRECT_CALL(framework, project)
873 ######################################################################
874 AC_DEFUN([MCA_SETUP_DIRECT_CALL],[
875     if test ! -z "$DIRECT_$1" ; then
876         MCA_$1_DIRECT_CALL_COMPONENT=$DIRECT_$1
877         MCA_$1_DIRECT_CALL=1
878     else
879         MCA_$1_DIRECT_CALL_COMPONENT=
880         MCA_$1_DIRECT_CALL=0
881     fi
883     AC_SUBST(MCA_$1_DIRECT_CALL_HEADER)
884     AC_DEFINE_UNQUOTED([MCA_$1_DIRECT_CALL], [$MCA_$1_DIRECT_CALL],
885             [Defined to 1 if $1 should use direct calls instead of components])
886     AC_DEFINE_UNQUOTED([MCA_$1_DIRECT_CALL_COMPONENT], [$MCA_$1_DIRECT_CALL_COMPONENT],
887             [name of component to use for direct calls, if MCA_$1_DIRECT_CALL is 1])
888     MCA_WRITE_DIRECT_CALL_HEADER($1, $2)
890 AC_DEFUN([MCA_WRITE_DIRECT_CALL_HEADER],[
891     AC_CONFIG_FILES($2/mca/$1/$1_direct_call.h.tmp:$2/mca/$1/$1_direct_call.h.in)
892     AC_CONFIG_COMMANDS($1-direct,
893 [if test -f "$2/mca/$1/$1_direct_call"; then
894   diff "$2/mca/$1/$1_direct_call.h" "$2/mca/$1/$1_direct_call.h.tmp" > /dev/null 2>&1
895   if test "$?" != "0"; then
896     cp "$2/mca/$1/$1_direct_call.h.tmp" "$2/mca/$1/$1_direct_call.h"
897     echo "config.status: regenerating $2/mca/$1/$1_direct_call.h"
898   else
899     echo "config.status: $2/mca/$1/$1_direct_call.h unchanged"
900   fi
901 else
902   cp "$2/mca/$1/$1_direct_call.h.tmp" "$2/mca/$1/$1_direct_call.h"
903   echo "config.status: creating $2/mca/$1/$1_direct_call.h"
905 rm $2/mca/$1/$1_direct_call.h.tmp])
909 # OMPI_MCA_MAKE_DIR_LIST(subst'ed variable, framework, shell list)
910 # -------------------------------------------------------------------------
911 AC_DEFUN([OMPI_MCA_MAKE_DIR_LIST],[
912     $1=
913     for item in $3 ; do
914        $1="$$1 mca/$2/$item"
915     done
916     AC_SUBST($1)