mirror of
https://git.planet-casio.com/Lephenixnoir/gint.git
synced 2024-12-29 13:03:36 +01:00
136 lines
3.6 KiB
Bash
Executable file
136 lines
3.6 KiB
Bash
Executable file
#! /bin/bash
|
|
|
|
#
|
|
# Basic configuration
|
|
#
|
|
|
|
declare -A conf
|
|
|
|
# Behavior
|
|
conf[GINT_STARTUP_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_gcc="gcc.cfg"
|
|
output_make="Makefile.cfg"
|
|
|
|
#
|
|
# Help screen and output util
|
|
#
|
|
|
|
error="\e[31;1merror:\e[0m"
|
|
Cg="$(tput setaf 8)$(tput bold)"
|
|
Cr="$(tput setaf 1)$(tput bold)"
|
|
Cy="$(tput setaf 2)$(tput bold)"
|
|
Cp="$(tput setaf 5)$(tput setaf 62)$(tput bold)"
|
|
C0="$(tput setaf 0)$(tput sgr 0)"
|
|
|
|
help()
|
|
{
|
|
cat << EOF
|
|
Configuration script for the gint library.
|
|
|
|
Options that affect the behavior of the library:
|
|
$Cr--startup-log $Cg[default:$Cp false$Cg]$C0
|
|
Enable a 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 $Cg[default:$Cp false$Cg]$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 $Cg[default:$Cp false$Cg]$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 $Cg[default:$Cp false$Cg]$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=$Cy<integer>$Cg [default:$Cp 16$Cg]$C0
|
|
Number of exit handlers that can be registered by atexit().
|
|
$Cr--timer-slots$C0=$Cy<integer>$Cg [default:$Cp 16$Cg]$C0
|
|
Number of virtual timers that may be registered at the same time.
|
|
$Cr--events-queue-size$C0=$Cy<integer>$Cg [default:$Cp 64$Cg]$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;;
|
|
--startup-log) conf[GINT_STARTUP_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
|
|
|
|
#
|
|
# Output config routines
|
|
#
|
|
|
|
output_config_gcc()
|
|
{
|
|
[ "${conf[GINT_STARTUP_LOG]}" != "" ] && echo "-D GINT_STARTUP_LOG"
|
|
[ "${conf[GINT_NO_SYSCALLS]}" != "" ] && echo "-D GINT_NO_SYSCALLS"
|
|
[ "${conf[GINT_EXTENDED_LIBC]}" != "" ] && echo "-D GINT_EXTENDED_LIBC"
|
|
[ "${conf[GINT_STATIC_GRAY]}" != "" ] && echo "-D GINT_STATIC_GRAY"
|
|
|
|
echo "-D ATEXIT_MAX=${conf[ATEXIT_MAX]}"
|
|
echo "-D TIMER_SLOTS=${conf[TIMER_SLOTS]}"
|
|
echo "-D EVENTS_QUEUE_SIZE=${conf[EVENTS_QUEUE_SIZE]}"
|
|
}
|
|
|
|
output_config_make()
|
|
{
|
|
[ "${conf[GINT_EXTENDED_LIBC]}" != "" ] && echo "config_ext=true"
|
|
}
|
|
|
|
#
|
|
# Output config
|
|
#
|
|
|
|
if $fail; then
|
|
echo "Configuration has not been modified."
|
|
else
|
|
output_config_gcc > $output_gcc
|
|
output_config_make > $output_make
|
|
echo "Configuration saved in $output_gcc and $output_make."
|
|
fi
|