2010-10-20 02:45:54 +04:00
|
|
|
#! @PERL@ -w
|
2009-10-21 03:46:46 +04:00
|
|
|
# -*- perl -*-
|
|
|
|
#
|
2010-10-20 02:45:54 +04:00
|
|
|
# Note that we use an interpreter value ("PERL") from configure
|
|
|
|
# because even "#!/usr/bin/env perl" to all systems (e.g., NetBSD).
|
|
|
|
#
|
2015-02-20 19:41:51 +03:00
|
|
|
# Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved.
|
2010-09-22 05:11:40 +04:00
|
|
|
# Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
|
2009-10-21 03:46:46 +04:00
|
|
|
# $COPYRIGHT$
|
2010-09-22 05:11:40 +04:00
|
|
|
#
|
2009-10-21 03:46:46 +04:00
|
|
|
# Additional copyrights may follow
|
2010-09-22 05:11:40 +04:00
|
|
|
#
|
2009-10-21 03:46:46 +04:00
|
|
|
# $HEADER$
|
|
|
|
#
|
|
|
|
|
|
|
|
use File::Basename;
|
|
|
|
use File::Spec::Functions;
|
|
|
|
|
2009-10-24 05:04:35 +04:00
|
|
|
my $includedir = "@ORTE_WRAPPER_INCLUDEDIR@";
|
|
|
|
my $libdir = "@ORTE_WRAPPER_LIBDIR@";
|
2009-10-21 03:46:46 +04:00
|
|
|
|
|
|
|
# obey the OPAL_DESTDIR environment variable
|
|
|
|
if (exists($ENV{'OPAL_DESTDIR'})
|
|
|
|
&& defined($ENV{'OPAL_DESTDIR'})
|
|
|
|
&& (length($ENV{'OPAL_DESTDIR'}) > 0)) {
|
|
|
|
my $ddir = $ENV{'OPAL_DESTDIR'};
|
|
|
|
|
|
|
|
$includedir = catdir($ddir, $includedir);
|
|
|
|
$libdir = catdir($ddir, $libdir);
|
|
|
|
}
|
|
|
|
|
2012-11-20 23:33:14 +04:00
|
|
|
my $CC = "@WRAPPER_CC@";
|
2009-10-21 03:46:46 +04:00
|
|
|
my $CXX = "@CXX@";
|
|
|
|
my $extra_cppflags = "@ORTE_WRAPPER_EXTRA_CPPFLAGS@";
|
|
|
|
my $extra_cflags = "@ORTE_WRAPPER_EXTRA_CFLAGS@";
|
2010-09-22 05:11:40 +04:00
|
|
|
my $extra_cflags_prefix = "@ORTE_WRAPPER_EXTRA_CFLAGS_PREFIX@";
|
2009-10-21 03:46:46 +04:00
|
|
|
my $extra_cxxflags = "@ORTE_WRAPPER_EXTRA_CXXFLAGS@";
|
2010-09-22 05:11:40 +04:00
|
|
|
my $extra_cxxflags_prefix = "@ORTE_WRAPPER_EXTRA_CXXFLAGS_PREFIX@";
|
2009-10-21 03:46:46 +04:00
|
|
|
my $extra_ldflags = "@ORTE_WRAPPER_EXTRA_LDFLAGS@";
|
|
|
|
my $extra_libs = "@ORTE_WRAPPER_EXTRA_LIBS@";
|
|
|
|
#my $cxx_lib = "@ORTE_WRAPPER_CXX_LIB@";
|
|
|
|
|
|
|
|
# Someone might want to fix for windows
|
|
|
|
my $include_flag = "-I";
|
|
|
|
my $libdir_flag = "-L";
|
|
|
|
|
|
|
|
my $lang = "none";
|
|
|
|
my $comp = ""; # this is a sentinal from configure
|
|
|
|
my $preproc_flags = $include_flag . $includedir;
|
|
|
|
my $comp_flags = "";
|
2010-09-22 05:11:40 +04:00
|
|
|
my $comp_flags_prefix = "";
|
2009-10-21 03:46:46 +04:00
|
|
|
my $linker_flags = $libdir_flag . $libdir . " " . $extra_ldflags;
|
2014-10-22 01:59:07 +04:00
|
|
|
my $libs = "-lopen-rte -lopen-pal " . $extra_libs;
|
2009-10-21 03:46:46 +04:00
|
|
|
|
|
|
|
|
|
|
|
sub check_env {
|
|
|
|
my $envvar = shift;
|
|
|
|
my $str = shift;
|
|
|
|
|
|
|
|
foreach my $var (("OMPI_MPI", "OMPI_")) {
|
|
|
|
my $testvar = $var . $envvar;
|
|
|
|
if (exists($ENV{$testvar})) {
|
|
|
|
$str = $ENV{$testvar};
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (basename($0) eq "ortecc") {
|
|
|
|
$lang = "C";
|
|
|
|
$comp = check_env("CC", $CC);
|
|
|
|
$comp_flags = $extra_cflags;
|
2010-09-22 05:11:40 +04:00
|
|
|
$comp_flags_prefix = $extra_cflags_prefix;
|
2009-10-21 03:46:46 +04:00
|
|
|
# no special libs for C
|
|
|
|
} elsif (basename($0) eq "ortec++") {
|
|
|
|
$lang = "C++";
|
|
|
|
$comp = check_env("CXX", $CXX);
|
|
|
|
$comp_flags = $extra_cxxflags;
|
2010-09-22 05:11:40 +04:00
|
|
|
$comp_flags_prefix = $extra_cxxflags_prefix;
|
2009-10-21 03:46:46 +04:00
|
|
|
# $libs = $cxx_lib . " " . $libs;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($lang eq "none") {
|
|
|
|
print "Could not determine requested language\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
if ($comp eq "") {
|
|
|
|
print "Unfortunately, this installation of Open RTE was not compiled with\n";
|
|
|
|
print $lang . " support. As such, the " . $lang . " compiler is non-functional.\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
# figure out what user wants
|
|
|
|
my @args = @ARGV;
|
|
|
|
my $want_preproc = 1;
|
|
|
|
my $want_compile = 1;
|
|
|
|
my $want_link = 1;
|
|
|
|
my $want_pmpi = 0;
|
|
|
|
my $dry_run = 0;
|
|
|
|
my $disable_flags = 1;
|
|
|
|
my $real_flag = 0;
|
|
|
|
my @appargs = ();
|
|
|
|
|
|
|
|
while (scalar(@args) > 0) {
|
|
|
|
my $arg = shift(@args);
|
|
|
|
|
2012-12-14 20:34:20 +04:00
|
|
|
if ($arg eq "-showme" || $arg eq "--showme") {
|
2009-10-21 03:46:46 +04:00
|
|
|
$dry_run = 1;
|
2012-12-14 20:34:20 +04:00
|
|
|
} elsif ($arg eq "--openmpi:linkall") {
|
|
|
|
# Nothing to do -- the orte wrapper script already links both
|
|
|
|
# the ORTE and OPAL libs.
|
|
|
|
next;
|
2009-10-21 03:46:46 +04:00
|
|
|
} else {
|
|
|
|
if ($arg eq "-c") {
|
|
|
|
$want_link = 0;
|
|
|
|
$real_flag = 1;
|
|
|
|
} elsif ($arg eq "-E" || $arg eq "-M") {
|
|
|
|
$want_compile = 0;
|
|
|
|
$want_link = 0;
|
|
|
|
$real_flag = 1;
|
|
|
|
} elsif ($arg eq "-S") {
|
|
|
|
$want_link = 0;
|
|
|
|
$real_flag = 1;
|
|
|
|
} elsif ($arg =~ /^-.*/) {
|
|
|
|
$real_flag = 1;
|
|
|
|
} else {
|
|
|
|
$real_flag = 1;
|
|
|
|
$disable_flags = 0;
|
|
|
|
}
|
|
|
|
push(@appargs, $arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($disable_flags == 1 && !($dry_run == 1 && $real_flag == 0)) {
|
|
|
|
$want_preproc = $want_compile = $want_link = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
my @exec_argv = ();
|
|
|
|
|
|
|
|
# assemble command
|
|
|
|
push(@exec_argv, split(' ', $comp));
|
2010-09-22 05:11:40 +04:00
|
|
|
# Per tickets https://svn.open-mpi.org/trac/ompi/ticket/2474, and
|
|
|
|
# https://svn.open-mpi.org/trac/ompi/ticket/2201, construct command
|
|
|
|
# with some system arguments before user arguments and some after.
|
|
|
|
if ($want_compile == 1) {
|
|
|
|
push(@exec_argv, split(' ', $comp_flags_prefix));
|
|
|
|
}
|
2010-01-30 01:51:35 +03:00
|
|
|
push(@exec_argv, @appargs);
|
2009-10-21 03:46:46 +04:00
|
|
|
if ($want_preproc == 1) {
|
|
|
|
push(@exec_argv, split(' ', $preproc_flags));
|
|
|
|
}
|
|
|
|
if ($want_compile == 1) {
|
|
|
|
push(@exec_argv, split(' ', $comp_flags));
|
|
|
|
}
|
|
|
|
if ($want_link == 1) {
|
|
|
|
push(@exec_argv, split(' ', $linker_flags));
|
|
|
|
push(@exec_argv, split(' ', $libs));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($dry_run == 1) {
|
|
|
|
print join(" ", @exec_argv) . "\n";
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$cmd = shift(@exec_argv);
|
|
|
|
if ($real_flag == 0) {
|
|
|
|
@exec_argv = ();
|
|
|
|
}
|
|
|
|
exec($cmd, (@exec_argv)) || die "Could not exec " . $exec_argv[0] . ": $!\n";
|