Blob Blame Raw
#!/bin/bash

set -e

TARGETPATH="$(pwd)"
PROGNAME="$1"
ARGS=()
for file in ${@:2}; do
	FILEPATH="$(realpath $file)"
    ARGS+=("$FILEPATH")
	echo "add file: $FILEPATH"
done


if [ -z "$PROGNAME" ] || [ -z "$ARGS" ]; then
	echo "Usage: $0 program_name file1.c file2.c ..."
	exit 1
fi

ROOT="$(cd `dirname "$0"`; pwd)"
cd "$ROOT"

source function.sh
source toolchain.sh


OPTIONS="-O3 -DNDEBUG"
#OPTIONS="-g -O0"

packages=""
newpackages="program"

#######################################################################


function build_program() {
	echocall $CC \
		"${ARGS[@]}" \
		-Wall $OPTIONS \
		-I"$ROOT/release/include/helianthus" \
		"$ROOT/release/lib$bits/libhelianthus.a" \
		-lmingw32 -mconsole \
		-lm -static-libgcc \
		-lopengl32 -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lshlwapi \
		-lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid \
		-o "$TARGETPATH/$PROGNAME$bits.exe"
}


#######################################################################


rm -f build*/program.done
build 32 i686-w64-mingw32
build 64 x86_64-w64-mingw32
rm -f build*/program.done

print_section done