#!/bin/sh
#
# Copyright (C) 2005-2011 ABINIT Group (Yann Pouillon)
#
# This file is part of the ABINIT software package. For license information,
# please see the COPYING file in the top-level directory of the ABINIT source
# distribution.
#

#
# IMPORTANT NOTE:
#
#   For maintainer use only!
#
#   PLEASE DO NOT EDIT THIS FILE, AS IT COULD CAUSE A SERIOUS LOSS OF DATA.
#   *** YOU HAVE BEEN WARNED! ***
#

# Check that we are in the right directory
if test ! -s "./configure.ac" -o ! -s "src/98_main/abinit.F90"; then
  echo "clean-source-tree: Cowardly refusing to remove something from here!"
  exit 1
fi

# Print warning
cat >&2 <<EOF
WARNING: clean-source-tree has been deprecated and will soon be removed!

Please use "makemake -c" or "makemake --clean" instead.

If you want to keep script-generated source files in the tree, you may
use in addition the "-k" or "--keep-source" option of makemake.

EOF
sleep 5

# Check whether the "--keep-source" option has been used
extra_opts=""
for arg in ${*}; do
  if test "${arg}" = "--keep-source"; then
    extra_opts="--keep-source"
  fi
done

# Call makemake
./config/scripts/makemake --clean ${extra_opts}
