buildpackage.sh

来自「MPI stands for the Message Passing Inter」· Shell 代码 · 共 551 行 · 第 1/2 页

SH
551
字号
#!/bin/bash# Copyright (c) 2001-2006 The Trustees of Indiana University.  #                         All rights reserved.# Copyright (c) 2006-2007 Los Alamos National Security, LLC.  All rights#                         reserved. # # This file is part of the Open MPI software package.  For license# information, see the LICENSE file in the top level directory of the# Open MPI source distribution.#### Build a Mac OS X package for use by Installer.app## Usage: buildpackage.sh <tarball> [prefix]## Prefix defaults to /usr/local########################################################################## Configuration Options########################################################################### User-configurable stuff#OMPI_PACKAGE="openmpi"OMPI_PREFIX="/usr/local/"OMPI_OPTIONS="--disable-mpi-f77 --without-cs-fs --enable-mca-no-build=ras-slurm,pls-slurm,gpr-null,sds-pipe,sds-slurm,pml-cm NM=\"nm -p\""OMPI_OSX_README="ReadMe.rtf"# note - if want XGrid support, make sure that a cocoa-supported # architecture appears first on the list.  Otherwise, we won't# lipo that component and it will be droppedOMPI_ARCH_LIST="ppc ppc64 i386 x86_64"OMPI_SDK="/Developer/SDKs/MacOSX10.4u.sdk"## Not so modifiable stuff#BUILD_TMP="/tmp/buildpackage-$$"if test ! "$2" = ""; then    OMPI_PREFIX="$2"fiOMPI_STARTDIR=`pwd`echo "--> Configuration options:"echo "    Package Name:   $OMPI_PACKAGE"echo "    Prefix:         $OMPI_PREFIX"echo "    Config Options: $OMPI_OPTIONS"echo "    Architectures:  $OMPI_ARCH_LIST"echo "    Target SDK:     $OMPI_SDK"echo ""########################################################################## Start actual code that does stuff########################################################################### Sanity check#fulltarball="$1"if test "$fulltarball" = ""; then    echo "Usage: buildpackage.sh <tarball> [prefix]"    exit 1fiif test ! -f $fulltarball; then    echo "*** Can't find $fulltarball!"    exit 1fiecho "--> Found tarball: $fulltarball"## Find version info#tarball=`basename $fulltarball`first="`echo $tarball | cut -d- -f2`"version="`echo $first | sed -e 's/\.tar\.gz//'`"unset firstecho "--> Found OMPI version: $version"OMPI_VER_PACKAGE="${OMPI_PACKAGE}-${version}"## Sanity check that we can continue#if test -d "/Volumes/${OMPI_VER_PACKAGE}"; then    echo "*** Already have disk image (/Volumes/${OMPI_VER_PACKAGE}) mounted."    echo "*** Unmount and try again"    exit 1fiif test ! -r "${OMPI_OSX_README}"; then    echo "*** Can not find ${OMPI_OSX_README} in `pwd`."    exit 1else    OMPI_OSX_README="`pwd`/${OMPI_OSX_README}"fi## Clean out the environment a bit#echo "--> Cleaning environment"PATH=/bin:/sbin/:/usr/binLANGUAGE=CLC_ALL=CLC_MESSAGES=LANG=export PATH LANGUAGE LC_ALL LC_MESSAGES LANGunset LD_LIBRARY_PATH CC CXX FC F77 OBJC## Make some play space#echo "--> Making play space: $BUILD_TMP"if test -d $BUILD_TMP; then    echo "Build dir $BUILD_TMP exists - exiting"    exit 1fi# -p is safe - will only run on OS Xmkdir -p $BUILD_TMP########################################################################## Configure, Build, and Install Open MPI########################################################################### Put tarball in right place#echo "--> Copying tarball"cp $fulltarball $BUILD_TMP/.cd $BUILD_TMP## Expand tarball## we know there can't be spaces in $tarball - filename onlycmd="tar xzf $tarball"echo "--> Untarring source: $cmd"eval $cmdsrcdir="$BUILD_TMP/openmpi-$version"if test ! -d "$srcdir"; then    echo "*** Didn't find $srcdir as expected - aborting"    exit 1fibuild_arch=`uname -p`"-apple-darwin"`uname -r`real_install=1for arch in $OMPI_ARCH_LIST ; do    builddir="$BUILD_TMP/build-$arch"    mkdir "$builddir"    case "$arch" in        ppc)            host_arch="powerpc-apple-darwin"`uname -r`            ;;        ppc64)            # lie, but makes building on G4 easier            host_arch="powerpc64-apple-darwin"`uname -r`            ;;        i386)            host_arch="i386-apple-darwin"`uname -r`            ;;        x86_64)            host_arch="x86_64-apple-darwin"`uname -r`            ;;        *)            echo "**** Could not find arch string for $arch ****"            exit 1            ;;    esac    #    # Run configure    #     cd $builddir    config="$srcdir/configure CFLAGS=\"-arch $arch -isysroot $OMPI_SDK\" CXXFLAGS=\"-arch $arch -isysroot $OMPI_SDK\" OBJCFLAGS=\"-arch $arch -isysroot $OMPI_SDK\" --prefix=$OMPI_PREFIX $OMPI_OPTIONS --build=$build_arch --host=$host_arch"    echo "--> Running configure: $config"    eval $config > "$BUILD_TMP/configure.out-$arch" 2>&1    if test $? != 0; then        echo "*** Problem running configure - aborting!"        echo "*** See $BUILD_TMP/configure.out-$arch for help."        exit 1    fi    #    # Build    #    cmd="make -j 4 all"    echo "--> Building: $cmd"    eval $cmd > "$BUILD_TMP/make.out-$arch" 2>&1    if test $? != 0; then        echo "*** Problem building - aborting!"        echo "*** See $BUILD_TMP/make.out-$arch for help."        exit 1    fi    #    # Install into tmp place    #    if test $real_install -eq 1 ; then        distdir="dist"        real_install=0    else        distdir="dist-$arch"    fi    fulldistdir="$BUILD_TMP/$distdir"    cmd="make DESTDIR=$fulldistdir install"    echo "--> Installing:"    eval $cmd > "$BUILD_TMP/install.out-$arch" 2>&1    if test $? != 0; then        echo "*** Problem installing - aborting!"        echo "*** See $BUILD_TMP/install.out-$arch for help."        exit 1    fi    #    # Copy in special doc files    #    SPECIAL_FILES="README LICENSE"    echo "--> Copying in special files: $SPECIAL_FILES"    pushd $srcdir >/dev/null    mkdir -p  "${fulldistdir}/${OMPI_PREFIX}/share/openmpi/doc"    cp $SPECIAL_FILES "${fulldistdir}/${OMPI_PREFIX}/share/openmpi/doc/."    if [ ! $? = 0 ]; then        echo "*** Problem copying files $SPECIAL_FILES.  Aborting!"        exit 1    fi    popd >/dev/null    distdir=    fulldistdir=done########################################################################## Make the fat binary#########################################################################print_arch_if() {    case "$1" in        ppc)            echo "#ifdef __ppc__" >> mpi.h            ;;        ppc64)            echo "#ifdef __ppc64__" >> mpi.h            ;;        i386)            echo "#ifdef __i386__" >> mpi.h            ;;        x86_64)            echo "#ifdef __x86_64__" >> mpi.h            ;;        *)            echo "*** Could not find arch #ifdef for $1"            exit 1            ;;    esac

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?