2004-01-12 10:21:20 +03:00
|
|
|
//
|
2005-11-05 22:57:48 +03:00
|
|
|
// Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
// University Research and Technology
|
|
|
|
// Corporation. All rights reserved.
|
|
|
|
// Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
// of Tennessee Research Foundation. All rights
|
|
|
|
// reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
// Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
// University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
// Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
// All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
// $COPYRIGHT$
|
|
|
|
//
|
|
|
|
// Additional copyrights may follow
|
|
|
|
//
|
2004-01-12 10:21:20 +03:00
|
|
|
// $HEADER$
|
|
|
|
//
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
|
|
|
#include "tools/wrappers/ompi_wrap.h"
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2005-12-20 02:31:42 +03:00
|
|
|
#include <iostream>
|
2004-01-12 10:21:20 +03:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Back-end entry point for the wrapper compiler functionality. All
|
|
|
|
/// three wrapper compilers invoke this function.
|
|
|
|
///
|
|
|
|
/// \param argc Number of command line arguments
|
|
|
|
/// \param argv Vector containing command line arguments
|
|
|
|
/// \param env_vars Environment variables
|
|
|
|
/// \param default_compiler The default backend compiler
|
|
|
|
/// \param want_cxx_libs Whether C++ libraries should be linked in
|
|
|
|
/// \param want_f77_includes Whether F77 include path should be added
|
|
|
|
/// \param extra_args Extra arguments which need to be added
|
|
|
|
///
|
2004-09-25 23:31:17 +04:00
|
|
|
/// At most, we end up with a command line in the following form:
|
|
|
|
///
|
|
|
|
/// [compiler(*)] [Xppflags(*)] [Xflags(*)] [user args] [ldflags(*)] [libs(*)]
|
|
|
|
///
|
|
|
|
/// Items with (*) can be overridden at run time with environment variables.
|
|
|
|
///
|
|
|
|
/// X can be replaced with C, CXX, F, and FC for C, C++, Fortran 77,
|
|
|
|
/// and Fortran 90, respectively.
|
|
|
|
///
|
2004-01-12 10:21:20 +03:00
|
|
|
int
|
2004-09-25 23:31:17 +04:00
|
|
|
ompi_wrap_engine(int argc, char *argv[],
|
|
|
|
const ompi_sv_t & compiler_env_var,
|
|
|
|
const ompi_sv_t & xppflags_env_var,
|
|
|
|
const ompi_sv_t & xflags_env_var,
|
|
|
|
const ompi_sv_t & ldflags_env_var,
|
|
|
|
const ompi_sv_t & libs_env_var,
|
|
|
|
const std::string & default_compiler,
|
|
|
|
const std::string & default_xflags,
|
2005-04-13 15:54:36 +04:00
|
|
|
bool want_cxx_libs,
|
|
|
|
bool want_f90_libs,
|
|
|
|
bool want_f77_includes)
|
2004-01-12 10:21:20 +03:00
|
|
|
{
|
2004-09-25 23:31:17 +04:00
|
|
|
int ret(0);
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
bool want_flags;
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
ompi_sv_t str_vec;
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
ompi_sv_t compiler;
|
|
|
|
ompi_sv_t xppflags;
|
|
|
|
ompi_sv_t xflags;
|
|
|
|
ompi_sv_t user_args;
|
|
|
|
ompi_sv_t ldflags;
|
|
|
|
ompi_sv_t libs;
|
|
|
|
ompi_sv_t extra_flags;
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
ompi_sv_t cmd_line;
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
// Parse command line
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
ompi_wrap_parse_args(argc, argv, want_flags);
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
// Get the compiler
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
ompi_wrap_get_compiler(compiler_env_var, default_compiler, compiler);
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
// Build the XPPFLAGS (-I stuff only)
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
ompi_wrap_build_xppflags(xppflags_env_var, want_f77_includes,
|
|
|
|
xppflags);
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
// Build any XFLAGS
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
ompi_wrap_build_xflags(xflags_env_var, default_xflags, xflags);
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
// Build the user arguments
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
ompi_wrap_build_user_args(argc, argv, user_args);
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
// Build the LDFLAGS (-L stuff and WRAPPER_EXTRA_LDFLAGS)
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
ompi_wrap_build_ldflags(ldflags_env_var, ldflags);
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
// Build the LIBS (-l stuff and WRAPPER_EXTRA_LIBS)
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2005-04-13 15:54:36 +04:00
|
|
|
ompi_wrap_build_libs(libs_env_var, want_cxx_libs, want_f90_libs, libs);
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
// Now assemble the command line
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
cmd_line.clear();
|
|
|
|
ompi_wrap_append_sv(compiler, cmd_line);
|
|
|
|
if (want_flags) {
|
|
|
|
ompi_wrap_append_sv(xppflags, cmd_line);
|
|
|
|
ompi_wrap_append_sv(xflags, cmd_line);
|
|
|
|
}
|
|
|
|
ompi_wrap_append_sv(user_args, cmd_line);
|
|
|
|
if (want_flags) {
|
|
|
|
ompi_wrap_append_sv(ldflags, cmd_line);
|
|
|
|
ompi_wrap_append_sv(libs, cmd_line);
|
|
|
|
}
|
|
|
|
// Display or execute?
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
if (showme_cmd) {
|
|
|
|
ompi_wrap_print_sv(compiler);
|
|
|
|
}
|
|
|
|
if (showme_cmd || showme_compile) {
|
|
|
|
ompi_wrap_print_sv(xppflags);
|
|
|
|
ompi_wrap_print_sv(xflags);
|
|
|
|
}
|
|
|
|
if (showme_cmd || showme_compile || showme_link)
|
|
|
|
ompi_wrap_print_sv(user_args);
|
|
|
|
if (showme_cmd || showme_link) {
|
|
|
|
ompi_wrap_print_sv(ldflags);
|
|
|
|
ompi_wrap_print_sv(libs);
|
|
|
|
}
|
|
|
|
if (showme_cmd || showme_compile || showme_link) {
|
|
|
|
cout << endl;
|
|
|
|
} else {
|
|
|
|
ret = ompi_wrap_exec_sv(cmd_line);
|
|
|
|
}
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
// That's all she wrote
|
2004-01-12 10:21:20 +03:00
|
|
|
|
2004-09-25 23:31:17 +04:00
|
|
|
return ret;
|
2004-01-12 10:21:20 +03:00
|
|
|
}
|