#! /bin/bash # # Basic configuration # declare -A conf # Target platform conf_target= # Behavior conf[GINT_BOOT_LOG]= conf[GINT_NO_SYSCALLS]= cong[GINT_LAX]= 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...] 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 Target platform is fx-CG 50; there is some compatibility with fx-CG 10/20. Options that affect the behavior of the library $C_[${Cp}default$C_]$C0: $Cr-boot-log $C_[${Cp}disabled$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_[${Cp}disabled$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-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 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_[${Cp}disabled$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 $C_[${Cp}default$C_]$C0: $Cr-atexit-max$C0=${Cg}integer$C_ [${Cp}16$C_]$C0 Number of exit handlers that can be registered by atexit(). $Cr-timer-slots$C0=${Cg}integer$C_ [${Cp}16$C_]$C0 Number of virtual timers that may be registered at the same time. $Cr-events-queue-size$C0=${Cg}integer$C_ [${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;; -fx9860g) conf_target="FX9860G";; -fxcg50) conf_target="FXCG50";; -boot-log) conf[GINT_BOOT_LOG]=true;; -no-syscalls) conf[GINT_NO_SYSCALLS]=true;; -lax) conf[GINT_LAX]=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=";; *) 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() { [ ${conf_target} == "FX9860G" ] \ && echo "cfg_target = fx" \ || echo "cfg_target = cg" echo -n "cfg_macros =" 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_LAX]}" ] && echo -n " -DGINT_LAX" [ "${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