mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2024-12-29 13:03:36 +01:00
163 lines
4.2 KiB
Bash
Executable file
163 lines
4.2 KiB
Bash
Executable file
#! /bin/bash
|
|
|
|
#
|
|
# Basic configuration
|
|
#
|
|
|
|
declare -A conf
|
|
|
|
# Target platform
|
|
conf_target=
|
|
|
|
# Behavior
|
|
conf[GINT_BOOT_LOG]=
|
|
conf[GINT_NO_SYSCALLS]=
|
|
conf[GINT_EXTENDED_LIBC]=
|
|
conf[GINT_STATIC_GRAY]=
|
|
|
|
# Size limits
|
|
conf[ATEXIT_MAX]=16
|
|
conf[TIMER_SLOTS]=16
|
|
conf[EVENTS_QUEUE_SIZE]=64
|
|
|
|
# Output files
|
|
output="config/Makefile.cfg"
|
|
|
|
#
|
|
# Help screen and output util
|
|
#
|
|
|
|
error="\e[31;1merror:\e[0m"
|
|
C_="$(echo -e '\e[30;1m')"
|
|
Cr="$(echo -e '\e[31;1m')"
|
|
Cg="$(echo -e '\e[32;1m')"
|
|
Cp="$(echo -e '\e[34;1m')"
|
|
C0="$(echo -e '\e[0m')"
|
|
|
|
help()
|
|
{
|
|
cat << EOF
|
|
Configuration script for the gint library.
|
|
Usage: $0 [options...]
|
|
|
|
Required settings:
|
|
$Cr--target$C0=${Cg}fx9860g$C0,${Cg}fxcg50$C0
|
|
Select the target platform, either ${Cg}fx9860g$C0 for monochrome
|
|
calculators, or ${Cg}fxcg50$C0 for Prizm calculators.
|
|
|
|
Options that affect the behavior of the library:
|
|
$Cr--boot-log $C_[default:$Cp not specified$C_]$C0
|
|
Enable an on-screen log at startup if a key is kept pressed while launching
|
|
the add-in, allowing easy debug and crash diagnoses.
|
|
$Cr--no-syscalls $C_[default:$Cp not specified$C_]$C0
|
|
Never use syscalls. Expect trouble with malloc() and the gray engine. Do
|
|
not trigger this switch unless you know what you are doing.
|
|
$Cr--extended-libc $C_[default:$Cp not specified$C_]$C0
|
|
Enable specific C99 headers/features that are normally not required by
|
|
calculator programs. This may allow porting programs from other platforms.
|
|
$Cr--static-gray-engine $C_[default:$Cp not specified$C_]$C0
|
|
Place the gray engine vram in static ram instead of using the heap. Always
|
|
use this option when using both the gray engine and --no-syscalls.
|
|
|
|
Options that customize size limits:
|
|
$Cr--atexit-max$C0=${Cg}integer$C_ [default:$Cp 16$C_]$C0
|
|
Number of exit handlers that can be registered by atexit().
|
|
$Cr--timer-slots$C0=${Cg}integer$C_ [default:$Cp 16$C_]$C0
|
|
Number of virtual timers that may be registered at the same time.
|
|
$Cr--events-queue-size$C0=${Cg}integer$C_ [default:$Cp 64$C_]$C0
|
|
Number of events simultaneously stored in the event queue.
|
|
EOF
|
|
|
|
exit 0
|
|
}
|
|
|
|
#
|
|
# Parsing arguments
|
|
#
|
|
|
|
fail=false
|
|
for arg; do case "$arg" in
|
|
-h | -? | --help) help;;
|
|
|
|
--target=*)
|
|
conf_target=${arg#*=}
|
|
if [[ $conf_target = "fx9860g" ]]; then
|
|
conf_target="GINT_FX9860G"
|
|
else if [[ $conf_target = "fxcg50" ]]; then
|
|
conf_target="GINT_FXCG50"
|
|
else
|
|
echo -e "$error Invalid target. See $0 --help."
|
|
fail=true;
|
|
fi; fi;;
|
|
|
|
--boot-log) conf[GINT_BOOT_LOG]=true;;
|
|
--no-syscalls) conf[GINT_NO_SYSCALLS]=true;;
|
|
--extended-libc) conf[GINT_EXTENDED_LIBC]=true;;
|
|
--static-gray-engine) conf[GINT_STATIC_GRAY]=true;;
|
|
|
|
--atexit-max=*)
|
|
size=${arg#*=}
|
|
if [[ $size == +([0-9]) ]]; then
|
|
conf[ATEXIT_MAX]=$size
|
|
else echo -e "$error --atexit-max expects an integer value"
|
|
fail=true; fi;;
|
|
--timer-slots=*)
|
|
size=${arg#*=}
|
|
if [[ $size == +([0-9]) ]]; then
|
|
conf[TIMER_SLOTS]=$size
|
|
else echo -e "$error --timer-slots expects an integer value"
|
|
fail=true; fi;;
|
|
--events-queue-size=*)
|
|
size=${arg#*=}
|
|
if [[ $size == +([0-9]) ]]; then
|
|
conf[EVENTS_QUEUE_SIZE]=$size
|
|
else echo -e "$error --events-queue-size expects an integer"\
|
|
"value"
|
|
fail=true; fi;;
|
|
|
|
--atexit-max | --timer-slots | --events-queue-size)
|
|
echo -e "$error syntax for $arg is $arg=<integer-value>";;
|
|
|
|
*)
|
|
echo -e "$error unrecognized argument '$arg'"; fail=true;;
|
|
esac; done
|
|
|
|
#
|
|
# Checking mandatory arguments
|
|
#
|
|
|
|
if [[ ! $conf_target ]]; then
|
|
echo -e "$error No target specified. See $0 --help."
|
|
fail=true;
|
|
fi
|
|
|
|
#
|
|
# Output config
|
|
#
|
|
|
|
output_config()
|
|
{
|
|
echo -n "cfg_defs ="
|
|
echo -n " -D$conf_target"
|
|
|
|
[ "${conf[GINT_BOOT_LOG]}" ] && echo -n " -DGINT_BOOT_LOG"
|
|
[ "${conf[GINT_NO_SYSCALLS]}" ] && echo -n " -DGINT_NO_SYSCALLS"
|
|
[ "${conf[GINT_EXTENDED_LIBC]}" ] && echo -n " -DGINT_EXTENDED_LIBC"
|
|
[ "${conf[GINT_STATIC_GRAY]}" ] && echo -n " -DGINT_STATIC_GRAY"
|
|
|
|
echo -n " -DATEXIT_MAX=${conf[ATEXIT_MAX]}"
|
|
echo -n " -DTIMER_SLOTS=${conf[TIMER_SLOTS]}"
|
|
echo -n " -DEVENTS_QUEUE_SIZE=${conf[EVENTS_QUEUE_SIZE]}"
|
|
|
|
echo ""
|
|
|
|
[ "${conf[GINT_EXTENDED_LIBC]}" != "" ] && echo "cfg_ext = true"
|
|
}
|
|
|
|
if $fail; then
|
|
echo "Output file $output has not been modified."
|
|
else
|
|
mkdir -p config
|
|
output_config > $output
|
|
echo "Configuration saved in $output, ready to make!"
|
|
fi
|