开发者

Howto make gnumake behave as if default options in command line were passed?

I am using a makefile in which if I pass options in the command line like

make OPT1=opt1 OPT1=2

I get a different behavior than if I edit Mak开发者_开发技巧efile and write there

OPT1=opt1
OPT2=opt2

and then then run

make

on the command line.

The behavior I want is the one where I use the options in the command line.Right now I am using an alias but I am interested in knowing if this can be done purely with the Makefile alone.

Thanks.


Does your make file use the origin command on these variables to decide whether to overwrite them? This returns the, well, origin of a variable, e.g. "environment" or "command line", and maybe the makefile is written to do something different in these cases.


The way I end up solving this was the following:

mv Makefile Makefile.aux

then create a now Makefile with the contents

OPT1=true
OPT2=false

DEFAULT_OPTS=--no-print-directory OPT1=$(OPT1) OPT2=$(OPT2)

.PHONY : $(MAKECMDGOALS)
$(MAKECMDGOALS):
        $(MAKE) -f Makefile.aux $(DEFAULT_OPTS) $(MAKEFLAGS) $(MAKECMDGOALS)

.PHONY: all
all:
        $(MAKE) -f Makefile.aux $(DEFAULT_OPTS) $(MAKEFLAGS) $(MAKECMDGOALS)

The reason I use --no-print-directory is because if I use this method without this option it will print an extra message in the beggining and in the end of the compilation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜