I have a huge Makefile I’m working with and trying to trim down. Right now, it’s layed out to build several different programs with tons of options I’ll never use. My hope is to first make sure the code builds the right way, and then cut out parts I don’t need.
First things first, I want to make sure my code in compiling with -o3 (lots of optimizations) but I’m not sure that it is. I see a chunk of the Makefile that says:
ifeq ($(findstring $(CFLAGS),-O),) CFLAGS_COMMON += -O3 # only add -O3 if no -O flag is in $(CFLAGS) endif
which provides some solace…but doesn’t there have to be a -O flag in place for it to compile at all, negating the if-statement?
Here’s the whole Makefile:
LDFLAGS ?= CFLAGS ?= CXXFLAGS ?= CPPFLAGS ?= LIBS ?= RADIANT_ABOUTMSG ?= Custom build
This will only change the code of your project’s changed files. To be sure all your files are recompiled, do a
make clean first. BUT:
This does not guarantee externally linked files, such as libraries. Those generally are not compiled with
-O3. If your want to assure they are, you will have to recompile all the libraries too (not forgetting to changeing all their Makefiles!). And. if those files depend on other libraries (they probably do), you’ll also have to recompile those.