Skip to content

Instantly share code, notes, and snippets.

@benvanik
Created September 19, 2012 02:33
Show Gist options
  • Save benvanik/3747316 to your computer and use it in GitHub Desktop.
Save benvanik/3747316 to your computer and use it in GitHub Desktop.
Build gjstest from source
#!/bin/bash
# Copyright 2012 Google Inc. All Rights Reserved.
# Attempt to build gjstest.
# This is required as there is no package on Linux. There is on OSX, but then
# everyone would be using different versions. This only needs to be done when
# a new computer is setup or the submodule is bumped in the repo.
TEMP_PATH=/tmp/wtf-tools
PREFIX=$TEMP_PATH/local
# Setup a temp scratch path for all intermediates.
if [ ! -d "$TEMP_PATH" ]; then
mkdir $TEMP_PATH
fi
if [ ! -d "$PREFIX" ]; then
mkdir $PREFIX
fi
echo ""
# =============================================================================
# Grab dependencies all at once
# =============================================================================
echo "Grabbing all dependencies..."
cd $TEMP_PATH
git clone https://github.com/jacobsa/gjstest.git
svn checkout http://google-glog.googlecode.com/svn/trunk/ google-glog
hg clone https://re2.googlecode.com/hg re2
svn checkout http://protobuf.googlecode.com/svn/trunk/ protobuf
svn checkout http://gflags.googlecode.com/svn/trunk/ gflags
svn checkout http://v8.googlecode.com/svn/trunk/ v8
echo ""
# =============================================================================
# glog
# =============================================================================
echo "Building glog..."
cd $TEMP_PATH/google-glog/
./configure --prefix=$PREFIX
make install
echo ""
# =============================================================================
# re2
# =============================================================================
echo "Building re2..."
cd $TEMP_PATH/re2/
make -e prefix=$PREFIX
make -e prefix=$PREFIX install
echo ""
# =============================================================================
# protobuf
# =============================================================================
echo "Building protobuf..."
# Requires:
# - autoconf
# - automake
# - libtool
cd $TEMP_PATH/protobuf
./configure --prefix=$PREFIX
make install
echo ""
# =============================================================================
# gflags
# =============================================================================
echo "Building gflags..."
cd $TEMP_PATH/gflags/
./configure --prefix=$PREFIX
make install
echo ""
# =============================================================================
# v8
# =============================================================================
echo "Building v8..."
cd $TEMP_PATH/v8/
make dependencies
make disassembler=on x64.release library=shared
cp -R include $PREFIX/include/v8/
cp out/x64.release/* $PREFIX/bin/
cp out/x64.release/lib.target/* $PREFIX/lib/
echo ""
# =============================================================================
# gjstest
# =============================================================================
echo "Building gjstest..."
cd $TEMP_PATH/gjstest/
PREFIX_INCLUDE_PATH=$PREFIX/include/:$TEMP_PATH/v8/include/
PREFIX_LIB_PATH=$PREFIX/lib
# Need to fix up library/include paths.
if grep -q "# Preprocessor flags." Makefile ; then
sed 's|# Preprocessor flags.|CPPFLAGS += -L'"$PREFIX_LIB_PATH"'|' <Makefile >Makefile1
sed 's|export PREFIX = /usr/local|export PREFIX = '"$PREFIX"'|' <Makefile1 >Makefile
fi
# Make with our prefixes.
PATH=$PREFIX/bin/:$PATH \
C_INCLUDE_PATH=$PREFIX_INCLUDE_PATH:$C_INCLUDE_PATH \
CPLUS_INCLUDE_PATH=$PREFIX_INCLUDE_PATH:$CPLUS_INCLUDE_PATH \
make install
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PREFIX/bin/
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment