In a makefile, there is a line:
CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1
&& echo -fno-stack-protector)
What’s the use of
shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1?
It seems to do nothing. And how the whole line works?
Thanks in advance.
If your compiler does not have the option
-fno-stack-protectorit will return an error code (i.e. something!=0) otherwise it will return0(meaning “true” in return codes), indicating everything was all right.Now, the expression
foo && barmeans thatbarwill only be executed iffooreturns a non-error code (i.e.0). So, you see, if your compiler does not have that flag, it will return “false” (something!=0) and theechocommand will never be executed. But if it does have the flag,echowill be executed.