X-Git-Url: http://nitlanguage.org diff --git a/bin/gccx b/bin/gccx index bdeb3bb..7fe6717 100755 --- a/bin/gccx +++ b/bin/gccx @@ -19,11 +19,12 @@ OPTS="-g" # option for compiler call objs="" # List of .o files -CC="gcc --ansi --pedantic -Wall -Wextra -Wformat-security -Wcast-align -Wno-uninitialized -Wno-unused-variable -Wno-unused-label -Wno-unused-parameter -Wno-missing-field-initializers" # Default compiler call +libs="" +CC="cc" # Default compiler call ext="_savo _sav" # Default flavor to reuse out="a.out" # Default output binary filename dir="" # Default tmp dir -nolibgc="true" # Disable boehm libgc? +nolibgc="false" # Disable boehm libgc? CKSUM="cksum" # Tool that perfors checksum. cksum seems to be very portable recompile="false" @@ -35,6 +36,7 @@ Usage: $e [options] modulename [options for module execution] -R Force full recompilation -O Compile with optimizations -i Use the intel compiler instead of gcc +-l C library to link with -ll Use the clang compiler (llvm) instead of gcc -I path Add a include directory -o name Call name the executable @@ -66,6 +68,11 @@ fi return $res } +cache=true +if ( ccache -V ) 2>/dev/null >/dev/null; then + cache=ccache +fi + stop=false verbose=false vverbose=false @@ -74,6 +81,7 @@ while [ $stop = false ]; do -R) recompile=true; shift;; -O) OPTS="$OPTS -O2" ext="_savo"; shift;; -i) CC="/opt/intel/cc/10.1.015/bin/icc -O2" ext="_savi"; shift;; + -l) libs="$libs -l$2"; shift; shift;; -ll) CC="clang --ansi --pedantic -O3"; ext="_savll"; shift;; -I) OPTS="$OPTS -I $2"; shift; shift;; -o) out="$2"; shift; shift;; @@ -88,7 +96,12 @@ while [ $stop = false ]; do done if [ $nolibgc != true ] && test_libgc; then - OPTS="$OPTS -DWITH_LIBGC -lgc" + OPTS="$OPTS -DWITH_LIBGC" + libs="$libs -lgc" +fi + +if [ $cache = "ccache" ]; then + CC="ccache $CC" fi for i in "$@"; do @@ -107,6 +120,13 @@ for i in "$@"; do "` found="false" + if [ $cache != true ]; then + o="$dir$j.o" + if [ $vverbose = true ] ; then + echo "* $CC $OPTS -c $i -o $o" >&2 + fi + $CC $OPTS -c $i -o $o || exit 1 + else # We remove starting # to be path independent (after preprocess, there are the only # remainings) cksum=`gcc -E $OPTS $i 2> /dev/null | grep -v "^#" | $CKSUM` for e in $ext; do @@ -137,10 +157,11 @@ for i in "$@"; do exit 1 fi fi +fi objs="$objs $o" done if [ $vverbose = true ] ; then - echo "* $CC $OPTS -lm $objs -o $out" >&2 + echo "* $CC $OPTS $objs -lm $libs -o $out" >&2 fi -$CC $OPTS -lm $objs -o "$out" +$CC $OPTS $objs -lm $libs -o "$out"