Re: Help on Makefile

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

 



Hi Lalit Seth,

Your question is off-topic for this forum.

- - - - - - - - - - - - - - - - - - - - - -

For doing something like:
gmake debug
...and...
gmake release

Do something like this near the beginning of your makefile:
ifeq ($(MAKECMDGOALS),debug)
BUILD:=debug
endif
ifeq ($(MAKECMDGOALS),release)
BUILD:=release
endif
ifeq ($(findstring $(BUILD),debug release),)
$(error BUILD=$(BUILD) is unknown, must be BUILD=release or BUILD=debug)
endif

And this near the end:
.PHONY : debug release
debug: all
release: all

And you can use the $(BUILD) variable to determine what compiler settings you want, and what directory you want to put your build files.

As given, "make clean" will fail; but "make BUILD=debug clean" will succeed. You could either put in a "BUILD:=debug" as the default (near the very top of the makefile), so "make" will always do a BUILD:=debug by default.

Or, you may want to add a "BUILD:=clean" option that cleans both debug and release interim generated files.

- - - - - - - - - - - - - - - - - - - - - -

However, I highly recommend that you DO NOT do that. Instead, I recommend you do:
gmake BUILD=debug
...and...
gmake BUILD=release


Using "debug" and "release" as targets is counter-intuitive to the make paradigm. In my opinion.

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux