#!/bin/sh -xeu # This script will detect the OS, and try to grab the libraries. And then # creates a tarball for distribution. # Check if another config is being sourced. set +u if [ -z "$TUP_CONFIG" ]; then . ./tup.config else . ./"$TUP_CONFIG" fi set -u WINDOWS="false" # Windows needs special treatment mkdir -p "$CONFIG_INSTALL_PREFIX/libs" case "$(uname -s)" in MINGW*) for i in $(ldd "$CONFIG_BUILD_DIR"/bin/Pong* | awk '/mingw*/ {print $3}'); do cp "$i" "$CONFIG_INSTALL_PREFIX/" done WINDOWS="true" ;; Linux) for i in $(ldd "$CONFIG_BUILD_DIR"/bin/Pong* | awk '/usr/ {print $3}'); do cp "$i" "$CONFIG_INSTALL_PREFIX/libs/" done ;; NetBSD) # NetBSD, unlike the other BSDs keep their packages in /usr/pkg for i in $(ldd "$CONFIG_BUILD_DIR"/bin/Pong* | awk '/usr\/pkg/ {print $3}'); do cp "$i" "$CONFIG_INSTALL_PREFIX/libs/" done ;; OpenBSD) for i in $(ldd "$CONFIG_BUILD_DIR"/bin/Pong* | awk '/usr\/local/ {print $7}'); do cp "$i" "$CONFIG_INSTALL_PREFIX/libs/" done ;; SunOS) for i in $(ldd "$CONFIG_BUILD_DIR"/bin/Pong* | awk '/usr\/lib/ {print $3}'); do cp "$i" "$CONFIG_INSTALL_PREFIX/libs/" done ;; *BSD) # BSDs keep installed packages in /usr/local for i in $(ldd "$CONFIG_BUILD_DIR"/bin/Pong* | awk '/usr\/local/ {print $3}'); do cp "$i" "$CONFIG_INSTALL_PREFIX/libs/" done ;; Darwin) # Try to see if my otool-tree program is there, if not, just use otool. # (WARNING: otool on it's own, only shows directly linked libraries, but # doesn't show the libraries needed by those said libraries. if which otool-tree > /dev/null; then for i in $(otool-tree "$CONFIG_BUILD_DIR"/bin/Pong* | awk '/usr\/local/'); do cp "$i" "$CONFIG_INSTALL_PREFIX/libs/" done else for i in $(otool -L "$CONFIG_BUILD_DIR"/bin/Pong* | awk '/usr\/local/{print $1}'); do cp "$i" "$CONFIG_INSTALL_PREFIX/libs/" done fi ;; *) echo "Unsupported System for distribute.sh, you'll have to package it yourself. =(" exit 1 ;; esac cd "$CONFIG_INSTALL_PREFIX" # Tarball the finish result! if [ "$WINDOWS" = "true" ]; then ARCHIVE_NAME="Pong_$(uname -s)-$(uname -r)" SEVENZIP="$(which 7z)" || SEVENZIP="/c/Program Files/7-Zip/7z.exe" if [ -f "$SEVENZIP" ]; then # Try to use 7z's self extracting feature if possible. "$SEVENZIP" a -sfx7z.sfx ../"$ARCHIVE_NAME".exe -- * else # If not, just create a standard zip file. zip -9 -r ../"$ARCHIVE_NAME".zip -- * fi exit 0 else set +e # Remove GL drivers, as they almost always conflict with system driver. rm -f libs/libGL* rm -f libs/libdrm* rm -f libs/lib*xcb*.so* # Remove libstdc++ rm -f libs/libstdc++* set -e bsdtar --options gzip:compression-level=9 -caf ../Pong_"$(uname -s)-$(uname -r)-$(uname -m)".tgz -- * fi