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.
It tests whether -fno-stack-protector is a valid command-line option for your C compiler, and if it is it then appends this option to CFLAGS, otherwise it does nothing.
If your compiler does not have the option -fno-stack-protector it will return an error code (i.e. something !=0) otherwise it will return 0 (meaning "true" in return codes), indicating everything was all right.
Now, the expression foo && bar means that bar will only be executed if foo returns 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 the echo command will never be executed. But if it does have the flag, echo will be executed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With