#!/bin/sh # # checkf -- # # Author: Takaaki Tateishi # Time-stamp: "1999-03-10 07:34:59 ttate" # # Options: # -h: help # -n: not print to stderr if test "$CC" = "" then CC=gcc fi OPTS= FUNC= NUM=1 TMPFILE= EXEFILE= STDERR=true if test "$1" = "" then echo "function was not specified" exit fi while test "$1" != "" do case "$1" in "-h"|"--help") echo "checkf [-h|--help] [-n] func options ..." exit;; "-n") STDERR=false; shift;; *) if test "$FUNC" = "" then FUNC=$1 else OPTS="$OPTS $1" fi shift;; esac done NUM=1 while test -f exe$NUM do NUM=`expr $NUM + 1` done EXEFILE=exe$NUM NUM=1 while test -f tmp$NUM.c do NUM=`expr $NUM + 1` done TMPFILE=tmp$NUM.c cat > $TMPFILE < int main(int argc, char *argv[]) { void (*func)(); func = $FUNC; return 0; }; EOF if test "$STDERR" = "true" then echo -n "$FUNC() ..... " 1>&2 fi $CC $OPTS $TMPFILE -o $EXEFILE 2> /dev/null 1> /dev/null if ./$EXEFILE 2> /dev/null 1> /dev/null then rm -f $EXEFILE $TMPFILE echo "true" if test "$STDERR" = "true" then echo "true" 1>&2 fi exit 0 else rm -f $EXEFILE $TMPFILE echo "false" if test "$STDERR" = "true" then echo "false" 1>&2 fi exit 1 fi