#!/bin/sh
set -e

BUILD_TREE=$1
DEST=$2

echo "Compiling ijar..."
g++ -o "$DEST" \
    $CPPFLAGS $CXXFLAGS \
    -DBLAZE_OPENSOURCE \
    -I"$BUILD_TREE" \
    "$BUILD_TREE/third_party/ijar/classfile.cc" \
    "$BUILD_TREE/third_party/ijar/ijar.cc" \
    "$BUILD_TREE/third_party/ijar/zip.cc" \
    "$BUILD_TREE/third_party/ijar/platform_utils.cc" \
    "$BUILD_TREE/third_party/ijar/mapped_file_unix.cc" \
    "$BUILD_TREE/third_party/ijar/zlib_client.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" \
    $LDFLAGS -lz
echo "ijar compiled successfully."
