anarch/make.sh

101 lines
2.4 KiB
Bash
Raw Permalink Normal View History

2021-05-28 17:35:52 -04:00
#!/bin/sh
2020-11-21 06:06:45 -05:00
2020-10-08 13:33:02 -04:00
# Optional helper build script for Anarch.
2020-09-11 14:24:41 -04:00
# by drummyfish, released under CC0 1.0, public domain
2020-10-08 13:26:45 -04:00
#
# usage:
#
# ./make.sh platform [compiler]
2020-09-11 14:24:41 -04:00
2020-10-08 13:26:45 -04:00
if [ $# -lt 1 ]; then
2020-09-26 19:24:41 -04:00
echo "need a parameter (sdl, pokitto, gb, emscripten, ...)"
2020-09-11 14:24:41 -04:00
exit 0
fi
clear; clear;
2023-09-08 16:11:10 -04:00
C_FLAGS="-std=c99 -Wall -Wextra -pedantic -O3 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -o anarch"
2020-09-11 14:24:41 -04:00
2020-10-08 13:26:45 -04:00
COMPILER='g++'
if [ $# -eq 2 ]; then
COMPILER=$2
2020-10-10 10:06:08 -04:00
2021-05-28 17:38:00 -04:00
if [ $2 = "tcc" ]; then # you'll probably want to modify this
2020-10-10 10:06:08 -04:00
C_FLAGS="${C_FLAGS} -L/usr/lib/x86_64-linux-gnu/pulseaudio/
-I/home/tastyfish/git/tcc/tcc-0.9.27/include
-I/usr/lib/gcc/x86_64-linux-gnu/8/include/"
fi
2020-10-08 13:26:45 -04:00
fi
2020-10-08 13:33:02 -04:00
echo "compiling"
2021-05-28 17:38:00 -04:00
if [ $1 = "sdl" ]; then
2020-09-11 14:24:41 -04:00
# PC SDL build, requires:
2020-09-26 19:24:41 -04:00
# - g++
2020-09-11 14:24:41 -04:00
# - SDL2 (dev) package
2023-09-08 16:11:10 -04:00
SDL_FLAGS=`sdl2-config --cflags --libs --static-libs`
2021-05-28 17:35:52 -04:00
COMMAND="${COMPILER} ${C_FLAGS} main_sdl.c -I/usr/local/include ${SDL_FLAGS}"
2020-10-08 13:33:02 -04:00
echo ${COMMAND}
2021-10-13 20:27:21 -04:00
${COMMAND}
elif [ $1 = "saf" ]; then
# SAF build using SDL, requires:
# - saf.h
# - SDL2 (dev) package
2023-09-08 16:11:10 -04:00
SDL_FLAGS=`sdl2-config --cflags --libs --static-libs`
2021-10-13 20:27:21 -04:00
COMMAND="${COMPILER} ${C_FLAGS} main_saf.c -I/usr/local/include ${SDL_FLAGS}"
echo ${COMMAND}
2021-06-16 16:58:28 -04:00
${COMMAND}
2021-05-28 17:38:00 -04:00
elif [ $1 = "terminal" ]; then
2020-10-05 14:15:04 -04:00
# PC terminal build, requires:
# - g++
2020-09-11 14:24:41 -04:00
2020-10-08 13:33:02 -04:00
COMMAND="${COMPILER} ${C_FLAGS} main_terminal.c"
echo ${COMMAND}
2021-06-16 16:58:28 -04:00
${COMMAND}
2021-05-28 17:38:00 -04:00
elif [ $1 = "csfml" ]; then
2020-10-25 13:34:47 -04:00
# csfml build, requires:
# - csfml
COMMAND="${COMPILER} ${C_FLAGS} main_csfml.c -lcsfml-graphics -lcsfml-window -lcsfml-system -lcsfml-audio"
echo ${COMMAND}
2021-06-16 16:58:28 -04:00
${COMMAND}
2021-05-28 17:38:00 -04:00
elif [ $1 = "test" ]; then
2020-10-24 16:41:31 -04:00
# test build, requires:
# - g++
COMMAND="${COMPILER} ${C_FLAGS} main_test.c"
echo ${COMMAND}
2021-06-16 16:58:28 -04:00
${COMMAND}
2021-05-28 17:38:00 -04:00
elif [ $1 = "pokitto" ]; then
2020-09-11 14:24:41 -04:00
# Pokitto build, requires:
# - PokittoLib, in this folder create a symlink named "PokittoLib" to the
# "Pokitto" subfolder of PokittoLib
# - Pokitto Makefile
# - GNU embedded toolchain, in this folder create a symlink named "gtc" to the
# "bin" subfolder
# - files like My_settings.h required by Pokitto
make
./PokittoEmu BUILD/firmware.bin
2021-05-28 17:38:00 -04:00
elif [ $1 = "emscripten" ]; then
2020-09-26 19:24:41 -04:00
# emscripten (browser Javascript) build, requires:
# - emscripten
2020-10-24 11:43:41 -04:00
../emsdk/upstream/emscripten/emcc ./main_sdl.c -s USE_SDL=2 -O3 -lopenal --shell-file HTMLshell.html -o anarch.html -s EXPORTED_FUNCTIONS='["_main","_webButton"]' -s EXPORTED_RUNTIME_METHODS='["ccall","cwrap"]'
2020-09-11 14:24:41 -04:00
else
echo "unknown parameter: $1"
fi