#!/bin/sh
set -eu

srcdir=$(dirname "$0")
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT

cp "$srcdir/smoke.cpp" "$tmpdir/"
cd "$tmpdir"

CXX=${CXX:-g++}
MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH)

# Link against the shared library (the default for -lgcsa2) and run.
$CXX -std=c++17 -Wall -Wextra -o smoke-shared smoke.cpp -lgcsa2 -lsdsl -fopenmp -pthread
./smoke-shared

# Link against the static library and run.
$CXX -std=c++17 -Wall -Wextra -o smoke-static smoke.cpp \
    "/usr/lib/$MULTIARCH/libgcsa2.a" -lsdsl -fopenmp -pthread
./smoke-static

echo "shared and static linking both OK"
