#!/bin/sh
compiler=$(basename "$0" | sed 's|-run$||')
-exe=$(mktemp -t cc-run) || exit 1
src=""
args=""
exeargs=""
fi
for arg in "$@"; do
- if [ -e "$arg" ] && [ "$src" = "" ]; then
- src=$arg
+ if [ "$src" = "" -a -e "$arg" -o "$arg" = "-" ]; then
+ src="$arg"
elif [ "$src" != "" ]; then
exeargs="$exeargs $arg"
else
fi
done
-case "$compiler" in
- cc|gcc|gcc-*|clang|clang-*)
+case $compiler in
+ cc|gcc|gcc-*|clang|clang-*|tcc)
+ if [ "$src" = '-' ]; then
+ args="$args -x c"
+ fi
args="$args $CPPFLAGS $CFLAGS $LDFLAGS";;
c++|g++|g++-*|clang++|clang++-*)
+ if [ "$src" = '-' ]; then
+ args="$args -x c++"
+ fi
args="$args $CPPFLAGS $CXXFLAGS $LDFLAGS"
esac
-$compiler $args $src -o $exe || exit 1
+exe=$(mktemp -t cc-run) || exit 1
+if ! $compiler $args $src -o $exe; then
+ rm -f $exe
+ exit 1
+fi
$exe $exeargs
ret=$?