Hello everybody!
I hope somebody could help me to solve this iussue: I should create a makefile which, according to the gcc version installed on the machine where the make will be run, will set or not the flag "-fno-stack-protector" (for gcc versions < 4.1, this flag doesn't exist since SSP is not present in gcc and i would get an error).
How could I do such a makefile?
Thanks in advance!
Bye!

10-21-2007

Salem

Collect the output of `gcc -v`, then use something to extract the version number.
Use that as the basis of your decision.

10-21-2007

smoking81

Quote:

Originally Posted by Salem

Collect the output of `gcc -v`, then use something to extract the version number.
Use that as the basis of your decision.

hello! 1st of all, thanks for answering!:)
my problem is exactly how to parse the result of gcc -v and decide for the flags in a makefile... I am not really experienced with makefiles... Any hints?
Thanks again!

10-21-2007

brewbuck

Quote:

Originally Posted by smoking81

hello! 1st of all, thanks for answering!:)
my problem is exactly how to parse the result of gcc -v and decide for the flags in a makefile... I am not really experienced with makefiles... Any hints?
Thanks again!

The "gcc --version" command sucks, because the format of its output changes from version to version. Instead, check to see if gcc actually supports the option:

We trigger a failure-protected inclusion of .cflags. This file has a rule which calls gcc on a dummy file with the flag to be checked. If this call succeeds, the next command in the .cflags rule runs, which creates a mini-makefile containing a variable STACK_FLAGS with the appropriate option. If, on the other hand, gcc does not support the option, processing of the .cflags rule aborts and the .cflags file does not get created, thus the flag does not get set.