2016-11-05 22:00:23 +01:00
|
|
|
#! /bin/bash
|
|
|
|
|
2017-02-25 19:02:07 +01:00
|
|
|
#
|
|
|
|
# Basic configuration
|
|
|
|
#
|
|
|
|
|
2018-04-09 08:31:12 +02:00
|
|
|
# Target platform
|
2019-02-21 20:58:38 +01:00
|
|
|
target=
|
|
|
|
toolchain=
|
|
|
|
|
|
|
|
# Build options
|
|
|
|
prefix=
|
|
|
|
cflags=
|
2018-04-09 08:31:12 +02:00
|
|
|
|
2017-02-25 19:02:07 +01:00
|
|
|
# Behavior
|
2019-02-21 20:58:38 +01:00
|
|
|
boot_log=
|
|
|
|
no_syscalls=
|
|
|
|
static_gray=
|
2017-02-25 19:02:07 +01:00
|
|
|
|
|
|
|
# Size limits
|
2019-02-21 20:58:38 +01:00
|
|
|
atexit_max=
|
2017-02-25 19:02:07 +01:00
|
|
|
|
|
|
|
# Output files
|
2019-02-21 20:58:38 +01:00
|
|
|
output="Makefile.cfg"
|
2017-01-22 18:35:02 +01:00
|
|
|
|
2017-02-25 19:02:07 +01:00
|
|
|
#
|
2019-02-21 20:58:38 +01:00
|
|
|
# Help screen
|
2017-02-25 19:02:07 +01:00
|
|
|
#
|
|
|
|
|
2016-11-05 22:00:23 +01:00
|
|
|
help()
|
|
|
|
{
|
2019-02-21 20:58:38 +01:00
|
|
|
cat << EOF
|
2016-11-05 22:00:23 +01:00
|
|
|
Configuration script for the gint library.
|
2018-04-09 08:31:12 +02:00
|
|
|
Usage: $0 [options...]
|
|
|
|
|
2019-02-21 20:58:38 +01:00
|
|
|
You should build out-of-tree by creating a build directory and configuring from
|
|
|
|
there.
|
|
|
|
|
|
|
|
Target selection:
|
|
|
|
--target=fx9860g|fxcg50
|
|
|
|
|
|
|
|
fx9860g covers all fx-9860G II-like monochromes models that support add-ins
|
|
|
|
or can be flashed with an OS that does. This includes SH3 and SH4 machines.
|
|
|
|
Default toolchain is 'sh3eb-elf'.
|
|
|
|
|
|
|
|
fxcg50 covers just the fx-CG 50; there is some unofficial compatibility with
|
|
|
|
fx-CG 10/20. All of these are SH4-only.
|
2019-03-10 15:45:34 +01:00
|
|
|
Default toolchain is 'sh4eb-elf'.
|
2019-02-21 20:58:38 +01:00
|
|
|
|
|
|
|
Build options:
|
|
|
|
--toolchain=TRIPLET Build with a different toolchain
|
|
|
|
--prefix=PREFIX Install prefix (PREFIX/lib and PREFIX/include are used)
|
|
|
|
--cflags=FLAGS Additional compiler flags at end of command
|
|
|
|
|
|
|
|
Library options (disabled by default):
|
|
|
|
--boot-log Display a boot debug log at startup if a key is pressed
|
|
|
|
Used to investigate unstabilities.
|
|
|
|
--no-syscalls Cut off all syscalls (this will break things)
|
|
|
|
Only use this option if you have a good idea of which.
|
|
|
|
--static-gray Allocate gray VRAMs in static RAM instead of the heap
|
|
|
|
May help when --no-syscalls is on.
|
|
|
|
|
|
|
|
Size limits:
|
|
|
|
--atexit-max=NUM Number of exit handlers in atexit()'s array [16]
|
|
|
|
|
|
|
|
Deprecated options (to be removed):
|
|
|
|
-extended-libc Provide a few C99 headers (in the future, refer to the
|
|
|
|
newlib port by Memallox's for the standard library)
|
|
|
|
-timer-slots=<n> Number of virtual timer slots (this feature will be
|
|
|
|
moved to an independent library) [16]
|
|
|
|
-events-queue-size=<n>
|
|
|
|
Size of event queue (this mechanism is likely to
|
|
|
|
disappear in future versions) [64]
|
2016-11-05 22:00:23 +01:00
|
|
|
EOF
|
2019-02-21 20:58:38 +01:00
|
|
|
exit 0
|
2016-11-05 22:00:23 +01:00
|
|
|
}
|
|
|
|
|
2019-02-21 20:58:38 +01:00
|
|
|
if [[ "$@" == "--help" ]]; then
|
|
|
|
help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -f make/Makefile ]]; then
|
|
|
|
echo "error: you should configure from a build directory, like this:" >&2
|
|
|
|
echo " mkdir build && cd build && ../configure [options..]" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
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
|
2019-02-21 20:58:38 +01:00
|
|
|
-h | -? | --help)
|
|
|
|
help;;
|
|
|
|
|
|
|
|
--target=*)
|
|
|
|
case ${arg#*=} in
|
|
|
|
"fx9860g")
|
|
|
|
target=fx9860g
|
|
|
|
toolchain=${toolchain:-sh3eb-elf};;
|
|
|
|
"fxcg50")
|
|
|
|
target=fxcg50
|
2019-03-10 15:45:34 +01:00
|
|
|
toolchain=${toolchain:-sh4eb-elf};;
|
2019-02-21 20:58:38 +01:00
|
|
|
*)
|
|
|
|
echo "error: invalid target '$target'"
|
|
|
|
fail=true
|
|
|
|
esac;;
|
2019-03-10 15:45:34 +01:00
|
|
|
--toolchain=*)
|
|
|
|
toolchain=${arg#*=};;
|
2019-02-21 20:58:38 +01:00
|
|
|
|
|
|
|
--prefix=*)
|
|
|
|
prefix=${arg#*=};;
|
|
|
|
--cflags=*)
|
|
|
|
cflags=${arg#*=};;
|
|
|
|
|
|
|
|
--boot-log)
|
|
|
|
boot_log=true;;
|
|
|
|
--no-syscalls)
|
|
|
|
no_syscalls=true;;
|
|
|
|
--static-gray)
|
|
|
|
static_gray=true;;
|
|
|
|
|
|
|
|
--atexit-max=*)
|
|
|
|
n=${arg#*=}
|
|
|
|
if [[ $n == +([0-9]) ]]; then
|
|
|
|
atexit_max=$n
|
|
|
|
else
|
|
|
|
echo -e "error: -atexit-max expects an integer value"
|
|
|
|
fail=true
|
|
|
|
fi;;
|
|
|
|
|
|
|
|
--atexit-max)
|
|
|
|
echo "error: '$arg' expects a value (see '$0 --help')";
|
|
|
|
fail=true;;
|
|
|
|
|
|
|
|
-extended-libc)
|
|
|
|
echo "warning: support for '-extended-libc' has been removed";;
|
|
|
|
-timer-slots=*)
|
|
|
|
echo "warning: support for '-timer-slots' has been removed";;
|
|
|
|
-events-queue-size=*)
|
|
|
|
echo "warning: support for '-events-queue-size' has been removed";;
|
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
|
|
|
#
|
|
|
|
|
2019-02-21 20:58:38 +01:00
|
|
|
if [[ -z "$target" ]]; then
|
|
|
|
echo "error: no target specified! (see '$0 --help')"
|
|
|
|
fail=true;
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If no prefix is specified, install to the GCC's build folder
|
|
|
|
if [[ -z "$prefix" ]]; then
|
|
|
|
echo "No prefix specified, let's ask the compiler:"
|
|
|
|
echo " $toolchain-gcc --print-search-dirs | grep install | sed 's/install: //'"
|
|
|
|
inst=$($toolchain-gcc --print-search-dirs | grep install | sed 's/install: //')
|
|
|
|
|
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
echo "Call returned $?, giving up."
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Got '$inst'".
|
|
|
|
|
|
|
|
if [[ ! -d $inst ]]; then
|
|
|
|
echo "Directory does not exist (or is not a directory), giving up."
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
prefix=$inst
|
2018-04-09 08:31:12 +02:00
|
|
|
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()
|
|
|
|
{
|
2019-02-21 20:58:38 +01:00
|
|
|
mod=${target/98/fx}
|
|
|
|
echo "CONFIG.TARGET = ${mod:2:2}"
|
|
|
|
echo "CONFIG.TARGET.LONG = $target"
|
|
|
|
|
|
|
|
[[ $prefix ]] && echo "PREFIX = $prefix"
|
|
|
|
[[ $toolchain ]] && echo "CONFIG.TOOLCHAIN = $toolchain"
|
|
|
|
[[ $cflags ]] && echo "CONFIG.CFLAGS = $cflags"
|
|
|
|
|
|
|
|
echo -n "CONFIG.MACROS ="
|
|
|
|
echo -n " -D$(echo $target | tr 'a-z' 'A-Z')"
|
|
|
|
[[ "$boot_log" ]] && echo -n " -DGINT_BOOT_LOG"
|
|
|
|
[[ "$no_syscalls" ]] && echo -n " -DGINT_NO_SYSCALLS"
|
|
|
|
[[ "$static_gray" ]] && echo -n " -DGINT_STATIC_GRAY"
|
|
|
|
[[ "$atexit_max" ]] && echo -n " -DATEXIT_MAX=$atexit_max"
|
|
|
|
echo ""
|
|
|
|
}
|
2018-04-09 08:31:12 +02:00
|
|
|
|
2019-02-21 20:58:38 +01:00
|
|
|
if $fail; then
|
|
|
|
echo "note: output file $output has not been changed."
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-04-09 08:31:12 +02:00
|
|
|
|
2019-02-21 20:58:38 +01:00
|
|
|
output_config > $output
|
2018-04-09 08:31:12 +02:00
|
|
|
|
2019-02-21 20:58:38 +01:00
|
|
|
src="Makefile"
|
|
|
|
dst="../make/Makefile"
|
2018-04-09 08:31:12 +02:00
|
|
|
|
2019-02-21 20:58:38 +01:00
|
|
|
[[ -L $src && $(readlink $src) == $dst ]] && rm $src
|
|
|
|
ln -s $dst $src
|
2018-04-09 08:31:12 +02:00
|
|
|
|
2019-02-21 20:58:38 +01:00
|
|
|
echo "Configuration saved in $output, ready to make!"
|