Re: GNU Make: Add something to CXXFLAGS when invoking make

"James" <[email protected]>
Newsgroups gmane.comp.gnu.utils
Organization http://groups.google.com
Message-ID <[email protected]>
Eric Lilja wrote:
> Hello, can you do what the topic says?
> I tried:
> hivemind@mindcooler
> ~/jobb/example_programs/overloaded_comparison_operators
> $ make CXXFLAGS+='-DFRIEND
> but instead of adding -DFRIEND to CXXFLAGS, it replaced it...the
> Makefile itself is:
> CXX =g++
> CXXFLAGS = -Wall -Wextra -std=c++98 -pedantic -g -c
> LDFLAGS = -o $(EXEC)
> EXEC = overloaded_comparison_operators.exe
> OBJECTS = overloaded_comparison_operators.o
>
> all: $(OBJECTS)
> 	$(CXX) $^ $(LDFLAGS)
>
> overloaded_comparison_operators.o: overloaded_comparison_operators.cpp
> 	$(CXX) $(CXXFLAGS) $<
>
> clean:
> 	rm -f $(OBJECTS) $(EXEC) *~ *.stackdump
>
> I'm trying to avoid writing several Makefiles or having to specify the
> other CXXFLAGS on the command line other than the defines I want at the
> moment.
>
> / E

CXXFLAGS = -Wall -Wextra -std=c++98 -pedantic -g -c $(EXTRA_CXXFLAGS)

make EXTRA_CXXFLAGS=-DFRIEND

James
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.