#!/bin/bash

SCRIPT_DIR="$(dirname $0)"
LIB_SRC="$1"
INSTALL_PREFIX="$2"
shift 2
INCLUDES="$@"

mkdir -p "$INSTALL_PREFIX"

BASE_INCLUDE_DIR="$(dirname "$LIB_SRC")"
find $BASE_INCLUDE_DIR -maxdepth 1 -type f -name "*.h" -exec cp -v {} "$INSTALL_PREFIX" \;

cd "$SCRIPT_DIR/../src"
for INCLUDE in $INCLUDES; do
  for f in $(find "$INCLUDE" -type f -name "*.h"); do
    DST="$INSTALL_PREFIX/$(dirname $f)"
    mkdir -p "$DST"
    cp -v "$f" "$DST"
  done
done
