help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Conditionally add parameters to CXXFLAGS


From: Greg Chicares
Subject: Re: Conditionally add parameters to CXXFLAGS
Date: Sun, 02 Dec 2007 12:53:07 +0000
User-agent: Thunderbird 2.0.0.9 (Windows/20071031)

On 2007-12-02 07:41Z, N Galpin wrote:
> 
> I'd like to define multiple build targets in my makefile, and depending
> on which target I pass to make, add different flags to $(CXXFLAGS).
> 
> For example, if i run `make release` I'd like this target to append
> -O3 onto CXXFLAGS, or if I run `make debug`, I'd like to append
> -g etc.

If you write something like this in your makefile:

  build_type        := release
  optimization_flag := -O3
  debug_flag        :=

  ifeq (debug,$(findstring debug,$(build_type)))
    optimization_flag :=
    debug_flag        := -g
  endif

  CXXFLAGS += $(optimization_flag) $(debug_flag)

  build_directory := /wherever/$(build_type)

then the flags will be set differently when you invoke make as
  make build_type=debug

For a more erudite discussion, see:
  http://make.paulandlesley.org/multi-arch.html





reply via email to

[Prev in Thread] Current Thread [Next in Thread]