#!/bin/sh VIEWER=evincee UP_HOST=ghostdub UP_PATH=public_html/image`date -u +%d%b%k%M`.png compile() { g++ -Wall -lpthread -O3 -mmmx -msse -msse2 -msse3 -msse4a -mssse3 -mfpmath=sse -falign-functions -falign-jumps -falign-labels -falign-loops -fbranch-probabilities -fbranch-target-load-optimize2 -fcprop-registers -fcrossjumping -finline-functions -finline-small-functions -fipa-matrix-reorg -fmodulo-sched -fpeephole2 -fpeephole -fpeel-loops -foptimize-sibling-calls -foptimize-register-move -frounding-math -fsel-sched-pipelining -fno-threadsafe-statics -funsafe-math-optimizations -funsafe-loop-optimizations -funroll-all-loops -masm=intel -m3dnow -mtune=core2 -I include/ -O3 -o bin/`echo "$1" | sed "s/\.[^.]*\$//"` $1 } edit() { $EDITOR include/options.h } view() { $VIEWER img/`echo "$1" | sed "s/\.[^.]*\$/.png/"` >/dev/null 2>&1 & } render() { time bin/`echo "$1" | sed "s/\.[^.]*\$//"` convert image.tga img/`echo "$1" | sed "s/\.[^.]*\$/.png/"` rm image.tga view "$1" } upload() { scp img/`echo "$1" | sed "s/\.[^.]*\$/.png/"` $UP_HOST:$UP_PATH } help() { echo " usage: $0 file command file is the file containing the main() function command has to be one of: all - compile, render, upload compile - builds the executable edit - edit compiletime options render - runs the executable, converts the resulting image to png format and views it upload - uploads the image view - views the current image" } if [ -z "$1" ]; then help exit 1 elif [ ! -r "$1" -o -d "$1" ]; then echo "no such file" help exit 1 else case "$2" in a|all) compile "$1" && echo "compiling done" && render "$1" && upload "$1" ;; c|compile) compile "$1" ;; e|edit) edit ;; r|render) render "$1" ;; u|upload) upload "$1" ;; v|view) view "$1" ;; *) echo "no such command" help exit 1 ;; esac fi