1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-05 05:59:04 -08:00

add arm support to mw script, sepples flags

This commit is contained in:
Connor Olding 2013-12-22 15:00:43 -08:00
parent fefe2abe22
commit 5904072f41
2 changed files with 33 additions and 19 deletions

View file

@ -24,10 +24,12 @@ done
export PREFIX="$HOME/opt/local"
export CC="$(has clang || has gcc)"
export CXX="$(has clang || has g++)"
export CFLAGS='-march=native -O2'
export LDFLAGS='-Wl,-O1,--sort-common,-z,relro'
export CFLAGS="$CFLAGS -I'$HOME/opt/local/include'"
export LDFLAGS="$LDFLAGS -L'$HOME/opt/local/lib'"
export CXXFLAGS="$CFLAGS"
export LD_LIBRARY_PATH= # -n isn't an option in zsh's export
export EDITOR='vim -p'

50
sh/mw
View file

@ -4,6 +4,7 @@ mkdir -p ~/opt/mingw
_mw_enabled=0
_mw_host32=i686-w64-mingw32
_mw_host64=x86_64-w64-mingw32
_mw_hostarm=arm-linux-gnueabi
_mw_host=$_mw_host64
typeset -Ag _mw_ # cryptic math expression errors if not global!
@ -14,36 +15,39 @@ _mw_export() {
export "$1=$2"
}
mingw-disable() {
mw-disable() {
[ $_mw_enabled -eq 0 ] && return 1
_mw_enabled=0
local e=
for e in PATH PREFIX CC CPP CXX CFLAGS CPPFLAGS CXXFLAGS LDFLAGS AR RANLIB RC WINDRES SDL_CFLAGS SDL_LDLIBS; do
for e in PATH PREFIX CC CPP CXX LD CFLAGS CPPFLAGS CXXFLAGS LDFLAGS AR RANLIB RC WINDRES SDL_CFLAGS SDL_LDLIBS; do
local v="${_mw_[$e]}"
[ -n "$v" ] && export "$e=$v" || unset "$e"
done
echo "mingw disabled"
echo "mw disabled"
}
mingw-enable() {
[ $_mw_enabled -eq 1 ] && mingw-disable || true
mw-enable() {
[ $_mw_enabled -eq 1 ] && mw-disable || true
_mw_enabled=1
_mw_host=${1:-$_mw_host}
local _mw_misc=~/src/mxe/usr/$_mw_host
local _mw_bin=~/src/mxe/usr/bin
_mw_usr=${2:-/usr}
local _mw_misc=$_mw_usr/$_mw_host
local _mw_bin=$_mw_usr/bin
local _mw_prefix=~/opt/$_mw_host
mkdir -p "$_mw_prefix"
set -- CC gcc CXX g++ CPP cpp AR ar RANLIB ranlib RC windres WINDRES windres
set -- CC gcc CXX g++ CPP cpp LD ld AR ar RANLIB ranlib RC windres WINDRES windres
while _mw_export "$1" "$_mw_bin/$_mw_host-$2"; do
shift 2
done
_mw_export PATH "$PATH:$_mw_bin"
_mw_export PREFIX "$_mw_prefix"
_mw_export CFLAGS "-mwin32 -O2 -I $_mw_misc/include -I $_mw_prefix/include"
_mw_export CFLAGS "-O2 -I $_mw_misc/include -I $_mw_prefix/include"
_mw_export LDFLAGS "-L $_mw_misc/lib -L $_mw_prefix/lib"
_mw_export CPPFLAGS ''
_mw_export CXXFLAGS "$CFLAGS"
@ -55,27 +59,35 @@ mingw-enable() {
_mw_export SDL_LDLIBS "$($_mw_host-sdl2-config --libs)"
}
echo "mingw enabled ($_mw_host)"
echo "mw enabled ($_mw_host)"
return 0
}
mw() {
if [ "$#" -eq 1 ]; then
if [ "$1" -eq 32 ]; then
mingw-enable $_mw_host32
elif [ "$1" -eq 64 ]; then
mingw-enable $_mw_host64
elif [ "$1" -eq 0 ]; then
mingw-disable
if [[ "$1" == 32 ]]; then
mw-enable $_mw_host32 ~/src/mxe/usr
export CFLAGS="-mwin32 $CFLAGS"
export CXXFLAGS="$CFLAGS"
elif [[ "$1" == 64 ]]; then
mw-enable $_mw_host64 ~/src/mxe/usr
export CFLAGS="-mwin32 $CFLAGS"
export CXXFLAGS="$CFLAGS"
elif [[ "$1" == arm ]]; then
mw-enable $_mw_hostarm /usr
export CFLAGS="-mfloat-abi=hard -mcpu=cortex-a9 $CFLAGS"
export CXXFLAGS="$CFLAGS"
elif [[ "$1" == 0 ]]; then
mw-disable
else
echo "usage: mw [0/32/64]"
echo "usage: mw [0/32/64/arm]"
return 1
fi
else
if [ $_mw_enabled -eq 0 ]; then
mingw-enable
mw-enable
else
mingw-disable
mw-disable
fi
fi
}