rewrite configure script

This commit is contained in:
Lephenixnoir 2021-01-11 22:18:22 +01:00
parent 7a4e5cde3b
commit 431633612f
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495

66
configure vendored
View file

@ -1,41 +1,21 @@
#! /bin/bash #! /usr/bin/env bash
# # Install prefix
# Output variables
#
# Path parameters
PREFIX="$HOME/.local" PREFIX="$HOME/.local"
# Individual component selection # Individual component selection
BUILD_fxsdk=1 BUILD_fxsdk=1
BUILD_fxconv=1 BUILD_fxconv=1
BUILD_fxg1a=1 BUILD_fxg1a=1
# help() {
# Tool name checking
#
check()
{
[[ $1 = "fxsdk" ]] ||
[[ $1 = "fxconv" ]] ||
[[ $1 = "fxg1a" ]]
}
#
# Usage
#
help()
{
cat << EOF cat << EOF
Configuration options for the fxSDK (fx9860g and fxcg50 development tools). Configuration options for the fxSDK (fx9860g and fxcg50 development tools).
Tool selection: Tool selection:
<tool> may be one of the following: <tool> may be one of the following:
"fxsdk" Command-line options (you generally want this) fxsdk Project management (you generally want this)
"fxconv" Asset conversion for gint (or any 4-aligned-VRAM system) fxconv Asset conversion for standard and custom gint formats
"fxg1a" G1A file wrapper, editor and analyzer fxg1a G1A file wrapper, editor and analyzer
--enable-<tool> Build and install the selected tool [default] --enable-<tool> Build and install the selected tool [default]
--disable-<tool> Do not build or install the selected tool --disable-<tool> Do not build or install the selected tool
@ -49,10 +29,7 @@ EOF
exit 0 exit 0
} }
# # Parse arguments
# Argument parsing
#
for arg; do case "$arg" in for arg; do case "$arg" in
-h | -? | --help) -h | -? | --help)
help;; help;;
@ -62,20 +39,18 @@ for arg; do case "$arg" in
--enable-*) --enable-*)
tool="${arg#--enable-}" tool="${arg#--enable-}"
if ! check $tool; then if [[ ! ":fxsdk:fxg1a:fxconv:" =~ ":$tool:" ]]; then
echo "error: cannot enable $tool: unknown tool" echo "error: $arg: no such tool"
exit 1 exit 1
fi fi
eval "BUILD_${tool}=1";; eval "BUILD_${tool}=1";;
--disable-*) --disable-*)
tool="${arg#--disable-}" tool="${arg#--disable-}"
if ! check $tool; then if [[ ! ":fxsdk:fxg1a:fxconv:" =~ ":$tool:" ]]; then
echo "error: cannot disable $tool: unknown tool" echo "error: $arg: no such tool"
exit 1 exit 1
fi fi
eval "BUILD_${tool}=0";; eval "BUILD_${tool}=0";;
*) *)
@ -83,28 +58,17 @@ for arg; do case "$arg" in
exit 1;; exit 1;;
esac; done esac; done
# # Generate sub-Makefile with configuration details
# Makefile generation gen() {
#
gen()
{
# Allow an install script to change the destination at the last second # Allow an install script to change the destination at the last second
# to have all files in a separate root before packaging # to have all files in a separate root before packaging
# TODO: Support DESTDIR instead
echo "PREFIX ?= $PREFIX" echo "PREFIX ?= $PREFIX"
echo -n "TARGETS =" echo -n "TARGETS ="
[[ $BUILD_fxsdk = 1 ]] && echo -n " fxsdk" [[ $BUILD_fxsdk = 1 ]] && echo -n " fxsdk"
[[ $BUILD_fxconv = 1 ]] && echo -n " fxconv" [[ $BUILD_fxconv = 1 ]] && echo -n " fxconv"
[[ $BUILD_fxg1a = 1 ]] && echo -n " fxg1a" [[ $BUILD_fxg1a = 1 ]] && echo -n " fxg1a"
echo "" echo ""
} }
echo "Configuration complete, the following has been saved in Makefile.cfg:" gen > Makefile.cfg
echo ""
gen | tee Makefile.cfg
echo ""
echo "You can now 'make'."