" "+self.inOptions.extraConfigureOptions+\
      getParallelOpt(self.inOptions, "--parallel=")+\
      " --prefix="+self.inOptions.installDir,
      extraEnv={"CXXFLAGS":"-O3", "CFLAGS":"-O3"},
      )

  def doBuild(self):
    echoChDir(self.cmakeBuildBaseDir)
    echoRunSysCmnd("make "+getParallelOpt(self.inOptions, "-j")+self.inOptions.makeOptions)

  def doInstall(self):
    echoChDir(self.cmakeBuildBaseDir)
    echoRunSysCmnd("make "+self.inOptions.makeOptions+" install")

  def getFinalInstructions(self):
    return """
To use the installed version of cmake-"""+self.inOptions.version+""" add the path:

  """+self.inOptions.installDir+"""/bin

to your path and that should be it!
"""


#
# Executable statements
#

cmakeInstaller = InstallProgramDriver(CMakeInstall())
cmakeInstaller.runDriver()
def main(cmndLineArgs):
    #
    # Get the command-line options
    #
    autoconf_version = autoconf_version_default
    cmake_version = cmake_version_default
    gcc_version = gcc_version_default
    mpich_version = mpich_version_default
    mvapich_version = mvapich_version_default
    mvapichInstalled = False
    #iterates over tools selected. If name is specified and a ':' is present, non-default version was specified. Updating install version to specified value
    #if no version was specified, default version will be installed
    inOptions = getCmndLineOptions(cmndLineArgs)
    versionList = dict()
    for toolName in inOptions.commonTools.split(','):
        if "cmake" in toolName and ':' in toolName:
            cmake_version = toolName.split(':')[1]
        elif "autoconf" in toolName and ':' in toolName:
            autoconf_version = toolName.split(':')[1]
    for toolName in inOptions.compilerToolset.split(','):
        if "gcc" in toolName and ':' in toolName:
            gcc_version = toolName.split(':')[1]
        elif "mpich" in toolName and ':' in toolName:
            mpich_version = toolName.split(':')[1]
        elif "mvapich" in toolName and ':' in toolName:
            mvapich_version = toolName.split(':')[1]
            mvapichInstalled = True

    versionList["cmake"] = cmake_version
    versionList["autoconf"] = autoconf_version
    versionList["gcc"] = gcc_version
    versionList["mpich"] = mpich_version
    versionList["mvapich"] = mvapich_version
    if inOptions.skipOp:
        print("\n***")
        print(
            "*** NOTE: --no-op provided, will only trace actions and not touch the filesystem!"
        )
        print("***\n")

    commonToolsSelected = \
      getToolsSelectedArray(inOptions.commonTools, commonToolsArray)
    print("\nSelected common tools = " + str(commonToolsSelected))
    commonToolsSelectedSet = set(commonToolsSelected)

    compilerToolsetSelected = \
      getToolsSelectedArray(inOptions.compilerToolset, compilerToolsetArray)
    print("\nSelected compiler toolset = " + str(compilerToolsetSelected))
    compilerToolsetSelectedSet = set(compilerToolsetSelected)

    dev_env_base_dir = inOptions.installDir

    ###
    print("\n\nA) Setup the install directory <dev_env_base> ='" +
          dev_env_base_dir + "':\n")
    ###

    dev_env_base_exists = os.path.exists(dev_env_base_dir)

    common_tools_dir = os.path.join(dev_env_base_dir, "common_tools")
    common_tools_exists = os.path.exists(common_tools_dir)

    compiler_toolset_base_dir = os.path.join(dev_env_base_dir,
                                             "gcc-" + gcc_version)
    compiler_toolset_base_exists = os.path.exists(compiler_toolset_base_dir)

    compiler_toolset_dir = os.path.join(compiler_toolset_base_dir, "toolset")
    compiler_toolset_exists = os.path.exists(compiler_toolset_dir)

    dev_env_dir = os.path.join(dev_env_base_dir, "env")
    dev_env_exists = os.path.exists(dev_env_dir)

    if inOptions.doInitialSetup:
        if not dev_env_base_exists:
            print("Creating directory '" + dev_env_base_dir + "' ...")
            if not inOptions.skipOp:
                os.makedirs(dev_env_base_dir)
        if not dev_env_exists and not inOptions.skipOp:
            os.makedirs(dev_env_dir)
        if not common_tools_exists:
            print("Creating directory '" + common_tools_dir + "' ...")
            if not inOptions.skipOp:
                os.makedirs(common_tools_dir)

        # Always create this directory so we can write the load_dev_env.sh script!
        if not compiler_toolset_base_exists:
            print("Creating directory '" + compiler_toolset_base_dir + "' ...")
            if not inOptions.skipOp:
                os.makedirs(compiler_toolset_base_dir)

        if not compiler_toolset_exists:
            print("Creating directory '" + compiler_toolset_dir + "' ...")
            if not inOptions.skipOp:
                os.makedirs(compiler_toolset_dir)

        print("Writing new files " + inOptions.loadDevEnvFileBaseName +
              ".[sh,csh] ...")
        if not inOptions.skipOp:
            writeLoadDevEnvFiles(dev_env_base_dir, dev_env_dir, inOptions,
                                 versionList, mvapichInstalled)

    else:

        print("Skipping setup of the install directory by request!")

        assertInstallDirExists(dev_env_base_dir, inOptions)
        assertInstallDirExists(common_tools_dir, inOptions)
        assertInstallDirExists(compiler_toolset_base_dir, inOptions)
        assertInstallDirExists(compiler_toolset_dir, inOptions)
    if not inOptions.skipOp:
        os.system("mkdir " + dev_env_base_dir + "/images")
        os.system("mkdir " + dev_env_base_dir + "/images/dev_env")
        os.system("mkdir " + dev_env_base_dir + "/images/install")
        gcc_first = gcc_version[0]
        gcc_short = str()
        for chr in gcc_version:
            if chr != '.':
                gcc_short += chr
        if mvapichInstalled:
            mpi_version = "mvapich2-" + mvapich_version
        else:
            mpi_version = "mpich-" + mpich_version
        if inOptions.mkl_true:
            mkl_true = "true"
            tpl_url = 'https://github.com/ehcole/MPACT_tpls.git'
            tpl_source_dir = "/MPACT_tpls/TPL_build/"
        else:
            mkl_true = "false"
            tpl_url = "https://github.com/CASL/vera_tpls.git"
            tpl_source_dir = "/vera_tpls/TPL_build/"
        os.system("autoconf")
        os.system(
            "./configure GCC_VERSION=gcc_version GCC_FIRST=gcc_first GCC_SHORT=gcc_short MPI_VERSION=MPI_VERSION CMAKE_VERSION=cmake_version TPL_URL=tpl_url TPL_SOURCE_DIR=tpl_source_dir MKL_TRUE=mkl_true"
        )
        os.system("mv Dockerfile " + dev_env_base_dir + "/images/dev_env")
        os.system("mv Dockerfile_install " + dev_env_base_dir +
                  "/images/install")
    ###
    print("\n\nB) Download all sources for each selected tool:\n")
    ###
    if inOptions.doDownload:
        for tool in commonToolsSelectedSet:
            if "cmake" in tool:
                print("")
                print("Downloading the source for cmake-" + cmake_version +
                      " ...")
                print("")
                cmakeShort = cmake_version[:-2]
                if not inOptions.skipOp:
                    try:
                        os.system("wget https://cmake.org/files/v" +
                                  cmakeShort + "/cmake-" + cmake_version +
                                  ".tar.gz")
                    except:
                        print(
                            "Invalid CMake version passed. No Download link found."
                        )
                        exit(1)
                    os.system("mv cmake-" + cmake_version + ".tar.gz " +
                              common_tools_dir)
                else:
                    print("wget " + dev_env_base_dir +
                          "/common_tools https://cmake.org/files/v" +
                          cmakeShort + "/cmake-" + cmake_version + ".tar.gz")
            elif "autoconf" in tool:
                downloadToolSource("autoconf", autoconf_version,
                                   inOptions.sourceGitUrlBase, inOptions)
        for tool in compilerToolsetSelectedSet:
            if "gcc" in tool:
                print("")
                print("Downloading the source for gcc-" + gcc_version + " ...")
                print("")
                if not inOptions.skipOp:
                    try:
                        os.system("wget https://ftp.gnu.org/gnu/gcc/gcc-" +
                                  gcc_version + "/gcc-" + gcc_version +
                                  ".tar.gz")
                    except:
                        print(
                            "Invalid gcc version passed. No Download link found."
                        )
                        exit(1)
                else:
                    print("wget https://ftp.gnu.org/gnu/gcc/gcc-" +
                          gcc_version + "/gcc-" + gcc_version + ".tar.gz")

            elif "mpich" in tool:
                if mpich_version == '3.1.3':
                    downloadToolSource("mpich", mpich_version,
                                       inOptions.sourceGitUrlBase, inOptions)
                else:
                    print("")
                    print("Downloading the source for mpich-" + mpich_version +
                          " ..")
                    print("")
                    if not inOptions.skipOp:
                        try:
                            os.system(
                                "wget / http://www.mpich.org/static/downloads/"
                                + mpich_version + "/mpich-" + mpich_version +
                                ".tar.gz")
                        except:
                            print(
                                "Invalid mpich version passed. No Download link found."
                            )
                            exit(1)
                    else:
                        print("wget http://www.mpich.org/static/downloads/" +
                              mpich_version + "/mpich-" + mpich_version +
                              ".tar.gz")
            elif "mvapich" in tool:
                print("")
                print("Downloading the source for mvapich-" + mvapich_version +
                      " ..")
                print("")
                if not inOptions.skipOp:
                    try:
                        os.system(
                            "wget http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-"
                            + mvapich_version + ".tar.gz")
                    except:
                        print(
                            "Invalid mvapich version passed. No Download link found."
                        )
                        exit(1)
                else:
                    print(
                        "wget/ http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-"
                        + mvapich_version + ".tar.gz")
    else:

        print("Skipping download of the source for the tools on request!")
        if inOptions.doInstall:
            print("NOTE: The downloads had better be there for the install!")

    ###
    print("\n\nC) Untar, configure, build and install each selected tool:\n")
    ###
    if inOptions.doInstall:
        if "gitdist" in commonToolsSelectedSet:
            print("\nInstalling gitdist ...")
            echoRunSysCmnd("cp " + pythonUtilsDir + "/gitdist " +
                           common_tools_dir + "/")
            InstallProgramDriver.fixupInstallPermissions(
                inOptions, common_tools_dir)

        if "cmake" in commonToolsSelectedSet:
            os.system("tar -xf " + common_tools_dir + "/cmake-" +
                      cmake_version + ".tar.gz")
            os.system("mv -f cmake-" + cmake_version + " " + common_tools_dir)
            os.system("yum install openssl-devel")
            if not inOptions.skipOp:
                try:
                    os.system(
                        "cmake " + common_tools_dir + "/cmake-" +
                        cmake_version +
                        " -DCMAKE_USE_OPENSSL=ON -DCMAKE_INSTALL_PREFIX=" +
                        dev_env_base_dir + "/common_tools/cmake-" +
                        cmake_version + "/")
                except:
                    os.system("cmake " + common_tools_dir + "/cmake-" +
                              cmake_version + " -DCMAKE_INSTALL_PREFIX=" +
                              dev_env_base_dir + "/common_tools/cmake-" +
                              cmake_version + "/")
                os.system("make -j8 install")
                os.system("cd ..")
                cmake_module = open(dev_env_dir + "/cmake-" + cmake_version,
                                    'w+')
                cmake_module.write("#%Module\n\n")
                cmake_module.write("set version " + cmake_version + "\n")
                cmake_module.write(
                    'set name "MPACT Development Environment - 2.1.0"\n')
                cmake_module.write(
                    'set msg "Loads the development environment for MPACT."\n')
                cmake_module.write('\n')
                cmake_module.write("procs ModulesHelp { } {\n")
                cmake_module.write(" puts stderr $msg }\n\n")
                cmake_module.write("module-whatis $msg\n")
                cmake_module.write(common_tools_dir + "cmake-$version/bin\n")
                cmake_module.close()
        if "autoconf" in commonToolsSelectedSet:
            installToolFromSource("autoconf", autoconf_version_default,
                                  common_tools_dir, None, inOptions)

        if "gcc" in compilerToolsetSelectedSet:
            print("unpacking gcc-" + gcc_version + ".tar.gz...")
            os.system("tar xzf gcc-" + gcc_version + ".tar.gz")
            os.chdir("gcc-" + gcc_version)
            print("downloading gcc prerequisites...")
            os.system("./contrib/download_prerequisites")
            os.chdir(compiler_toolset_dir)
            os.system("mkdir gcc-" + gcc_version)
            os.chdir("gcc-" + gcc_version)
            print("configuring gcc...")
            os.system(scratch_dir + "/gcc-" + gcc_version +
                      "/configure --disable-multilib --prefix=" +
                      compiler_toolset_dir + "/gcc-" + gcc_version +
                      " --enable-languages=c,c++,fortran")
            print("building gcc...")
            os.system("make -j8")
            os.system("make install")
            os.chdir(scratch_dir)
            if not inOptions.skipOp:
                gcc_module = open(dev_env_dir + "/gcc-" + gcc_version, 'w+')
                gcc_module.write("#%module\n\n")
                gcc_module.write("set root " + dev_env_base_dir + "\n")
                gcc_module.write("set version gcc-" + gcc_version + "\n")
                gcc_module.write("set tpldir " + compiler_toolset_base_dir +
                                 "/tpls\n")
                gcc_module.write(
                    'set name "MPACT Development Environment - $version"\n')
                gcc_module.write(
                    'set msg "Loads the development environment for MPACT."\n')
                gcc_module.write('proc ModulesHelp { } {\n')
                gcc_module.write(" puts stderr $msg }\n")
                gcc_module.write("module-whatis $msg\n")
                if not mvapichInstalled:
                    gcc_module.write("if ![ is-loaded 'mpi/mpich-" +
                                     mpich_version + "-x86_64' ] {\n")
                    gcc_module.write(" module load mpi/mpich-" +
                                     mpich_version + "-x86_64 }\n")
                else:
                    gcc_module.write("if ![ is-loaded 'mpi/mvapich-" +
                                     mvapich_version + "-x86_64' ] {\n")
                    gcc_module.write(" module load mpi/mvapich-" +
                                     mvapich_version + "-x86_64 }\n")
                gcc_module.write(
                    "setenv TRIBITS_DEV_ENV_BASE          $root\n")
                gcc_module.write(
                    "setenv TRIBITS_DEV_ENV_GCC_VERSION   $version\n")
                gcc_module.write(
                    "setenv TRIBITS_DEV_ENV_COMPILER_BASE $root/$version\n")
                gcc_module.write(
                    "setenv TRIBITS_DEV_ENV_MPICH_DIR     $env(MPI_HOME)\n")
                gcc_module.write(
                    "setenv LOADED_TRIBITS_DEV_ENV        $version\n")
                gcc_module.write(
                    "setenv LOADED_VERA_DEV_ENV        $version\n")
                gcc_module.write("prepend-path PATH $root/common_tools\n")
                gcc_module.write("set tplpath $tpldir/hdf5-1.8.10\n")
                gcc_module.write("setenv HDF5_ROOT             $tplpath\n")
                gcc_module.write("prepend-path PATH            $tplpath/bin\n")
                gcc_module.write("prepend-path LD_LIBRARY_PATH $tplpath/lib\n")
                gcc_module.write(
                    "prepend-path INCLUDE         $tplpath/include\n")
                gcc_module.write("set tplpath $tpldir/lapack-3.3.1\n")
                gcc_module.write("setenv BLAS_ROOT             $tplpath\n")
                gcc_module.write("setenv LAPACK_DIR            $tplpath\n")
                gcc_module.write("prepend-path LD_LIBRARY_PATH $tplpath/lib\n")
                gcc_module.write("set tplpath $tpldir/hypre-2.9.1a\n")
                gcc_module.write("setenv HYPRE_DIR             $tplpath\n")
                gcc_module.write("prepend-path LD_LIBRARY_PATH $tplpath/lib\n")
                gcc_module.write("set tplpath $tpldir/petsc-3.5.4\n")
                gcc_module.write("setenv PETSC_DIR             $tplpath\n")
                gcc_module.write("prepend-path PATH            $tplpath/bin\n")
                gcc_module.write("prepend-path LD_LIBRARY_PATH $tplpath/lib\n")
                gcc_module.write("set tplpath $tpldir/slepc-3.5.4\n")
                gcc_module.write("setenv SLEPC_DIR             $tplpath\n")
                gcc_module.write("prepend-path LD_LIBRARY_PATH $tplpath/lib\n")
                gcc_module.write("set tplpath $tpldir/sundials-2.9.0\n")
                gcc_module.write("setenv SUNDIALS_DIR          $tplpath\n")
                gcc_module.write("prepend-path LD_LIBRARY_PATH $tplpath/lib\n")
                gcc_module.write(
                    "set-alias gitdist-status     {gitdist dist-repo-status}\n"
                )
                gcc_module.write(
                    "set-alias gitdist-mod        {gitdist --dist-mod-only}\n")
                gcc_module.close()

        if "mpich" in compilerToolsetSelectedSet:
            gccInstallDir = compiler_toolset_dir + "/gcc-" + gcc_version
            if not os.path.exists(gccInstallDir) and not inOptions.skipOp:
                raise Exception("Error, gcc has not been installed yet." \
                  "  Missing directory '"+gccInstallDir+"'")
            LD_LIBRARY_PATH = os.environ.get("LD_LIBRARY_PATH", "")
            if mpich_version == "3.1.3":
                installToolFromSource(
                    "mpich", mpich_version, compiler_toolset_dir, {
                        "CC":
                        gccInstallDir + "/bin/gcc",
                        "CXX":
                        gccInstallDir + "/bin/g++",
                        "FC":
                        gccInstallDir + "/bin/gfortran",
                        "LD_LIBRARY_PATH":
                        compiler_toolset_dir + "/lib64:" + LD_LIBRARY_PATH
                    }, inOptions)
            else:
                os.system("tar xfz mpich-" + mpich_version + ".tar.gz")
                os.system("mkdir -p " + compiler_toolset_dir + "/mpich-" +
                          mpich_version)
                os.system("mkdir tmp")
                os.chdir("tmp")
                os.system("../mpich-" + mpich_version + "/configure -prefix=" +
                          compiler_toolset_dir + "/mpich-" + mpich_version)
                os.system("make")
                os.system("make install")
            if not inOptions.skipOp:
                mpich_module = open(dev_env_dir + "/mpich-" + mpich_version,
                                    'w+')
                mpich_module.write("conflict mvapich\n")
                mpich_module.write(
                    "prepend-path            PATH            /usr/lib64/mpich/bin\n"
                )
                mpich_module.write(
                    "prepend-path            LD_LIBRARY_PATH /usr/lib64/mpich/lib\n"
                )
                mpich_module.write(
                    "prepend-path            PYTHONPATH      /usr/lib64/python2.7/site-packages/mpich\n"
                )
                mpich_module.write(
                    "prepend-path            MANPATH         /usr/share/man/mpich-x86_64\n"
                )
                mpich_module.write(
                    "prepend-path            PKG_CONFIG_PATH /usr/lib64/mpich/lib/pkgconfig\n"
                )
                mpich_module.write(
                    "setenv                  MPI_BIN         /usr/lib64/mpich/bin\n"
                )
                mpich_module.write(
                    "setenv                  MPI_SYSCONFIG   /etc/mpich-x86_64\n"
                )
                mpich_module.write(
                    "setenv                  MPI_FORTRAN_MOD_DIR     /usr/lib64/gfortran/modules/mpich-x86_64\n"
                )
                mpich_module.write(
                    "setenv                  MPI_INCLUDE     /usr/include/mpich-x86_64\n"
                )
                mpich_module.write(
                    "setenv                  MPI_LIB         /usr/lib64/mpich/lib\n"
                )
                mpich_module.write(
                    "setenv                  MPI_MAN         /usr/share/man/mpich-x86_64\n"
                )
                mpich_module.write(
                    "setenv                  MPI_PYTHON_SITEARCH     /usr/lib64/python2.7/site-packages/mpich\n"
                )
                mpich_module.write(
                    "setenv                  MPI_COMPILER    mpich-x86_64\n")
                mpich_module.write(
                    "setenv                  MPI_SUFFIX      _mpich\n")
                mpich_module.write(
                    "setenv                  MPI_HOME        /usr/lib64/mpich\n"
                )
                mpich_module.close()

        elif "mvapich" in compilerToolsetSelectedSet:
            gccInstallDir = compiler_toolset_dir + "/gcc-" + gcc_version
            if not os.path.exists(gccInstallDir) and not inOptions.skipOp:
                raise Exception("Error, gcc has not been installed yet." \
                  "  Missing directory '"+gccInstallDir+"'")
            LD_LIBRARY_PATH = os.environ.get("LD_LIBRARY_PATH", "")
            mvapichDir = gccInstallDir + "/toolset/mvapich-" + mvapich_version
            if not inOptions.skipOp:
                os.system("yum install libibverbs")
                os.system("gzip -dc mvapich2-" + mvapich_version +
                          ".tar.gz | tar -x")
                os.chdir("mvapich2-" + mvapich_version)
                os.system("./configure --prefix " + mvapichDir)
                os.system("make -j8")
                os.system("make install")
                mvapich_module = open(
                    dev_env_dir + "/mvapich-" + mvapich_version, 'w+')
                mvapich_module.write("conflict mpich\n")
                mvapich_module.write(
                    "prepend-path            PATH            /usr/lib64/mvapich2/bin\n"
                )
                mvapich_module.write(
                    "prepend-path            LD_LIBRARY_PATH /usr/lib64/mvapich2/lib\n"
                )
                mvapich_module.write(
                    "prepend-path            PYTHONPATH      /usr/lib64/python2.7/site-packages/mvapich2\n"
                )
                mvapich_module.write(
                    "prepend-path            MANPATH         /usr/share/man/mvapich2-x86_64\n"
                )
                mvapich_module.write(
                    "prepend-path            PKG_CONFIG_PATH /usr/lib64/mvapich2/lib/pkgconfig\n"
                )
                mvapich_module.write(
                    "setenv                  MPI_BIN         /usr/lib64/mvapich2/bin\n"
                )
                mvapich_module.write(
                    "setenv                  MPI_SYSCONFIG   /etc/mvapich2-x86_64\n"
                )
                mvapich_module.write(
                    "setenv                  MPI_FORTRAN_MOD_DIR     /usr/lib64/gfortran/modules/mvapich2-x86_64\n"
                )
                mvapich_module.write(
                    "setenv                  MPI_INCLUDE     /usr/include/mvapich2-x86_64\n"
                )
                mvapich_module.write(
                    "setenv                  MPI_LIB         /usr/lib64/mvapich2/lib\n"
                )
                mvapich_module.write(
                    "setenv                  MPI_MAN         /usr/share/man/mvapich2-x86_64\n"
                )
                mvapich_module.write(
                    "setenv                  MPI_PYTHON_SITEARCH     /usr/lib64/python2.7/site-packages/mvapich2"
                )
                mvapich_module.write(
                    "setenv                  MPI_COMPILER    mvapich2-x86_64\n"
                )
                mvapich_module.write(
                    "setenv                  MPI_SUFFIX      _mvapich2\n")
                mvapich_module.write(
                    "setenv                  MPI_HOME        /usr/lib64/mvapich2"
                )
                mvapich_module.close()
    else:
        print("Skipping install of the tools on request!")

    ###
    print("\n\nD) Final instructions for using installed dev env:")
    ###

    if inOptions.skipOp:
        print("\n***")
        print(
            "*** NOTE: --no-op provided, only traced actions that would have been taken!"
        )
        print("***")
    else:
        os.system("mv load_dev_env.sh " + dev_env_dir)
        os.system("mv load_dev_env.csh " + dev_env_dir)

    print("installing CMake target for vera_tpls")
    if not inOptions.skipOp and inOptions.doInstall:
        os.system("mkdir " + compiler_toolset_base_dir + "/tpls")
        os.chdir(scratch_dir + "/..")
        os.system("git submodule init && git submodule update")
        if not os.path.exists(scratch_dir + "/tmp"):
            os.mkdir(scratch_dir + "/tmp")
        os.chdir(scratch_dir + "/tmp")
        os.system("rm -rf *")
        os.system("module load mpi")
        os.system(
            'cmake  -D CMAKE_INSTALL_PREFIX=' + compiler_toolset_base_dir +
            '/tpls -D CMAKE_BUILD_TYPE=Release  -D CMAKE_CXX_COMPILER=mpicxx  -D CMAKE_C_COMPILER=mpicc  -D CMAKE_Fortran_COMPILER=mpif90  -D FFLAGS="-fPIC -O3"  -D CFLAGS="-fPIC -O3"  -D CXXFLAGS="-fPIC -O3"  -D LDFLAGS=""  -D ENABLE_SHARED=ON  -D PROCS_INSTALL=8 ../../vera_tpls/TPL_build'
        )
        os.system("make -j8 || make -j8")
    else:
        print("git submodule init && git submodule update")
        print(
            'cmake  -D CMAKE_INSTALL_PREFIX=' + compiler_toolset_base_dir +
            '/tpls -D CMAKE_BUILD_TYPE=Release  -D CMAKE_CXX_COMPILER=mpicxx  -D CMAKE_C_COMPILER=mpicc  -D CMAKE_Fortran_COMPILER=mpif90  -D FFLAGS="-fPIC -O3"  -D CFLAGS="-fPIC -O3"  -D CXXFLAGS="-fPIC -O3"  -D LDFLAGS=""  -D ENABLE_SHARED=ON  -D PROCS_INSTALL=8 ../vera_tpls/TPL_build'
        )
        print("make -j8")
    if not inOptions.skipOp:
        if inOptions.build_image:
            print("building docker image")
            os.system("docker build -t test-mpact-dev-env " +
                      dev_env_base_dir + "/images")
    if inOptions.showFinalInstructions:
        print("\nTo use the new dev env, just source the file:\n")
        print("  source " + dev_env_base_dir + "/env/load_dev_env.sh\n")
        print("for sh or bash shells (or load_dev_env.csh for csh shell).\n")
        print("TIP: Add this source to your ~/.bash_profile!")
    else:
        print("Skipping on request ...")
    print("\n[End]")
Exemple #3
0
    print "rpathbase = "+rpathbase
    specpath = getCmndOutput(gccExec+" --print-file libgcc.a | sed 's|/libgcc.a||'", True)
    print "specpath = "+specpath
    rpath = ""
    libPath = rpathbase+"/lib"
    if os.path.exists(libPath):
      rpath = appendToRPath(rpath, libPath)
    lib64Path = rpathbase+"/lib64"
    if os.path.exists(lib64Path):
      rpath = appendToRPath(rpath, lib64Path)
    print "rpath will be: '"+rpath+"'"
    specsfile = specpath+"/specs"
    if os.path.exists(specsfile):
      print "Backing up the existing GCC specs file '"+specsfile+"' ..."
      echoRunSysCmnd("cp "+specsfile+" "+specsfile+".backup")
    print "Writing to GCC specs file "+specsfile
    gccSpecs = getCmndOutput(gccExec+" -dumpspecs", True)
    #print "gccSpecs:\n", gccSpecs
    gccSpecsMod = addRpathToLink(gccSpecs, rpath)
    #print "gccSpecsMod:\n", gccSpecsMod
    writeStrToFile(specsfile, gccSpecsMod)


#
# Executable statements
#

gitInstaller = InstallProgramDriver(GccInstall())

gitInstaller.runDriver()
Exemple #4
0
def main(cmndLineArgs):

    #
    # Get the command-line options
    #

    inOptions = getCmndLineOptions(cmndLineArgs)

    if inOptions.skipOp:
        print("\n***")
        print(
            "*** NOTE: --no-op provided, will only trace actions and not touch the filesystem!"
        )
        print("***\n")

    commonToolsSelected = \
      getToolsSelectedArray(inOptions.commonTools, commonToolsArray)
    print("\nSelected common tools = " + commonToolsSelected)
    commonToolsSelectedSet = set(commonToolsSelected)

    compilerToolsetSelected = \
      getToolsSelectedArray(inOptions.compilerToolset, compilerToolsetArray)
    print("\nSelected compiler toolset = " + compilerToolsetSelected)
    compilerToolsetSelectedSet = set(compilerToolsetSelected)

    gccVersion = gcc_version_default  #ToDo: Make variable!

    dev_env_base_dir = inOptions.installDir

    ###
    print("\n\nA) Setup the install directory <dev_env_base> ='" +
          dev_env_base_dir + "':\n")
    ###

    dev_env_base_exists = os.path.exists(dev_env_base_dir)

    common_tools_dir = os.path.join(dev_env_base_dir, "common_tools")
    common_tools_exists = os.path.exists(common_tools_dir)

    compiler_toolset_base_dir = os.path.join(dev_env_base_dir,
                                             "gcc-" + gccVersion)
    compiler_toolset_base_exists = os.path.exists(compiler_toolset_base_dir)

    compiler_toolset_dir = os.path.join(compiler_toolset_base_dir, "toolset")
    compiler_toolset_exists = os.path.exists(compiler_toolset_dir)

    if inOptions.doInitialSetup:

        if not dev_env_base_exists:
            print("Creating directory '" + dev_env_base_dir + "' ...")
            if not inOptions.skipOp:
                os.makedirs(dev_env_base_dir)

        if not common_tools_exists:
            print("Creating directory '" + common_tools_dir + "' ...")
            if not inOptions.skipOp:
                os.makedirs(common_tools_dir)

        # Always create this directory so we can write the load_dev_env.sh script!
        if not compiler_toolset_base_exists:
            print("Creating directory '" + compiler_toolset_base_dir + "' ...")
            if not inOptions.skipOp:
                os.makedirs(compiler_toolset_base_dir)

        if not compiler_toolset_exists:
            print("Creating directory '" + compiler_toolset_dir + "' ...")
            if not inOptions.skipOp:
                os.makedirs(compiler_toolset_dir)

        print("Writing new files " + inOptions.loadDevEnvFileBaseName +
              ".[sh,csh] ...")
        if not inOptions.skipOp:
            writeLoadDevEnvFiles(dev_env_base_dir, compiler_toolset_base_dir,
                                 inOptions)

    else:

        print("Skipping setup of the install directory by request!")

        assertInstallDirExists(dev_env_base_dir, inOptions)
        assertInstallDirExists(common_tools_dir, inOptions)
        assertInstallDirExists(compiler_toolset_base_dir, inOptions)
        assertInstallDirExists(compiler_toolset_dir, inOptions)

    ###
    print("\n\nB) Download all sources for each selected tool:\n")
    ###

    if inOptions.doDownload:

        if "cmake" in commonToolsSelectedSet:
            downloadToolSource("cmake", cmake_version_default,
                               inOptions.sourceGitUrlBase, inOptions)

        if "autoconf" in commonToolsSelectedSet:
            downloadToolSource("autoconf", autoconf_version_default,
                               inOptions.sourceGitUrlBase, inOptions)

        if "gcc" in compilerToolsetSelectedSet:
            downloadToolSource("gcc", gcc_version_default,
                               inOptions.sourceGitUrlBase, inOptions)

        if "mpich" in compilerToolsetSelectedSet:
            downloadToolSource("mpich", mpich_version_default,
                               inOptions.sourceGitUrlBase, inOptions)

    else:

        print("Skipping download of the source for the tools on request!")
        if inOptions.doInstall:
            print("NOTE: The downloads had better be there for the install!")

    ###
    print("\n\nC) Untar, configure, build and install each selected tool:\n")
    ###

    if inOptions.doInstall:

        if "gitdist" in commonToolsSelectedSet:
            print("\nInstalling gitdist ...")
            echoRunSysCmnd("cp " + pythonUtilsDir + "/gitdist " +
                           common_tools_dir + "/")
            InstallProgramDriver.fixupInstallPermissions(
                inOptions, common_tools_dir)

        if "cmake" in commonToolsSelectedSet:
            installToolFromSource("cmake", cmake_version_default,
                                  common_tools_dir, None, inOptions)

        if "autoconf" in commonToolsSelectedSet:
            installToolFromSource("autoconf", autoconf_version_default,
                                  common_tools_dir, None, inOptions)

        if "gcc" in compilerToolsetSelectedSet:
            installToolFromSource("gcc", gcc_version_default,
                                  compiler_toolset_dir, None, inOptions)

        if "mpich" in compilerToolsetSelectedSet:
            gccInstallDir = compiler_toolset_dir + "/gcc-" + gcc_version_default
            if not os.path.exists(gccInstallDir) and not inOptions.skipOp:
                raise Exception("Error, gcc has not been installed yet." \
                  "  Missing directory '"+gccInstallDir+"'")
            LD_LIBRARY_PATH = os.environ.get("LD_LIBRARY_PATH", "")
            installToolFromSource(
                "mpich", mpich_version_default, compiler_toolset_dir, {
                    "CC": gccInstallDir + "/bin/gcc",
                    "CXX": gccInstallDir + "/bin/g++",
                    "FC": gccInstallDir + "/bin/gfortran",
                    "LD_LIBRARY_PATH":
                    gccInstallDir + "/lib64:" + LD_LIBRARY_PATH
                }, inOptions)

    else:

        print("Skipping install of the tools on request!")

    ###
    print("\n\nD) Final instructions for using installed dev env:")
    ###

    if inOptions.showFinalInstructions:
        print("\nTo use the new dev env, just source the file:\n")
        print("  source " + compiler_toolset_base_dir + "/load_dev_env.sh\n")
        print("for sh or bash shells (or load_dev_env.csh for csh shell).\n")
        print("TIP: Add this source to your ~/.bash_profile!")
    else:
        print("Skipping on request ...")

    if inOptions.skipOp:
        print("\n***")
        print(
            "*** NOTE: --no-op provided, only traced actions that would have been taken!"
        )
        print("***")

    print("\n[End]")
def getCmndLineOptions(cmndLineArgs, skipEchoCmndLine=False):

    from optparse import OptionParser

    clp = OptionParser(usage=usageHelp)
    clp.add_option(
      "--install-dir", dest="installDir", type="string", default="",
      help="The base directory <dev_env_base> that will be used for the install." \
        +"  There is not default.  If this is not specified then will abort.")

    InstallProgramDriver.insertInstallPermissionsOptions(clp)

    clp.add_option(
        "--source-git-url-base",
        dest="sourceGitUrlBase",
        type="string",
        default=sourceGitUrlBase_default,
        help=
        "Gives the base URL <url_base> for the git repos to object the source from."
    )

    clp.add_option(
      "--load-dev-env-file-base-name", dest="loadDevEnvFileBaseName",
      type="string", default="load_dev_env",
      help="Base name of the load dev env script that will be installed." \
        "  (Default = 'load_dev_env')" )

    clp.add_option(
      "--common-tools", dest="commonTools", type="string", default="all",
      help="Specifies the common tools to download and install under common_tools/." \
        "  Can be 'all', or empty '', or any combination of" \
        " '"+(",".join(commonToolsArray))+"' (separated by commas, no spaces).")

    clp.add_option(
      "--compiler-toolset", dest="compilerToolset", type="string", default="all",
      help="Specifies GCC and MPICH and other compiler-specific tools to" \
        " download and install under gcc-<gcc-version>/toolset/." \
        "  Can be 'all', or empty '', or any combination of" \
        " '"+(",".join(compilerToolsetArray))+"' (separated by commas, no spaces).")

    clp.add_option(
      "--parallel", dest="parallelLevel", type="string", default="1",
      help="Number of parallel processes to use in the build.  The default is" \
        " just '1'.  Use something like '8' to get faster parallel builds." )

    clp.add_option("--do-op",
                   dest="skipOp",
                   action="store_false",
                   help="Do all of the requested actions [default].")
    clp.add_option(
        "--no-op",
        dest="skipOp",
        action="store_true",
        default=False,
        help=
        "Skip all of the requested actions and just print what would be done.")

    clp.add_option("--show-defaults",
                   dest="showDefaults",
                   action="store_true",
                   default=False,
                   help="[ACTION] Show the defaults and exit.")

    clp.add_option(
      "--initial-setup", dest="doInitialSetup", action="store_true", default=False,
      help="[ACTION] Create base directories under <dev_env_base>/ and install" \
        " load_dev_env.[sh,csh].")

    clp.add_option(
      "--download", dest="doDownload", action="store_true", default=False,
      help="[ACTION] Download all of the tools specified by --common-tools" \
        " and --compiler-toolset.  WARNING:  If the source for a tool has" \
        " already been downloaded, it will be deleted (along with the build" \
        " directory) and downloaded from scratch!")

    clp.add_option(
      "--install", dest="doInstall", action="store_true", default=False,
      help="[ACTION] Configure, build, and install all of the tools specified by" \
        " --common-tools and --compiler-toolset.")

    clp.add_option(
        "--show-final-instructions",
        dest="showFinalInstructions",
        action="store_true",
        default=False,
        help="[ACTION] Show final instructions for using the installed dev env."
    )

    clp.add_option(
        "-m",
        "--mkl",
        action="store_true",
        dest="mkl_true",
        default=False,
        help=
        "Enable to install tpls with intel-mkl rather than blas-lapack. Default is vera tpls"
    )

    clp.add_option(
        "-b",
        "--build-image",
        action="store_true",
        dest="build_image",
        default=False,
        help=
        "Enable to build a docker image from the configured docker file. Default is false"
    )

    clp.add_option(
      "--do-all", dest="doAll", action="store_true", default=False,
      help="[AGGR ACTION] Do everything.  Implies --initial-setup --downlaod" \
        +" --install --show-final-instructions")

    (options, args) = clp.parse_args(args=cmndLineArgs)

    # NOTE: Above, in the pairs of boolean options, the *last* add_option(...)
    # takes effect!  That is why the commands are ordered the way they are!

    #
    # Echo the command-line
    #

    if not skipEchoCmndLine:

        cmndLine = "**************************************************************************\n"
        cmndLine += "Script: install-devtools.py \\\n"
        cmndLine += "  --install-dir='" + options.installDir + "' \\\n"
        cmndLine += InstallProgramDriver.echoInsertPermissionsOptions(options)
        cmndLine += "  --source-git-url-base='" + options.sourceGitUrlBase + "' \\\n"
        cmndLine += "  --load-dev-env-file-base-name='" + options.loadDevEnvFileBaseName + "' \\\n"
        cmndLine += "  --common-tools='" + options.commonTools + "' \\\n"
        cmndLine += "  --compiler-toolset='" + options.compilerToolset + "' \\\n"
        cmndLine += "  --parallel='" + options.parallelLevel + "' \\\n"
        if not options.skipOp:
            cmndLine += "  --do-op \\\n"
        else:
            cmndLine += "  --no-op \\\n"
        if options.doInitialSetup:
            cmndLine += "  --initial-setup \\\n"
        if options.doDownload:
            cmndLine += "  --download \\\n"
        if options.doInstall:
            cmndLine += "  --install \\\n"
        if options.showFinalInstructions:
            cmndLine += "  --show-final-instructions \\\n"
        if options.doAll:
            cmndLine += "  --do-all \\\n"

        print(cmndLine)

        if options.showDefaults:
            sys.exit(0)

    #
    # Check the input arguments
    #

    if options.installDir == "":
        print("\nError, you must set --install-dir=<dev_env_base>!")
        raise Exception("Bad input option --install-dir")
    options.installDir = os.path.abspath(os.path.expanduser(
        options.installDir))

    if options.commonTools == "all":
        options.commonTools = ",".join(commonToolsArray)
    #print("options.commonTools = '"+options.commonTools+"'")

    if options.compilerToolset == "all":
        options.compilerToolset = ",".join(compilerToolsetArray)
    #print("options.compilerToolset = '"+options.compilerToolset+"'")

    if options.doAll:
        options.doInitialSetup = True
        options.doDownload = True
        options.doInstall = True
        options.showFinalInstructions = True

    #
    # Return the options
    #

    return options
Exemple #6
0
      + self.inOptions.makeOptions)

  def doInstall(self):
    echoChDir(self.mpichBuildBaseDir)
    echoRunSysCmnd("make " + getParallelOpt(self.inOptions, "-j") \
      + self.inOptions.makeOptions + " install")

  def getFinalInstructions(self):
    return """
To use the installed version of mpich-"""+self.inOptions.version+""" add the path:

  """+self.inOptions.installDir+"""/bin

to your path and that should be it!

Also, when you link shared libs or executables, pass in:

   -Wl,-rpath,"""+self.inOptions.installDir+"""/lib[64]

That will make it so that you don't need to add this MPICH libs to your
LD_LIBRARY_PATH.
"""


#
# Executable statements
#

mpichInstaller = InstallProgramDriver(MpichInstall())
mpichInstaller.runDriver()
def main(cmndLineArgs):

  #
  # Get the command-line options
  #

  inOptions = getCmndLineOptions(cmndLineArgs)

  if inOptions.skipOp:
    print("\n***")
    print("*** NOTE: --no-op provided, will only trace actions and not touch the filesystem!")
    print("***\n")

  commonToolsSelected = \
    getToolsSelectedArray(inOptions.commonTools, commonToolsArray)
  print("\nSelected common tools = " + commonToolsSelected)
  commonToolsSelectedSet = set(commonToolsSelected)

  compilerToolsetSelected = \
    getToolsSelectedArray(inOptions.compilerToolset, compilerToolsetArray)
  print("\nSelected compiler toolset = " + compilerToolsetSelected)
  compilerToolsetSelectedSet = set(compilerToolsetSelected)

  gccVersion=gcc_version_default #ToDo: Make variable!

  dev_env_base_dir = inOptions.installDir

  ###
  print("\n\nA) Setup the install directory <dev_env_base> ='" +
        dev_env_base_dir + "':\n")
  ###

  dev_env_base_exists = os.path.exists(dev_env_base_dir)

  common_tools_dir = os.path.join(dev_env_base_dir, "common_tools")
  common_tools_exists = os.path.exists(common_tools_dir)

  compiler_toolset_base_dir = os.path.join(dev_env_base_dir, "gcc-"+gccVersion)
  compiler_toolset_base_exists = os.path.exists(compiler_toolset_base_dir)

  compiler_toolset_dir = os.path.join(compiler_toolset_base_dir, "toolset")
  compiler_toolset_exists = os.path.exists(compiler_toolset_dir)

  if inOptions.doInitialSetup:

    if not dev_env_base_exists:
      print("Creating directory '" + dev_env_base_dir + "' ...")
      if not inOptions.skipOp:
        os.makedirs(dev_env_base_dir)

    if not common_tools_exists:
      print("Creating directory '" + common_tools_dir + "' ...")
      if not inOptions.skipOp:
        os.makedirs(common_tools_dir)

    # Always create this directory so we can write the load_dev_env.sh script!
    if not compiler_toolset_base_exists:
      print("Creating directory '" + compiler_toolset_base_dir + "' ...")
      if not inOptions.skipOp:
        os.makedirs(compiler_toolset_base_dir)

    if not compiler_toolset_exists:
      print("Creating directory '" + compiler_toolset_dir + "' ...")
      if not inOptions.skipOp:
        os.makedirs(compiler_toolset_dir)

    print("Writing new files " + inOptions.loadDevEnvFileBaseName +
          ".[sh,csh] ...")
    if not inOptions.skipOp:
      writeLoadDevEnvFiles(dev_env_base_dir, compiler_toolset_base_dir, inOptions)

  else:

    print("Skipping setup of the install directory by request!")

    assertInstallDirExists(dev_env_base_dir, inOptions)
    assertInstallDirExists(common_tools_dir, inOptions)
    assertInstallDirExists(compiler_toolset_base_dir, inOptions)
    assertInstallDirExists(compiler_toolset_dir, inOptions)

  ###
  print("\n\nB) Download all sources for each selected tool:\n")
  ###

  if inOptions.doDownload:

    if "cmake" in commonToolsSelectedSet:
      downloadToolSource("cmake", cmake_version_default,
        inOptions.sourceGitUrlBase, inOptions)

    if "autoconf" in commonToolsSelectedSet:
      downloadToolSource("autoconf", autoconf_version_default,
        inOptions.sourceGitUrlBase, inOptions)

    if "gcc" in compilerToolsetSelectedSet:
      downloadToolSource("gcc", gcc_version_default,
        inOptions.sourceGitUrlBase, inOptions)

    if "mpich" in compilerToolsetSelectedSet:
      downloadToolSource("mpich", mpich_version_default,
        inOptions.sourceGitUrlBase, inOptions)

  else:

    print("Skipping download of the source for the tools on request!")
    if inOptions.doInstall:
      print("NOTE: The downloads had better be there for the install!")

  ###
  print("\n\nC) Untar, configure, build and install each selected tool:\n")
  ###

  if inOptions.doInstall:

    if "gitdist" in commonToolsSelectedSet:
      print("\nInstalling gitdist ...")
      echoRunSysCmnd("cp "+pythonUtilsDir+"/gitdist "+common_tools_dir+"/")
      InstallProgramDriver.fixupInstallPermissions(inOptions, common_tools_dir)

    if "cmake" in commonToolsSelectedSet:
      installToolFromSource("cmake", cmake_version_default,
        common_tools_dir, None, inOptions )

    if "autoconf" in commonToolsSelectedSet:
      installToolFromSource("autoconf", autoconf_version_default,
        common_tools_dir, None, inOptions )

    if "gcc" in compilerToolsetSelectedSet:
      installToolFromSource("gcc", gcc_version_default,
        compiler_toolset_dir, None, inOptions )

    if "mpich" in compilerToolsetSelectedSet:
      gccInstallDir = compiler_toolset_dir+"/gcc-"+gcc_version_default
      if not os.path.exists(gccInstallDir) and not inOptions.skipOp:
        raise Exception("Error, gcc has not been installed yet." \
          "  Missing directory '"+gccInstallDir+"'") 
      LD_LIBRARY_PATH = os.environ.get("LD_LIBRARY_PATH", "")
      installToolFromSource(
        "mpich",
        mpich_version_default,
        compiler_toolset_dir,
        {
          "CC" : gccInstallDir+"/bin/gcc",
          "CXX" : gccInstallDir+"/bin/g++",
          "FC" : gccInstallDir+"/bin/gfortran",
          "LD_LIBRARY_PATH" : gccInstallDir+"/lib64:"+LD_LIBRARY_PATH
         },
        inOptions
        )

  else:

    print("Skipping install of the tools on request!")

  ###
  print("\n\nD) Final instructions for using installed dev env:")
  ###
    
  if inOptions.showFinalInstructions:
    print("\nTo use the new dev env, just source the file:\n")
    print("  source " + compiler_toolset_base_dir + "/load_dev_env.sh\n")
    print("for sh or bash shells (or load_dev_env.csh for csh shell).\n")
    print("TIP: Add this source to your ~/.bash_profile!")
  else:
    print("Skipping on request ...")

  if inOptions.skipOp:
    print("\n***")
    print("*** NOTE: --no-op provided, only traced actions that would have been taken!")
    print("***")
  
  print("\n[End]")
Exemple #8
0
 def test_default(self):
     ipd = InstallProgramDriver(DummyInstall())
     sys.argv = ["scriptName"]
     self.assertEqual(ipd.runDriver(), None)
Exemple #9
0
  """+self.inOptions.installDir+"""/include

the libraries in the directory:

  """+self.inOptions.installDir+"""/lib

and the executables and compiler wrappers (e.g. mpicc, mpic++, mpirun, etc.) in:

  """+self.inOptions.installDir+"""/bin

Actually, using the MPI compiler wrappers mpicc, mpic++, etc. is prefered.
"""

  def getEnvCmnd(self):
    envCmnd = "env "
    if self.inOptions.withPath:
      envCmnd = "PATH="+self.inOptions.withPath+":$PATH "
    if self.inOptions.withLibDir:
      envCmnd += "LD_LIBRARY_PATH="+self.inOptions.withLibDir+":$LD_LIBRARY_PATH "
    envCmnd += "echo 'PATH='$PATH && echo 'LD_LIBRARY_PATH='$LD_LIBRARY_PATH && which gcc && gcc --version && "
    return envCmnd


#
# Executable statements
#

openmpiInstaller = InstallProgramDriver(OpenMpiInstall())

openmpiInstaller.runDriver()
Exemple #10
0
  """ + self.inOptions.installDir + """/include

the libraries in the directory:

  """ + self.inOptions.installDir + """/lib

and the executables and compiler wrappers (e.g. mpicc, mpic++, mpirun, etc.) in:

  """ + self.inOptions.installDir + """/bin

Actually, using the MPI compiler wrappers mpicc, mpic++, etc. is prefered.
"""

    def getEnvCmnd(self):
        envCmnd = "env "
        if self.inOptions.withPath:
            envCmnd = "PATH=" + self.inOptions.withPath + ":$PATH "
        if self.inOptions.withLibDir:
            envCmnd += "LD_LIBRARY_PATH=" + self.inOptions.withLibDir + ":$LD_LIBRARY_PATH "
        envCmnd += "echo 'PATH='$PATH && echo 'LD_LIBRARY_PATH='$LD_LIBRARY_PATH && which gcc && gcc --version && "
        return envCmnd


#
# Executable statements
#

openmpiInstaller = InstallProgramDriver(OpenMpiInstall())

openmpiInstaller.runDriver()
          " --prefix="+self.inOptions.installDir,
          extraEnv={"CFLAGS":"-O3"},
          )

    def doBuild(self):
        echoChDir(self.autoconfBuildBaseDir)
        echoRunSysCmnd("make " + getParallelOpt(self.inOptions, "-j") \
          + self.inOptions.makeOptions)

    def doInstall(self):
        echoChDir(self.autoconfBuildBaseDir)
        echoRunSysCmnd("make " + getParallelOpt(self.inOptions, "-j") \
          + self.inOptions.makeOptions + " install")

    def getFinalInstructions(self):
        return """
To use the installed version of autoconf-""" + self.inOptions.version + """ add the path:

  """ + self.inOptions.installDir + """/bin

to your path and that should be it!
"""


#
# Executable statements
#

autoconfInstaller = InstallProgramDriver(AutoconfInstall())
autoconfInstaller.runDriver()
 def test_default(self):
   ipd = InstallProgramDriver(DummyInstall())
   sys.argv = ["scriptName"]
   self.assertEqual(ipd.runDriver(), None)
          + self.inOptions.makeOptions)

    def doInstall(self):
        echoChDir(self.mvapichBuildBaseDir)
        echoRunSysCmnd("make " + getParallelOpt(self.inOptions, "-j") \
          + self.inOptions.makeOptions + " install")

    def getFinalInstructions(self):
        return """
To use the installed version of mvapich-""" + self.inOptions.version + """ add the path:

  """ + self.inOptions.installDir + """/bin

to your path and that should be it!

Also, when you link shared libs or executables, pass in:

   -Wl,-rpath,""" + self.inOptions.installDir + """/lib[64]

That will make it so that you don't need to add this MPICH libs to your
LD_LIBRARY_PATH.
"""


#
# Executable statements
#

mvapichInstaller = InstallProgramDriver(MvapichInstall())
mvapichInstaller.runDriver()
Exemple #14
0
 def test_default(self):
     ipd = InstallProgramDriver(DummyInstall())
     sys.argv = ["scriptName", "--install-dir=/some/install/path"]
     self.assertEqual(ipd.runDriver(), None)
Exemple #15
0
          getParallelOpt(self.inOptions, "--parallel=")+\
          " --prefix="+self.inOptions.installDir,
          extraEnv={"CXXFLAGS":"-O3", "CFLAGS":"-O3"},
          )

    def doBuild(self):
        echoChDir(self.cmakeBuildBaseDir)
        echoRunSysCmnd("make " + getParallelOpt(self.inOptions, "-j") +
                       self.inOptions.makeOptions)

    def doInstall(self):
        echoChDir(self.cmakeBuildBaseDir)
        echoRunSysCmnd("make " + self.inOptions.makeOptions + " install")

    def getFinalInstructions(self):
        return """
To use the installed version of cmake-""" + self.inOptions.version + """ add the path:

  """ + self.inOptions.installDir + """/bin

to your path and that should be it!
"""


#
# Executable statements
#

cmakeInstaller = InstallProgramDriver(CMakeInstall())
cmakeInstaller.runDriver()
Exemple #16
0
def getCmndLineOptions(cmndLineArgs, skipEchoCmndLine=False):

  from optparse import OptionParser
  
  clp = OptionParser(usage=usageHelp)

  clp.add_option(
    "--install-dir", dest="installDir", type="string", default="",
    help="The base directory <dev_env_base> that will be used for the install." \
      +"  There is not default.  If this is not specified then will abort.")

  InstallProgramDriver.insertInstallPermissionsOptions(clp)

  clp.add_option(
    "--source-git-url-base", dest="sourceGitUrlBase", type="string",
    default=sourceGitUrlBase_default,
    help="Gives the base URL <url_base> for the git repos to object the source from.")

  clp.add_option(
    "--load-dev-env-file-base-name", dest="loadDevEnvFileBaseName",
    type="string", default="load_dev_env",
    help="Base name of the load dev env script that will be installed." \
      "  (Default = 'load_dev_env')" )

  clp.add_option(
    "--common-tools", dest="commonTools", type="string", default="all",
    help="Specifies the common tools to download and install under common_tools/." \
      "  Can be 'all', or empty '', or any combination of" \
      " '"+(",".join(commonToolsArray))+"' (separated by commas, no spaces).")

  clp.add_option(
    "--compiler-toolset", dest="compilerToolset", type="string", default="all",
    help="Specifies GCC and MPICH and other compiler-specific tools to" \
      " download and install under gcc-<gcc-version>/toolset/." \
      "  Can be 'all', or empty '', or any combination of" \
      " '"+(",".join(compilerToolsetArray))+"' (separated by commas, no spaces).")

  clp.add_option(
    "--parallel", dest="parallelLevel", type="string", default="1",
    help="Number of parallel processes to use in the build.  The default is" \
      " just '1'.  Use something like '8' to get faster parallel builds." )

  clp.add_option(
    "--do-op", dest="skipOp", action="store_false",
    help="Do all of the requested actions [default].")
  clp.add_option(
    "--no-op", dest="skipOp", action="store_true", default=False,
    help="Skip all of the requested actions and just print what would be done.")
    
  clp.add_option(
    "--show-defaults", dest="showDefaults", action="store_true", default=False,
    help="[ACTION] Show the defaults and exit." )

  clp.add_option(
    "--initial-setup", dest="doInitialSetup", action="store_true", default=False,
    help="[ACTION] Create base directories under <dev_env_base>/ and install" \
      " load_dev_env.[sh,csh].")

  clp.add_option(
    "--download", dest="doDownload", action="store_true", default=False,
    help="[ACTION] Download all of the tools specified by --common-tools" \
      " and --compiler-toolset.  WARNING:  If the source for a tool has" \
      " already been downloaded, it will be deleted (along with the build" \
      " directory) and downloaded from scratch!")

  clp.add_option(
    "--install", dest="doInstall", action="store_true", default=False,
    help="[ACTION] Configure, build, and install all of the tools specified by" \
      " --common-tools and --compiler-toolset.")
    
  clp.add_option(
    "--show-final-instructions", dest="showFinalInstructions", action="store_true",
    default=False,
    help="[ACTION] Show final instructions for using the installed dev env." )

  clp.add_option(
    "--do-all", dest="doAll", action="store_true", default=False,
    help="[AGGR ACTION] Do everything.  Implies --initial-setup --downlaod" \
      +" --install --show-final-instructions")

  (options, args) = clp.parse_args(args=cmndLineArgs)

  # NOTE: Above, in the pairs of boolean options, the *last* add_option(...) 
  # takes effect!  That is why the commands are ordered the way they are!

  #
  # Echo the command-line
  #

  if not skipEchoCmndLine:

    cmndLine = "**************************************************************************\n"
    cmndLine +=  "Script: install-devtools.py \\\n"
    cmndLine +=  "  --install-dir='"+options.installDir+"' \\\n"
    cmndLine += InstallProgramDriver.echoInsertPermissionsOptions(options)
    cmndLine +=  "  --source-git-url-base='"+options.sourceGitUrlBase+"' \\\n"
    cmndLine +=  "  --load-dev-env-file-base-name='"+options.loadDevEnvFileBaseName+"' \\\n"
    cmndLine +=  "  --common-tools='"+options.commonTools+"' \\\n"
    cmndLine +=  "  --compiler-toolset='"+options.compilerToolset+"' \\\n"
    cmndLine +=  "  --parallel='"+options.parallelLevel+"' \\\n"
    if not options.skipOp:
      cmndLine +=  "  --do-op \\\n"
    else:
      cmndLine +=  "  --no-op \\\n"
    if options.doInitialSetup:
      cmndLine +=  "  --initial-setup \\\n"
    if options.doDownload:
      cmndLine +=  "  --download \\\n"
    if options.doInstall:
      cmndLine +=  "  --install \\\n"
    if options.showFinalInstructions:
      cmndLine +=  "  --show-final-instructions \\\n"
    if options.doAll:
      cmndLine +=  "  --do-all \\\n"

    print(cmndLine)

    if options.showDefaults:
      sys.exit(0);

  #
  # Check the input arguments
  #

  if options.installDir == "":
    print("\nError, you must set --install-dir=<dev_env_base>!")
    raise Exception("Bad input option --install-dir")
  options.installDir = os.path.abspath(os.path.expanduser(options.installDir))

  if options.commonTools == "all":
    options.commonTools = ",".join(commonToolsArray)
  #print("options.commonTools = '"+options.commonTools+"'")

  if options.compilerToolset == "all":
    options.compilerToolset = ",".join(compilerToolsetArray)
  #print("options.compilerToolset = '"+options.compilerToolset+"'")

  if options.doAll:
    options.doInitialSetup = True
    options.doDownload = True
    options.doInstall = True
    options.showFinalInstructions = True

  #
  # Return the options
  #

  return options
Exemple #17
0
        specpath = getCmndOutput(
            gccExec + " --print-file libgcc.a | sed 's|/libgcc.a||'", True)
        print "specpath = " + specpath
        rpath = ""
        libPath = rpathbase + "/lib"
        if os.path.exists(libPath):
            rpath = appendToRPath(rpath, libPath)
        lib64Path = rpathbase + "/lib64"
        if os.path.exists(lib64Path):
            rpath = appendToRPath(rpath, lib64Path)
        print "rpath will be: '" + rpath + "'"
        specsfile = specpath + "/specs"
        if os.path.exists(specsfile):
            print "Backing up the existing GCC specs file '" + specsfile + "' ..."
            echoRunSysCmnd("cp " + specsfile + " " + specsfile + ".backup")
        print "Writing to GCC specs file " + specsfile
        gccSpecs = getCmndOutput(gccExec + " -dumpspecs", True)
        #print "gccSpecs:\n", gccSpecs
        gccSpecsMod = addRpathToLink(gccSpecs, rpath)
        #print "gccSpecsMod:\n", gccSpecsMod
        writeStrToFile(specsfile, gccSpecsMod)


#
# Executable statements
#

gitInstaller = InstallProgramDriver(GccInstall())

gitInstaller.runDriver()
Exemple #18
0
    def doBuild(self):
        echoChDir(self.autoconfBuildBaseDir)
        echoRunSysCmnd("make " + getParallelOpt(self.inOptions, "-j") + self.inOptions.makeOptions)

    def doInstall(self):
        echoChDir(self.autoconfBuildBaseDir)
        echoRunSysCmnd("make " + getParallelOpt(self.inOptions, "-j") + self.inOptions.makeOptions + " install")

    def getFinalInstructions(self):
        return (
            """
To use the installed version of autoconf-"""
            + self.inOptions.version
            + """ add the path:

  """
            + self.inOptions.installDir
            + """/bin

to your path and that should be it!
"""
        )


#
# Executable statements
#

autoconfInstaller = InstallProgramDriver(AutoconfInstall())
autoconfInstaller.runDriver()