2121#include "opal/mca/installdirs/installdirs.h"
2222#include "opal/mca/mca.h"
2323
24+ #include <sys/stat.h>
25+ #include <errno.h>
26+
2427opal_install_dirs_t opal_install_dirs = {0 };
28+ static int opal_install_dir_warn_if_non_existent = 0 ;
2529
2630#define CONDITIONAL_COPY (target , origin , field ) \
2731 do { \
@@ -30,6 +34,23 @@ opal_install_dirs_t opal_install_dirs = {0};
3034 } \
3135 } while (0)
3236
37+ #define CHECK_AND_COMPLAIN (field ) \
38+ do { \
39+ if(!directory_exists(opal_install_dirs.field)) { \
40+ fprintf(stderr, #field ": %s\n", opal_install_dirs.field); \
41+ } \
42+ } while (0)
43+
44+ static int directory_exists (const char * path )
45+ {
46+ struct stat info ;
47+
48+ if (0 != stat (path , & info )) {
49+ return 0 ;
50+ }
51+ return S_ISDIR (info .st_mode );
52+ }
53+
3354static int opal_installdirs_base_open (mca_base_open_flag_t flags )
3455{
3556 mca_base_component_list_item_t * component_item ;
@@ -87,26 +108,30 @@ static int opal_installdirs_base_open(mca_base_open_flag_t flags)
87108 opal_install_dirs .opalincludedir = opal_install_dirs_expand_setup (
88109 opal_install_dirs .opalincludedir );
89110
90- #if 0
91- fprintf (stderr , "prefix: %s\n" , opal_install_dirs .prefix );
92- fprintf (stderr , "exec_prefix: %s\n" , opal_install_dirs .exec_prefix );
93- fprintf (stderr , "bindir: %s\n" , opal_install_dirs .bindir );
94- fprintf (stderr , "sbindir: %s\n" , opal_install_dirs .sbindir );
95- fprintf (stderr , "libexecdir: %s\n" , opal_install_dirs .libexecdir );
96- fprintf (stderr , "datarootdir: %s\n" , opal_install_dirs .datarootdir );
97- fprintf (stderr , "datadir: %s\n" , opal_install_dirs .datadir );
98- fprintf (stderr , "sysconfdir: %s\n" , opal_install_dirs .sysconfdir );
99- fprintf (stderr , "sharedstatedir: %s\n" , opal_install_dirs .sharedstatedir );
100- fprintf (stderr , "localstatedir: %s\n" , opal_install_dirs .localstatedir );
101- fprintf (stderr , "libdir: %s\n" , opal_install_dirs .libdir );
102- fprintf (stderr , "includedir: %s\n" , opal_install_dirs .includedir );
103- fprintf (stderr , "infodir: %s\n" , opal_install_dirs .infodir );
104- fprintf (stderr , "mandir: %s\n" , opal_install_dirs .mandir );
105- fprintf (stderr , "pkgdatadir: %s\n" , opal_install_dirs .pkgdatadir );
106- fprintf (stderr , "pkglibdir: %s\n" , opal_install_dirs .pkglibdir );
107- fprintf (stderr , "pkgincludedir: %s\n" , opal_install_dirs .pkgincludedir );
108- #endif
111+ (void )mca_base_var_register ("opal" , "opal" , "installdir" , "warn" ,
112+ "Print a warning is any of the OMPI necessary paths cannot be found" ,
113+ MCA_BASE_VAR_TYPE_INT , NULL , 0 , 0 , OPAL_INFO_LVL_9 ,
114+ MCA_BASE_VAR_SCOPE_READONLY , & opal_install_dir_warn_if_non_existent );
109115
116+ if (opal_install_dir_warn_if_non_existent ) {
117+ CHECK_AND_COMPLAIN (prefix );
118+ CHECK_AND_COMPLAIN (exec_prefix );
119+ CHECK_AND_COMPLAIN (bindir );
120+ //CHECK_AND_COMPLAIN(sbindir);
121+ //CHECK_AND_COMPLAIN(libexecdir);
122+ CHECK_AND_COMPLAIN (datarootdir );
123+ CHECK_AND_COMPLAIN (datadir );
124+ CHECK_AND_COMPLAIN (sysconfdir );
125+ //CHECK_AND_COMPLAIN(sharedstatedir);
126+ //CHECK_AND_COMPLAIN(localstatedir);
127+ CHECK_AND_COMPLAIN (libdir );
128+ CHECK_AND_COMPLAIN (includedir );
129+ //CHECK_AND_COMPLAIN(infodir);
130+ CHECK_AND_COMPLAIN (mandir );
131+ CHECK_AND_COMPLAIN (opaldatadir );
132+ CHECK_AND_COMPLAIN (opallibdir );
133+ CHECK_AND_COMPLAIN (opalincludedir );
134+ }
110135 /* NTH: Is it ok not to close the components? If not we can add a flag
111136 to mca_base_framework_components_close to indicate not to deregister
112137 variable groups */
0 commit comments