2016-11-05 22:00:23 +01:00
|
|
|
#! /bin/bash
|
|
|
|
|
2017-02-25 19:02:07 +01:00
|
|
|
#
|
|
|
|
# Basic configuration
|
|
|
|
#
|
|
|
|
|
2016-11-05 22:00:23 +01:00
|
|
|
declare -A conf
|
2017-02-25 19:02:07 +01:00
|
|
|
|
2018-04-09 08:31:12 +02:00
|
|
|
# Target platform
|
|
|
|
conf_target=
|
|
|
|
|
2017-02-25 19:02:07 +01:00
|
|
|
# Behavior
|
2018-04-09 08:31:12 +02:00
|
|
|
conf[GINT_BOOT_LOG]=
|
2017-02-25 19:02:07 +01:00
|
|
|
conf[GINT_NO_SYSCALLS]=
|
2018-08-01 20:41:36 +02:00
|
|
|
cong[GINT_LAX]=
|
2017-02-25 19:02:07 +01:00
|
|
|
conf[GINT_EXTENDED_LIBC]=
|
2017-07-05 21:38:12 +02:00
|
|
|
conf[GINT_STATIC_GRAY]=
|
2017-02-25 19:02:07 +01:00
|
|
|
|
|
|
|
# Size limits
|
2016-11-05 22:00:23 +01:00
|
|
|
conf[ATEXIT_MAX]=16
|
2017-03-01 11:07:28 +01:00
|
|
|
conf[TIMER_SLOTS]=16
|
2016-11-05 22:00:23 +01:00
|
|
|
conf[EVENTS_QUEUE_SIZE]=64
|
2017-02-25 19:02:07 +01:00
|
|
|
|
|
|
|
# Output files
|
2018-04-09 08:31:12 +02:00
|
|
|
output="config/Makefile.cfg"
|
2017-01-22 18:35:02 +01:00
|
|
|
|
2017-02-25 19:02:07 +01:00
|
|
|
#
|
|
|
|
# Help screen and output util
|
|
|
|
#
|
|
|
|
|
2017-01-22 18:35:02 +01:00
|
|
|
error="\e[31;1merror:\e[0m"
|
2018-04-09 08:31:12 +02:00
|
|
|
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')"
|
2016-11-05 22:00:23 +01:00
|
|
|
|
|
|
|
help()
|
|
|
|
{
|
|
|
|
cat << EOF
|
|
|
|
Configuration script for the gint library.
|
2018-04-09 08:31:12 +02:00
|
|
|
Usage: $0 [options...]
|
|
|
|
|
2018-04-19 13:24:26 +02:00
|
|
|
Platform settings (specify exactly one):
|
|
|
|
${Cg}-fx9860g$C0
|
|
|
|
Target platform is fx-9860G II: all monochrome models that support add-ins
|
|
|
|
or can be flashed to support them.
|
|
|
|
${Cg}-fxcg50$C0
|
2018-08-01 20:41:36 +02:00
|
|
|
Target platform is fx-CG 50; there is some compatibility with fx-CG 10/20.
|
2016-11-05 22:00:23 +01:00
|
|
|
|
2018-08-01 20:41:36 +02:00
|
|
|
Options that affect the behavior of the library $C_[${Cp}default$C_]$C0:
|
|
|
|
$Cr-boot-log $C_[${Cp}disabled$C_]$C0
|
2018-04-09 08:31:12 +02:00
|
|
|
Enable an on-screen log at startup if a key is kept pressed while launching
|
2017-07-05 21:38:12 +02:00
|
|
|
the add-in, allowing easy debug and crash diagnoses.
|
2018-08-01 20:41:36 +02:00
|
|
|
$Cr-no-syscalls $C_[${Cp}disabled$C_]$C0
|
2017-07-05 21:38:12 +02:00
|
|
|
Never use syscalls. Expect trouble with malloc() and the gray engine. Do
|
2017-02-25 19:02:07 +01:00
|
|
|
not trigger this switch unless you know what you are doing.
|
2018-08-01 20:41:36 +02:00
|
|
|
$Cr-lax $C_[${Cp}disabled$C_]$C0
|
|
|
|
Make more assumptions about functions parameters. This disables coordinate
|
|
|
|
checks in drawing functions. Be careful!
|
|
|
|
$Cr-extended-libc $C_[${Cp}disabled$C_]$C0
|
2017-02-25 19:02:07 +01:00
|
|
|
Enable specific C99 headers/features that are normally not required by
|
|
|
|
calculator programs. This may allow porting programs from other platforms.
|
2018-08-01 20:41:36 +02:00
|
|
|
$Cr-static-gray-engine $C_[${Cp}disabled$C_]$C0
|
2017-07-05 21:38:12 +02:00
|
|
|
Place the gray engine vram in static ram instead of using the heap. Always
|
2018-04-19 13:24:26 +02:00
|
|
|
use this option when using both the gray engine and -no-syscalls.
|
2016-11-05 22:00:23 +01:00
|
|
|
|
2018-08-01 20:41:36 +02:00
|
|
|
Options that customize size limits $C_[${Cp}default$C_]$C0:
|
|
|
|
$Cr-atexit-max$C0=${Cg}integer$C_ [${Cp}16$C_]$C0
|
2017-02-25 19:02:07 +01:00
|
|
|
Number of exit handlers that can be registered by atexit().
|
2018-08-01 20:41:36 +02:00
|
|
|
$Cr-timer-slots$C0=${Cg}integer$C_ [${Cp}16$C_]$C0
|
2017-03-01 11:07:28 +01:00
|
|
|
Number of virtual timers that may be registered at the same time.
|
2018-08-01 20:41:36 +02:00
|
|
|
$Cr-events-queue-size$C0=${Cg}integer$C_ [${Cp}64$C_]$C0
|
2017-02-25 19:02:07 +01:00
|
|
|
Number of events simultaneously stored in the event queue.
|
2016-11-05 22:00:23 +01:00
|
|
|
EOF
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2017-02-25 19:02:07 +01:00
|
|
|
#
|
|
|
|
# Parsing arguments
|
|
|
|
#
|
|
|
|
|
|
|
|
fail=false
|
2016-11-05 22:00:23 +01:00
|
|
|
for arg; do case "$arg" in
|
2018-04-09 08:31:12 +02:00
|
|
|
-h | -? | --help) help;;
|
|
|
|
|
2018-04-19 13:24:26 +02:00
|
|
|
-fx9860g)
|
|
|
|
conf_target="FX9860G";;
|
|
|
|
-fxcg50)
|
|
|
|
conf_target="FXCG50";;
|
|
|
|
|
|
|
|
-boot-log) conf[GINT_BOOT_LOG]=true;;
|
|
|
|
-no-syscalls) conf[GINT_NO_SYSCALLS]=true;;
|
2018-08-01 20:41:36 +02:00
|
|
|
-lax) conf[GINT_LAX]=true;;
|
2018-04-19 13:24:26 +02:00
|
|
|
-extended-libc) conf[GINT_EXTENDED_LIBC]=true;;
|
|
|
|
-static-gray-engine) conf[GINT_STATIC_GRAY]=true;;
|
|
|
|
|
|
|
|
-atexit-max=*)
|
2016-11-05 22:00:23 +01:00
|
|
|
size=${arg#*=}
|
|
|
|
if [[ $size == +([0-9]) ]]; then
|
|
|
|
conf[ATEXIT_MAX]=$size
|
2018-04-19 13:24:26 +02:00
|
|
|
else echo -e "$error -atexit-max expects an integer value"
|
2016-11-05 22:00:23 +01:00
|
|
|
fail=true; fi;;
|
2018-04-19 13:24:26 +02:00
|
|
|
-timer-slots=*)
|
2016-11-05 22:00:23 +01:00
|
|
|
size=${arg#*=}
|
|
|
|
if [[ $size == +([0-9]) ]]; then
|
2017-03-01 11:07:28 +01:00
|
|
|
conf[TIMER_SLOTS]=$size
|
2018-04-19 13:24:26 +02:00
|
|
|
else echo -e "$error -timer-slots expects an integer value"
|
2016-11-05 22:00:23 +01:00
|
|
|
fail=true; fi;;
|
2018-04-19 13:24:26 +02:00
|
|
|
-events-queue-size=*)
|
2016-11-05 22:00:23 +01:00
|
|
|
size=${arg#*=}
|
|
|
|
if [[ $size == +([0-9]) ]]; then
|
|
|
|
conf[EVENTS_QUEUE_SIZE]=$size
|
2018-04-19 13:24:26 +02:00
|
|
|
else echo -e "$error -events-queue-size expects an integer"\
|
2017-01-22 18:35:02 +01:00
|
|
|
"value"
|
2016-11-05 22:00:23 +01:00
|
|
|
fail=true; fi;;
|
|
|
|
|
2018-04-19 13:24:26 +02:00
|
|
|
-atexit-max | -timer-slots | -events-queue-size)
|
2017-01-22 18:35:02 +01:00
|
|
|
echo -e "$error syntax for $arg is $arg=<integer-value>";;
|
2016-11-05 22:00:23 +01:00
|
|
|
|
|
|
|
*)
|
2017-01-22 18:35:02 +01:00
|
|
|
echo -e "$error unrecognized argument '$arg'"; fail=true;;
|
2016-11-05 22:00:23 +01:00
|
|
|
esac; done
|
|
|
|
|
2017-02-25 19:02:07 +01:00
|
|
|
#
|
2018-04-09 08:31:12 +02:00
|
|
|
# Checking mandatory arguments
|
2017-02-25 19:02:07 +01:00
|
|
|
#
|
|
|
|
|
2018-04-09 08:31:12 +02:00
|
|
|
if [[ ! $conf_target ]]; then
|
|
|
|
echo -e "$error No target specified. See $0 --help."
|
|
|
|
fail=true;
|
|
|
|
fi
|
2016-11-05 22:00:23 +01:00
|
|
|
|
2017-02-25 19:02:07 +01:00
|
|
|
#
|
|
|
|
# Output config
|
|
|
|
#
|
|
|
|
|
2018-04-09 08:31:12 +02:00
|
|
|
output_config()
|
|
|
|
{
|
2018-04-19 13:24:26 +02:00
|
|
|
[ ${conf_target} == "FX9860G" ] \
|
|
|
|
&& echo "cfg_target = fx" \
|
|
|
|
|| echo "cfg_target = cg"
|
|
|
|
|
|
|
|
echo -n "cfg_macros ="
|
2018-04-09 08:31:12 +02:00
|
|
|
echo -n " -D$conf_target"
|
|
|
|
|
|
|
|
[ "${conf[GINT_BOOT_LOG]}" ] && echo -n " -DGINT_BOOT_LOG"
|
|
|
|
[ "${conf[GINT_NO_SYSCALLS]}" ] && echo -n " -DGINT_NO_SYSCALLS"
|
2018-08-01 20:41:36 +02:00
|
|
|
[ "${conf[GINT_LAX]}" ] && echo -n " -DGINT_LAX"
|
2018-04-09 08:31:12 +02:00
|
|
|
[ "${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"
|
|
|
|
}
|
|
|
|
|
2016-11-05 22:00:23 +01:00
|
|
|
if $fail; then
|
2018-04-09 08:31:12 +02:00
|
|
|
echo "Output file $output has not been modified."
|
2016-11-05 22:00:23 +01:00
|
|
|
else
|
2018-04-09 08:31:12 +02:00
|
|
|
mkdir -p config
|
|
|
|
output_config > $output
|
|
|
|
echo "Configuration saved in $output, ready to make!"
|
2016-11-05 22:00:23 +01:00
|
|
|
fi
|