105 lines
3.7 KiB
Bash
Executable File
105 lines
3.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# POSIX shell configure script for GBA development
|
|
#
|
|
#
|
|
# Copyright (c) 2021 nytpu <alex [at] nytpu.com>
|
|
# SPDX-License-Identifier: BSL-1.0
|
|
# The orginal source for this file is available at <https://git.sr.ht/~nytpu/tonc-template>.
|
|
#
|
|
# Permission is hereby granted, free of charge, to any person or organization
|
|
# obtaining a copy of the software and accompanying documentation covered by
|
|
# this license (the "Software") to use, reproduce, display, distribute,
|
|
# execute, and transmit the Software, and to prepare derivative works of the
|
|
# Software, and to permit third-parties to whom the Software is furnished to
|
|
# do so, all subject to the following:
|
|
#
|
|
# The copyright notices in the Software and this entire statement, including
|
|
# the above license grant, this restriction and the following disclaimer, must
|
|
# be included in all copies of the Software, in whole or in part, and all
|
|
# derivative works of the Software, unless such copies or derivative works are
|
|
# solely in the form of machine-executable object code generated by a source
|
|
# language processor.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
# FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
# SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
# FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
# DEALINGS IN THE SOFTWARE.
|
|
set -eu
|
|
|
|
# redirect stdout to config.mk beyond this point
|
|
exec >config.mk
|
|
|
|
echo "# Configuration for Makefile"
|
|
echo "# This file was generated automatically by configure. Don't edit."
|
|
|
|
while getopts "h" opt; do
|
|
case "${opt}" in
|
|
(h)
|
|
exec 1>&2
|
|
printf "usage: [ENV=VAR] %s\n" "$0"
|
|
printf "\nsupported environment variables:\n"
|
|
printf "\tDEVKITPRO path to the devkitPro installation\n"
|
|
printf "\tCFLAGS additional flags for the C compiler\n"
|
|
printf "\tASFLAGS additional flags for the assembler\n"
|
|
printf "\tLDFLAGS additional flags for the linker\n"
|
|
exit 0
|
|
;;
|
|
(?)
|
|
printf "%s: invalid option '%c'\n" "$0" "${opt}" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
[ -n "${CFLAGS:-}" ] && printf "CFLAGS += %s\n" "${CFLAGS}"
|
|
[ -n "${ASFLAGS:-}" ] && printf "ASFLAGS += %s\n" "${ASFLAGS}"
|
|
[ -n "${LDFLAGS:-}" ] && printf "LDFLAGS += %s\n" "${LDFLAGS}"
|
|
|
|
if [ -z "${DEVKITPRO:-}" ] || ! [ -d "${DEVKITPRO:-}" ]; then
|
|
exec 1>&2
|
|
printf "Couldn't find devkitPro directory.\n"
|
|
printf "Please set the \$DEVKITPRO environment variable.\n"
|
|
exit 1
|
|
fi
|
|
|
|
dkptools="${DEVKITPRO}/tools/bin"
|
|
armtoolchain="${DEVKITPRO}/devkitARM/bin"
|
|
|
|
# verify all required stuff exists
|
|
if ! [ -d "${DEVKITPRO}/libtonc" ]; then
|
|
exec 1>&2
|
|
printf "Couldn't find libtonc.\n"
|
|
printf "Ensure that \$DEVKITPRO/libtonc exists and contains\n"
|
|
printf "the \"lib/\" and \"include/\" directories.\n"
|
|
exit 1
|
|
fi
|
|
if ! [ -d "${dkptools}" ]; then
|
|
exec 1>&2
|
|
printf "Couldn't find devkitPro tools.\n"
|
|
printf "Ensure that \$DEVKITPRO/tools/bin exists and contains:\n"
|
|
printf "\tgbafix\n\tpadbin\n\tgrit\n\tgbfs\n"
|
|
exit 1
|
|
fi
|
|
if ! [ -d "${armtoolchain}" ]; then
|
|
exec 1>&2
|
|
printf "Couldn't find the devkitARM toolchain.\n"
|
|
printf "Ensure that \$DEVKITPRO/devkitARM/bin exists and contains:\n"
|
|
printf "\tarm-none-eabi-gcc\n\tarm-none-eabi-as\n\tarm-none-eabi-objcopy\n"
|
|
exit 1
|
|
fi
|
|
|
|
echo "CC = ${armtoolchain}/arm-none-eabi-gcc"
|
|
echo "AS = ${armtoolchain}/arm-none-eabi-as"
|
|
echo "OBJCOPY = ${armtoolchain}/arm-none-eabi-objcopy"
|
|
echo "GBAFIX = ${dkptools}/gbafix"
|
|
echo "PADBIN = ${dkptools}/padbin"
|
|
echo "GRIT = ${dkptools}/grit"
|
|
echo "GBFS = ${dkptools}/gbfs"
|
|
echo "LDFLAGS += -L${DEVKITPRO}/libtonc/lib"
|
|
echo "CFLAGS += -I${DEVKITPRO}/libtonc/include"
|
|
|
|
exit 0
|