I don't think that you can do that with the GNU preprocessor, but surely it's not doable with a plain standard preprocessor; instead, I think that this is the job for the Makefile.
Let it run uname -a and store it in a Makefile variable, that will be used to create the correct -D directive for the compiler.
You could also make the Makefile create a .h file that will contain the macro definition, and that file will be #included by the files that need the COMPILED_ON macro. This has the extra bonus of being independent of compiler-specific options to define macros.
Notice that these suggestions are applicable also to build tools other than the good ol' make.