#!/bin/sh std=c99 vendor="" flags="" rpath="" while [ $# -gt 0 ]; do case "$1" in -std=*) std=${1#-std=};; -G) shared=1;; -B) shift; mode="$1";; # Multiple instances [...] −R can be specified. -R) shift; rpath="$rpath $1";; -o) shift; out="$1";; -c) compileonly=1;; *) vendor="$vendor $1" esac shift done if [ "$std" != "c99" ] && [ "$std" != "iso9899:1999" ]; then echo "`basename $0` called with non ISO C99 option -std=$std" >&2 exit 1 fi if [ "$mode" ]; then # pass unknown flags on to compiler if [ "$mode" != "dynamic" ]; then vendor="$vendor -B $mode" elif [ "$shared" ]; then echo "`basename $0` called with both -B shared and -G option" >&2 exit 1 else # Unspecified by POSIX: If combined with -c we produce an object # suitable for -pie if [ "$compileonly" ]; then flags="$flags -fpie" else flags="$flags -pie" fi fi fi if [ "$shared" ]; then if [ "$compileonly" ]; then flags="$flags -fpic" else flags="$flags -shared" fi fi if [ "$rpath" ]; then if [ "$compileonly" ]; then echo "`basename $0` called with both -R and -c option" >&2 exit 1 else for rp in "$rpath"; do flags="-Wl,-rpath,$rp" done fi fi args="$flags $vendor" echo gcc $args #gcc $args #flags= #if [ "$shared" ]; then # flags="$flags -shared" #fi #if [ #echo gcc $fl ${1+"$@"}