Using conditionals in automake
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 Ma开发者_如何学Gokefile template? Or should I try to find some way of adding it the automatically generated Makefile?
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
.
精彩评论