#!/bin/sh
#******************************************************************************#
#                                                                              #
#   configure                                                                  #
#   | Project : TuQuoque                                                       #
#                                                                              #
#   By: thomas <thomas@touhey.fr>                                              #
#   Last updated: 2016/05/28 16:08:11                                          #
#                                                                              #
#******************************************************************************#
# Defaults
reconf=false

# Help
usage() {
cat <<EOF
Usage: $0 [OPTION]

Miscallenous:
  --re                    remake the configuration

EOF
exit 0
}

# Args parsing
for arg in "$@"; do
case "$arg" in
--help|-h) usage ;;
--re) reconf=true ;;
*) echo "$arg: ignored" ;;
esac
done

# If Makefile configuration already exists, ragequit
if [ reconf = false ]; then
	if [ -f Makefile.cfg ]; then
		echo "Configuration is already loaded, skipping."
		exit 0
	fi
fi

# Create Makefile configuration
exec 3>&1 1>Makefile.cfg

cat <<EOF
#!/usr/bin/make -f
# Makefile configuration generated by ./configure
# - Ship
#  __
#  | \
# =[_|H)--._____
# =[+--,-------'
#  [|_/""
EOF

exec 1>&3 3>&-
chmod +x Makefile.cfg

# We're done
echo "Configuration loaded, you can make now."
