How to generate Linux version flag at compile time, run time, from rpm spec.

I am writing a user space utility which would run on RHEL4, RHEL5 and
SLES10. This utility has common source and there are few section of
code are specific to OS version. In order to differentiate I am
thinking I could use Linux kernel version. Tha means I need a Linux
version flag
1) at compile time ( in Makefile, in C source )
2) at run time ( from c source)
3) From rpm spec file to build rpms.

I do not use GNU autotool. Kindly suggest methods. Appreciate your