From 593b8a17188da0f7f6793d6ef117f68d5ebeddc4 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sat, 29 Jun 2013 11:47:01 -0700 Subject: [PATCH] mingw scripts --- bashrc | 2 ++ init.sh | 2 +- mingw.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ shrc.zsh | 9 +++++++-- zshrc | 10 ++++++---- 5 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 mingw.sh diff --git a/bashrc b/bashrc index b0d38b6..9742266 100644 --- a/bashrc +++ b/bashrc @@ -31,3 +31,5 @@ PROMPT_COMMAND='[ $? = 0 ] && PS1=${ret_succ} || PS1=${ret_fail}' # this doesn't work for all scripts at the moment, but PATH="$PATH:$HOME/sh" + +unset x diff --git a/init.sh b/init.sh index c1b26b9..bbd2232 100755 --- a/init.sh +++ b/init.sh @@ -40,7 +40,7 @@ PATH="$PATH:$rc/sh" umask 027 -for f in .bashrc .zshrc shrc.zsh .conkyrc .inputrc .screenrc .xinitrc; do +for f in .bashrc .zshrc shrc.zsh mingw.sh .conkyrc .inputrc .screenrc .xinitrc; do r="$rc/$(dotless "$f")" hardlink "$f" "$r" done diff --git a/mingw.sh b/mingw.sh new file mode 100644 index 0000000..93ff2a9 --- /dev/null +++ b/mingw.sh @@ -0,0 +1,46 @@ +# FYI you use /opt/mingw-w64 for mingw itself +# but /opt/mingw for things built with mingw... +#[ -d "$HOME/opt/mingw-w64" ] || echo -E "crap no mingw" >&2 + +mkdir -p ~/opt/mingw +alias cmakem='cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=~/mingw.cmake' + +_mw_enabled=0 +_mw_name=i686-w64-mingw32 +_mw_bin=~/opt/mingw-w64/bin/$_mw_name +_mw_misc=~/opt/mingw-w64/$_mw_name +_mw_prefix=~/opt/mingw + +declare -A _mw_ + +_mw_export() { + [ -z "$1" ] && return 1 + [ -n "${ZSH_VERSION:-}" ] && _mw_[$1]=${(P)1} || _mw_[$1]="${!1}" + export "$1=$2" +} + +mingw-disable() { + [ $_mw_enabled -eq 0 ] && return 1 + _mw_enabled=0 + + local e= + for e in PATH AR CC CPP CXX CFLAGS CPPFLAGS CXXFLAGS LDFLAGS RANLIB RC WINDRES; do + export "$e=${_mw_[$e]}" + done +} + +mingw-enable() { + [ $_mw_enabled -eq 1 ] && return 1 + _mw_enabled=1 + + set -- CC gcc CXX g++ CPP cpp AR ar RANLIB ranlib RC windres WINDRES windres + while _mw_export "$1" "$_mw_bin-$2"; do + shift 2 + done + + _mw_export PATH "$PATH:$HOME/opt/mingw-w64/bin" + _mw_export CFLAGS "-O2 -I $_mw_misc/include -I $_mw_prefix/include" + _mw_export LDFLAGS "-s -L $_mw_misc/lib -L $_mw_prefix/lib" + _mw_export CPPFLAGS '' + _mw_export CXXFLAGS "$CFLAGS" +} diff --git a/shrc.zsh b/shrc.zsh index 9026940..08789ec 100644 --- a/shrc.zsh +++ b/shrc.zsh @@ -3,7 +3,11 @@ umask 027 # screw others export PATH="$PATH:$HOME/opt/local/bin" -export PATH="$PATH:$HOME/opt/mingw-w64/bin" + +# cleanup in case of inherited exports +for x in AR CC CPP CXX CFLAGS CPPFLAGS CXXFLAGS LDFLAGS RANLIB RC WINDRES; do + export $x= +done export PREFIX="$HOME/opt/local" export CC=clang @@ -24,6 +28,7 @@ alias make="colormake" # just flags export LESS='-SR' +alias makedbg='CFLAGS="-O0" LDFLAGS="-g" make' alias fils="du -bad1" alias lsfm="lsf -ugpms" alias lsa="ls -A --group-directories-first" @@ -36,7 +41,6 @@ alias erc="e ~/.zshrc ~/shrc.zsh ~/.bashrc" alias irc="screen -dR irc irssi" alias crawl='screen -dR crawl ssh crawl@crawl.develz.org -i ~/.ssh/crawl' alias crawla='screen -dR crawl ssh crawl@crawl.akrasiac.org -l joshua -i ~/.ssh/crawl' -alias cmakem="cmake -G \"Unix Makefiles\" -DCMAKE_TOOLCHAIN_FILE=~/mingw.cmake" # providing extra functionality # TODO: dotfiles first, like `LC_ALL=C ls -A` which doesnt work with -X flag @@ -49,5 +53,6 @@ alias unwrap='awk '"'"'BEGIN{RS="\n\n";FS="\n"}{for(i=1;i<=NF;i++)printf "%s ",$ alias picky='{ pacman -Qgq base base-devel; pacman -Qtq; } | sort | uniq -u' alias unused='{ pacman -Qt; pacman -Qe | tee -; } | sort | uniq -u' +. ~/mingw.sh . ~/sh/lsf.sh/lsf.sh . ~/sh/z/z.sh diff --git a/zshrc b/zshrc index cc92279..36c3ac0 100644 --- a/zshrc +++ b/zshrc @@ -77,10 +77,10 @@ bindkey '^Xe' edit-command-line # ctrl+x -> e alias -g STFU="2>/dev/null" -for c in ack cd cp ebuild gcc gist grep ln man mkdir mv rm - alias $c="nocorrect $c" -for c in arith fc find ftp history let locate rsync scp sftp wget - alias $c="noglob $c" +for x in ack cd cp ebuild gcc gist grep ln man mkdir mv rm + alias $x="nocorrect $x" +for x in arith fc find ftp history let locate rsync scp sftp wget + alias $x="noglob $x" if [[ "$TERM" = xterm* ]]; then precmd() { print -Pn "\e]2;%M: %~\a" } @@ -101,3 +101,5 @@ reload() { [ -f .zcompdump.zwc.old ] && rm -f .zcompdump.zwc.old exec zsh # reload zsh (ends script execution) } + +unset x