static void
expand_flags(char **argv)
{
    int i;
    char *tmp;

    for (i = 0 ; argv[i] != NULL ; ++i) {
        tmp = opal_install_dirs_expand(argv[i]);
        if (tmp != argv[i]) {
            free(argv[i]);
            argv[i] = tmp;
        }
    }
}
int
opal_installdirs_base_open(void)
{
    int i, ret;
    mca_base_component_list_item_t *cli;

    OBJ_CONSTRUCT(&opal_installdirs_components, opal_list_t);
    for (i = 0 ; mca_installdirs_base_static_components[i] != NULL ; ++i) {
        opal_installdirs_base_component_t *component = 
            (opal_installdirs_base_component_t*) 
            mca_installdirs_base_static_components[i];

        /* Save it in a global list for ompi_info */
        cli = OBJ_NEW(mca_base_component_list_item_t);
        cli->cli_component = mca_installdirs_base_static_components[i];
        opal_list_append(&opal_installdirs_components, 
                         &cli->super);

        if (NULL != component->component.mca_open_component) {
            ret = component->component.mca_open_component();
            if (OPAL_SUCCESS != ret) continue;
        }

        /* copy over the data, if something isn't already there */
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data, 
                         prefix);
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data,
                         exec_prefix);
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data,
                         bindir);
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data,
                         sbindir);
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data,
                         libexecdir);
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data,
                         datarootdir);
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data,
                         datadir);
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data, 
                         sysconfdir);
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data, 
                         sharedstatedir);
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data, 
                         localstatedir);
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data, 
                         libdir);
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data, 
                         includedir);
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data, 
                         infodir);
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data, 
                         mandir);
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data,
                         pkgdatadir);
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data, 
                         pkglibdir);
        CONDITIONAL_COPY(opal_install_dirs, component->install_dirs_data, 
                         pkgincludedir);
    }

    /* expand out all the fields */
    opal_install_dirs.prefix = 
        opal_install_dirs_expand(opal_install_dirs.prefix);
    opal_install_dirs.exec_prefix = 
        opal_install_dirs_expand(opal_install_dirs.exec_prefix);
    opal_install_dirs.bindir = 
        opal_install_dirs_expand(opal_install_dirs.bindir);
    opal_install_dirs.sbindir = 
        opal_install_dirs_expand(opal_install_dirs.sbindir);
    opal_install_dirs.libexecdir = 
        opal_install_dirs_expand(opal_install_dirs.libexecdir);
    opal_install_dirs.datarootdir = 
        opal_install_dirs_expand(opal_install_dirs.datarootdir);
    opal_install_dirs.datadir = 
        opal_install_dirs_expand(opal_install_dirs.datadir);
    opal_install_dirs.sysconfdir = 
        opal_install_dirs_expand(opal_install_dirs.sysconfdir);
    opal_install_dirs.sharedstatedir = 
        opal_install_dirs_expand(opal_install_dirs.sharedstatedir);
    opal_install_dirs.localstatedir = 
        opal_install_dirs_expand(opal_install_dirs.localstatedir);
    opal_install_dirs.libdir = 
        opal_install_dirs_expand(opal_install_dirs.libdir);
    opal_install_dirs.includedir = 
        opal_install_dirs_expand(opal_install_dirs.includedir);
    opal_install_dirs.infodir = 
        opal_install_dirs_expand(opal_install_dirs.infodir);
    opal_install_dirs.mandir = 
        opal_install_dirs_expand(opal_install_dirs.mandir);
    opal_install_dirs.pkgdatadir = 
        opal_install_dirs_expand(opal_install_dirs.pkgdatadir);
    opal_install_dirs.pkglibdir = 
        opal_install_dirs_expand(opal_install_dirs.pkglibdir);
    opal_install_dirs.pkgincludedir = 
        opal_install_dirs_expand(opal_install_dirs.pkgincludedir);

#if 0
    fprintf(stderr, "prefix:         %s\n", opal_install_dirs.prefix);
    fprintf(stderr, "exec_prefix:    %s\n", opal_install_dirs.exec_prefix);
    fprintf(stderr, "bindir:         %s\n", opal_install_dirs.bindir);
    fprintf(stderr, "sbindir:        %s\n", opal_install_dirs.sbindir);
    fprintf(stderr, "libexecdir:     %s\n", opal_install_dirs.libexecdir);
    fprintf(stderr, "datarootdir:    %s\n", opal_install_dirs.datarootdir);
    fprintf(stderr, "datadir:        %s\n", opal_install_dirs.datadir);
    fprintf(stderr, "sysconfdir:     %s\n", opal_install_dirs.sysconfdir);
    fprintf(stderr, "sharedstatedir: %s\n", opal_install_dirs.sharedstatedir);
    fprintf(stderr, "localstatedir:  %s\n", opal_install_dirs.localstatedir);
    fprintf(stderr, "libdir:         %s\n", opal_install_dirs.libdir);
    fprintf(stderr, "includedir:     %s\n", opal_install_dirs.includedir);
    fprintf(stderr, "infodir:        %s\n", opal_install_dirs.infodir);
    fprintf(stderr, "mandir:         %s\n", opal_install_dirs.mandir);
    fprintf(stderr, "pkgdatadir:     %s\n", opal_install_dirs.pkgdatadir);
    fprintf(stderr, "pkglibdir:      %s\n", opal_install_dirs.pkglibdir);
    fprintf(stderr, "pkgincludedir:  %s\n", opal_install_dirs.pkgincludedir);
#endif

    for (i = 0 ; mca_installdirs_base_static_components[i] != NULL ; ++i) {
        if (NULL !=  mca_installdirs_base_static_components[i]->mca_close_component) {
            mca_installdirs_base_static_components[i]->mca_close_component();
        }
    }

    return OPAL_SUCCESS;
}
static void
data_callback(const char *key, const char *value)
{
    /* handle case where text file does not contain any special
       compiler options field */
    if (parse_options_idx < 0 && 0 != strcmp(key, "compiler_args")) {
        options_data_expand(NULL);
    }

    if (0 == strcmp(key, "compiler_args")) {
        options_data_expand(value);
    } else if (0 == strcmp(key, "language")) {
        if (NULL != value) options_data[parse_options_idx].language = strdup(value);
    } else if (0 == strcmp(key, "compiler")) {
        if (NULL != value) options_data[parse_options_idx].compiler = strdup(value);
    } else if (0 == strcmp(key, "project")) {
        if (NULL != value) options_data[parse_options_idx].project = strdup(value);
    } else if (0 == strcmp(key, "version")) {
        if (NULL != value) options_data[parse_options_idx].version = strdup(value);
    } else if (0 == strcmp(key, "module_option")) {
        if (NULL != value) options_data[parse_options_idx].module_option = strdup(value);
    } else if (0 == strcmp(key, "extra_includes")) {
        if (NULL != value) options_data[parse_options_idx].extra_includes = strdup(value);
        if (NULL != value && NULL != options_data[parse_options_idx].path_includedir) {
            /* includedir already found -- we now have both pieces of information, and the
               includedir code didn't do this because it didn't have the extra includes */
            add_extra_includes(value, options_data[parse_options_idx].path_includedir);
        }
    } else if (0 == strcmp(key, "preprocessor_flags")) {
        char **values = opal_argv_split(value, ' ');
        opal_argv_insert(&options_data[parse_options_idx].preproc_flags, 
                         opal_argv_count(options_data[parse_options_idx].preproc_flags),
                         values);
        expand_flags(options_data[parse_options_idx].preproc_flags);
        opal_argv_free(values);
    } else if (0 == strcmp(key, "compiler_flags")) {
        char **values = opal_argv_split(value, ' ');
        opal_argv_insert(&options_data[parse_options_idx].comp_flags,
                         opal_argv_count(options_data[parse_options_idx].comp_flags),
                         values);
        expand_flags(options_data[parse_options_idx].comp_flags);
        opal_argv_free(values);
    } else if (0 == strcmp(key, "linker_flags")) {
        char **values = opal_argv_split(value, ' ');
        opal_argv_insert(&options_data[parse_options_idx].link_flags,
                         opal_argv_count(options_data[parse_options_idx].link_flags),
                         values);
        expand_flags(options_data[parse_options_idx].link_flags);
        opal_argv_free(values);
    } else if (0 == strcmp(key, "libs")) {
        char **values = opal_argv_split(value, ' ');
        opal_argv_insert(&options_data[parse_options_idx].libs,
                         opal_argv_count(options_data[parse_options_idx].libs),
                         values);
        opal_argv_free(values);
    } else if (0 == strcmp(key, "required_file")) {
        if (NULL != value) options_data[parse_options_idx].req_file = strdup(value);
    } else if (0 == strcmp(key, "project_short")) {
        if (NULL != value) options_data[parse_options_idx].project_short = strdup(value);
    } else if (0 == strcmp(key, "compiler_env")) {
        if (NULL != value) options_data[parse_options_idx].compiler_env = strdup(value);
    } else if (0 == strcmp(key, "compiler_flags_env")) {
        if (NULL != value) options_data[parse_options_idx].compiler_flags_env = strdup(value);
    } else if (0 == strcmp(key, "includedir")) {
        if (NULL != value) {
            options_data[parse_options_idx].path_includedir =
                opal_install_dirs_expand(value);
            if (0 != strcmp(options_data[parse_options_idx].path_includedir, "/usr/include") ||
                0 == strncmp(options_data[parse_options_idx].language, "Fortran", strlen("Fortran"))) {
                char *line;
#if defined(__WINDOWS__)
                asprintf(&line, OPAL_INCLUDE_FLAG"\"%s\"", 
                         options_data[parse_options_idx].path_includedir);
#else
                asprintf(&line, OPAL_INCLUDE_FLAG"%s", 
                         options_data[parse_options_idx].path_includedir);
#endif  /* defined(__WINDOWS__) */
                opal_argv_append_nosize(&options_data[parse_options_idx].preproc_flags, line);
                free(line);
            }
            /* Now that we have an include dir, see if we already have
               the extra includes, so that we can post them as well */
            if (NULL != options_data[parse_options_idx].extra_includes) {
                add_extra_includes(options_data[parse_options_idx].extra_includes,
                                   options_data[parse_options_idx].path_includedir);
            }
        }
    } else if (0 == strcmp(key, "libdir")) {
        if (NULL != value) options_data[parse_options_idx].path_libdir = 
                               opal_install_dirs_expand(value);
#if defined(__WINDOWS__)
        opal_argv_append_nosize( &options_data[parse_options_idx].link_flags, "/link" );
#endif  /* defined(__WINDOWS__) */
        if (0 != strcmp(options_data[parse_options_idx].path_libdir, "/usr/lib")) {
            char *line;
#if defined(__WINDOWS__)
            asprintf(&line, OPAL_LIBDIR_FLAG"\"%s\"", 
                     options_data[parse_options_idx].path_libdir);
#else
            asprintf(&line, OPAL_LIBDIR_FLAG"%s", 
                     options_data[parse_options_idx].path_libdir);
#endif  /* defined(__WINDOWS__) */
            opal_argv_append_nosize(&options_data[parse_options_idx].link_flags, line);
            free(line);
        }
    }
}
Beispiel #4
0
static void
data_callback(const char *key, const char *value)
{
    /* handle case where text file does not contain any special
       compiler options field */
    if (parse_options_idx < 0 && 0 != strcmp(key, "compiler_args")) {
        options_data_expand(NULL);
    }

    if (0 == strcmp(key, "compiler_args")) {
        options_data_expand(value);
    } else if (0 == strcmp(key, "language")) {
        if (NULL != value) options_data[parse_options_idx].language = strdup(value);
    } else if (0 == strcmp(key, "compiler")) {
        if (NULL != value) options_data[parse_options_idx].compiler = strdup(value);
    } else if (0 == strcmp(key, "project")) {
        if (NULL != value) options_data[parse_options_idx].project = strdup(value);
    } else if (0 == strcmp(key, "version")) {
        if (NULL != value) options_data[parse_options_idx].version = strdup(value);
    } else if (0 == strcmp(key, "preprocessor_flags")) {
        char **values = opal_argv_split(value, ' ');
        opal_argv_insert(&options_data[parse_options_idx].preproc_flags, 
                         opal_argv_count(options_data[parse_options_idx].preproc_flags),
                         values);
        expand_flags(options_data[parse_options_idx].preproc_flags);
        opal_argv_free(values);
    } else if (0 == strcmp(key, "compiler_flags")) {
        char **values = opal_argv_split(value, ' ');
        opal_argv_insert(&options_data[parse_options_idx].comp_flags,
                         opal_argv_count(options_data[parse_options_idx].comp_flags),
                         values);
        expand_flags(options_data[parse_options_idx].comp_flags);
        opal_argv_free(values);
    } else if (0 == strcmp(key, "compiler_flags_prefix")) {
        char **values = opal_argv_split(value, ' ');
        opal_argv_insert(&options_data[parse_options_idx].comp_flags_prefix,
                         opal_argv_count(options_data[parse_options_idx].comp_flags_prefix),
                         values);
        expand_flags(options_data[parse_options_idx].comp_flags_prefix);
        opal_argv_free(values);
    } else if (0 == strcmp(key, "linker_flags")) {
        char **values = opal_argv_split(value, ' ');
        opal_argv_insert(&options_data[parse_options_idx].link_flags,
                         opal_argv_count(options_data[parse_options_idx].link_flags),
                         values);
        expand_flags(options_data[parse_options_idx].link_flags);
        opal_argv_free(values);
    } else if (0 == strcmp(key, "libs")) {
        char **values = opal_argv_split(value, ' ');
        opal_argv_insert(&options_data[parse_options_idx].libs,
                         opal_argv_count(options_data[parse_options_idx].libs),
                         values);
        opal_argv_free(values);
    } else if (0 == strcmp(key, "libs_static")) {
        char **values = opal_argv_split(value, ' ');
        opal_argv_insert(&options_data[parse_options_idx].libs_static,
                         opal_argv_count(options_data[parse_options_idx].libs_static),
                         values);
        opal_argv_free(values);
    } else if (0 == strcmp(key, "dyn_lib_file")) {
        if (NULL != value) options_data[parse_options_idx].dyn_lib_file = strdup(value);
    } else if (0 == strcmp(key, "static_lib_file")) {
        if (NULL != value) options_data[parse_options_idx].static_lib_file = strdup(value);
    } else if (0 == strcmp(key, "required_file")) {
        if (NULL != value) options_data[parse_options_idx].req_file = strdup(value);
    } else if (0 == strcmp(key, "project_short")) {
        if (NULL != value) options_data[parse_options_idx].project_short = strdup(value);
    } else if (0 == strcmp(key, "compiler_env")) {
        if (NULL != value) options_data[parse_options_idx].compiler_env = strdup(value);
    } else if (0 == strcmp(key, "compiler_flags_env")) {
        if (NULL != value) options_data[parse_options_idx].compiler_flags_env = strdup(value);
    } else if (0 == strcmp(key, "includedir")) {
        if (NULL != value) {
            options_data[parse_options_idx].path_includedir =
                opal_install_dirs_expand(value);
            if (0 != strcmp(options_data[parse_options_idx].path_includedir, "/usr/include") ||
                0 == strncmp(options_data[parse_options_idx].language, "Fortran", strlen("Fortran"))) {
                char *line;
                asprintf(&line, OPAL_INCLUDE_FLAG"%s", 
                         options_data[parse_options_idx].path_includedir);
                opal_argv_append_nosize(&options_data[parse_options_idx].preproc_flags, line);
                free(line);
            }
        }
    } else if (0 == strcmp(key, "libdir")) {
        if (NULL != value) options_data[parse_options_idx].path_libdir = 
                               opal_install_dirs_expand(value);
        if (0 != strcmp(options_data[parse_options_idx].path_libdir, "/usr/lib")) {
            char *line;
            asprintf(&line, OPAL_LIBDIR_FLAG"%s", 
                     options_data[parse_options_idx].path_libdir);
            opal_argv_append_nosize(&options_data[parse_options_idx].link_flags, line);
            free(line);
        }
    }
}