#!/bin/sh
#require cc
#require cflags
#phase init
#after init_cc
#after init_cflags
#phase header
case $PHASE in
	init)
		C99="0"
		dispn "Checking for C99 compatible compiler..."
		if test "`basename $CC`" = "gcc"; then
			VER=`$CC --version | head -1 | cut -d ' ' -f 3`
			MVER=`$ECHO "$VER" | cut -d '.' -f 1`
			if test "$MVER" -ge "3"; then
				disp "gcc $VER (>= 3.0.0) found, C99 support activated"
				C99="1"
			else
				disp "gcc $VER (< 3.0.0) found, no C99 support"
			fi
		else
			disp "compiler not gcc, no C99 support"
		fi
		if test "$C99" = "1"; then
			disp "Adding \"-std=c99\" to CFLAGS"
			FM_CFLAGS="$FM_CFLAGS -std=c99"
		fi
		;;
	header)
		if test "$C99" = "0"; then
			disp "Removing \"inline\" and \"restrict\" keyworks from source"
			$ECHO "#define inline"
			$ECHO "#define restrict"
		else
			disp "C99 is supported, no header changes needed"
		fi
		;;
esac
