#!/bin/sh
set -e

BUILD_TREE=$1
DEST=$2

echo "Compiling singlejar..."
g++ -o "$DEST" \
    $CPPFLAGS $CXXFLAGS \
    -DBLAZE_OPENSOURCE \
    -I"$BUILD_TREE" \
    -I"$BUILD_TREE/src/tools/singlejar" \
    "$BUILD_TREE/src/tools/singlejar/singlejar_main.cc" \
    "$BUILD_TREE/src/tools/singlejar/combiners.cc" \
    "$BUILD_TREE/src/tools/singlejar/input_jar.cc" \
    "$BUILD_TREE/src/tools/singlejar/mapped_file.cc" \
    "$BUILD_TREE/src/tools/singlejar/options.cc" \
    "$BUILD_TREE/src/tools/singlejar/output_jar.cc" \
    "$BUILD_TREE/src/main/cpp/util/file.cc" \
    "$BUILD_TREE/src/main/cpp/util/file_posix.cc" \
    "$BUILD_TREE/src/main/cpp/util/path.cc" \
    "$BUILD_TREE/src/main/cpp/util/path_posix.cc" \
    "$BUILD_TREE/src/main/cpp/util/errors_posix.cc" \
    "$BUILD_TREE/src/main/cpp/util/logging.cc" \
    "$BUILD_TREE/src/main/cpp/util/strings.cc" \
    "$BUILD_TREE/src/main/cpp/util/port.cc" \
    "$BUILD_TREE/src/main/cpp/util/md5.cc" \
    $LDFLAGS -lz
echo "singlejar compiled successfully."
