UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C
  • » Conditional makefile: help

#1 2007-10-21 06:03 PM

smoking81
Member
Registered: 2007-10-21
Posts: 2

Re: Conditional makefile: help

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!

Offline

#2 2007-10-22 11:59 AM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: Conditional makefile: help

Use gmake's $(shell <cmd>) syntax to set a variable, and have the command you
run just be something that tests the GCC version (however you like, possibly by
parsing the output of "gcc -v") and either echoes or not the appropriate flag value...
Then, just use that variable as part of CFLAGS/CPPFLAGS/whatever...  Eg:

STACK_PROT := $(shell gcc_ver_tst)
CFLAGS += $(STACK_PROT)

Offline

#3 2007-10-22 06:07 PM

smoking81
Member
Registered: 2007-10-21
Posts: 2

Re: Conditional makefile: help

ok! Thank you very much! :)
Bye

Offline

  • Index
  • » C
  • » Conditional makefile: help

Board footer

Powered by FluxBB