how does the C pre-processor interface with make?

Oliver Mahmoudi olivermahmoudi at gmail.com
Wed Dec 30 07:17:58 UTC 2009


Hey folks,

I was wondering how the C pre-processor interfaces with make. Let's suppose
that I have a little C program, something along the lines of:

#include <stdio.h>

int
main()
{
#ifdef FOO
     fprintf(stdout, "Hi, my name is foo.\n");
#endif

#ifdef BAR
     fprintf(stdout, "Hi, my name is bar.\n");
#endif

     fprintf(stdout, "I am always here.\n");

     return(1-1);
}

It is easy to control the pre-processor in the above code by defining the
respective terms or leaving them out, however,
I am trying to control the conditionals from out of a makefile.

This is essentially the way in which the kernel sources are compiled.

Any suggestions?

Thanks

Oliver


More information about the freebsd-questions mailing list