Blame win/build-program-win.sh

173ebc
#!/bin/bash
173ebc
173ebc
set -e
173ebc
94a33e
if [ -z "$TARGETPATH" ]; then
94a33e
	TARGETPATH="$(pwd)"
94a33e
fi
94a33e
173ebc
PROGNAME="$1"
173ebc
ARGS=()
173ebc
for file in ${@:2}; do
173ebc
	FILEPATH="$(realpath $file)"
173ebc
    ARGS+=("$FILEPATH")
173ebc
	echo "add file: $FILEPATH"
173ebc
done
173ebc
173ebc
173ebc
if [ -z "$PROGNAME" ] || [ -z "$ARGS" ]; then
173ebc
	echo "Usage: $0 program_name file1.c file2.c ..."
94a33e
	echo "You may set environment variable TARGETPATH - the full path to target directory"
173ebc
	exit 1
173ebc
fi
173ebc
173ebc
ROOT="$(cd `dirname "$0"`; pwd)"
173ebc
cd "$ROOT"
173ebc
173ebc
source function.sh
173ebc
source toolchain.sh
173ebc
173ebc
56274e
if [ -z "OPTIONS" ]; then
56274e
	OPTIONS="-O3 -DNDEBUG"
56274e
	#OPTIONS="-g -O0"
56274e
fi
56274e
56274e
COMP="CC"
56274e
COMP_OPTIONS=
56274e
if [ "$COMPILER" = "c++" ]; then
56274e
	COMP="CXX"
56274e
	COMP_OPTIONS="-static-libstdc++"
56274e
fi
56274e
173ebc
173ebc
packages=""
173ebc
newpackages="program"
173ebc
173ebc
#######################################################################
173ebc
173ebc
173ebc
function build_program() {
56274e
	local CMP=${!COMP}
1b8859
	if [ -z "$LINUX" ]; then
56274e
		echocall $CMP \
1b8859
			"${ARGS[@]}" \
1b8859
			-Wall $OPTIONS \
1b8859
			-I"$ROOT/release/include/helianthus" \
1b8859
			"$ROOT/release/lib-$bits/libhelianthus.a" \
1b8859
			-lmingw32 -mconsole \
56274e
			-lm -static-libgcc $COMP_OPTIONS \
1b8859
			-lopengl32 -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lshlwapi \
1b8859
			-lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid \
1b8859
			-o "$TARGETPATH/$PROGNAME-$bits.exe"
1b8859
	else
56274e
		echocall $CMP \
1b8859
			"${ARGS[@]}" \
1b8859
			-Wall $OPTIONS \
1b8859
			-I"$ROOT/release/include/helianthus" \
1b8859
			"$ROOT/release/lib-$bits/libhelianthus.a" \
56274e
			-lm -static-libgcc $COMP_OPTIONS -lGL -ldl -pthread \
1b8859
			-o "$TARGETPATH/$PROGNAME-$bits"
1b8859
	fi
173ebc
}
173ebc
173ebc
173ebc
#######################################################################
173ebc
173ebc
173ebc
rm -f build*/program.done
1b8859
build win32 i686-w64-mingw32
1b8859
build win64 x86_64-w64-mingw32
1b8859
#LINUX=1 ADDCFLAGS="-m32 -fPIC" build linux32 ""
1b8859
LINUX=1 ADDCFLAGS=-fPIC build linux64 ""
173ebc
rm -f build*/program.done
173ebc
173ebc
print_section done