#!/bin/sh

# Copy the files needed to build dkms.
# Currently dkms needs to re-run configure, and therefore carries
# all the files configure rewrites.

# Usage: parameter: target directory to copy files to

set -e

files="
configure.ac autogen.sh dkms.conf.in include kernel lib m4 test Makefile.am
cray-xpmem.pc.in module.in
"

gen_files="
config.guess config.h.in config.sub configure Makefile.in ltmain.sh ar-lib
compile missing install-sh dkms.conf aclocal.m4
"

target_dir="$1"
rm -rf "$target_dir"
mkdir -p "$target_dir"

cp -a $files "$target_dir/"
for f in $gen_files
do
    [ -e "$f" ] && cp -a "$f" "$target_dir/" || :
done
