Tutorial :Using conditionals in automake



Question:

I recently switched from using Makefiles to using Automake, and I can't figure out how to write the following simple if statement using automake:

DEBUG ?= 1  ifeq (${DEBUG},1)  CXXFLAGS:=$(CXXFLAGS) -g  else  CXXFLAGS:=$(CXXFLAGS) -O3 -DNDEBUG  endif  

Is this even possible to do if I'm using automake? Since it generates the makefile from automatically, does it make sense writing it in the Makefile template? Or should I try to find some way of adding it the automatically generated Makefile?


Solution:1

No, you cannot use such a syntax with Automake. There is no exact equivalent for the first two lines.

You could do something close using an Automake conditional (see Usage of Conditionals in the Automake manual for examples), and set DEBUG from ./configure. However I see little point in doing that: if you want to change CXXFLAGS globally, simply alter this variable in configure, not in the Makefile.am.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »