[fun@kru ~/test]% cat Makefile       
all: main.o
@./ver.sh

main.o: main.c version.o

version.o: version.c

clean:
rm -f *.o version.c
[fun@kru ~/test]% cat ver.sh
#!/bin/sh

echo "const char version[] = \"`date`\";" > _version.c

if [ ! -f version.c ]
then mv _version.c version.c
else diff -q version.c _version.c >/dev/null || mv _version.c version.c
fi

rm -f _version.c