1#!/bin/bash 2set -o verbose 3set -o errexit 4 5# This script fetches and creates a copy of sources for snappy 6# snappy uses autotools on posix, and nothing on Windows 7# Snappy has the same config.h file on Darwin and Solaris, Linux is unique 8# The difference is byteswap.h 9# To get the sources for Snappy, run this script as follows: 10# 1. Run on Darwin or Solaris 11# 2. Run on Linux 12 13VERSION=1.1.3 14NAME=snappy 15TARBALL=$NAME-$VERSION.tar.gz 16TARBALL_DIR=$NAME-$VERSION 17TARBALL_DEST_DIR=$NAME-$VERSION 18TEMP_DIR=/tmp/temp-$NAME-$VERSION 19DEST_DIR=`git rev-parse --show-toplevel`/src/third_party/$NAME-$VERSION 20UNAME=`uname | tr A-Z a-z` 21 22if [ $UNAME == "linux" ]; then 23 TARGET_UNAME=linux 24else 25 TARGET_UNAME=posix 26fi 27 28echo TARGET_UNAME: $TARGET_UNAME 29 30if [ ! -f $TARBALL ]; then 31 echo "Get tarball" 32 wget https://github.com/google/$NAME/releases/download/$VERSION/$NAME-$VERSION.tar.gz 33fi 34 35echo $TARBALL 36tar -zxvf $TARBALL 37 38rm -rf $TEMP_DIR 39mv $TARBALL_DIR $TEMP_DIR 40mkdir $DEST_DIR || true 41 42cd $TEMP_DIR 43if [ $TARGET_UNAME != "windows" ]; then 44 # Do a shallow copy, it is all we need 45 cp $TEMP_DIR/* $DEST_DIR || true 46 rm -f $DEST_DIR/Makefile* $DEST_DIR/config* $DEST_DIR/*sh 47 rm -f $DEST_DIR/compile* $DEST_DIR/depcomp $DEST_DIR/libtool 48 rm -f $DEST_DIR/test-driver $DEST_DIR/*.m4 $DEST_DIR/missing 49 50 echo "Generating Config.h and other files" 51 ./configure 52 53 # Copy over the platform independent generated files 54 cp $TEMP_DIR/snappy-stubs-public.h $DEST_DIR 55 56 # Copy over config.h 57 mkdir $DEST_DIR/build_$TARGET_UNAME 58 cp $TEMP_DIR/config.h $DEST_DIR/build_$TARGET_UNAME 59fi 60 61 62echo "Done" 63