help-make
[Top][All Lists]
Advanced

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

'--' inserted into MAKEFLAGS


From: gk
Subject: '--' inserted into MAKEFLAGS
Date: Thu, 26 Jun 2003 13:44:58 -0700

I would like to share a little discovery that may cause problems for others like me. There is an undocumented behavior that was driving me crazy until I figured out what was going on: '--' is inserted into MAKEFLAGS before MAKEOVERRIDES is appended, but only within the context of command rules.

I don't know if this is a POSIX spec but it can get in the way if you try to write a wrapper like XMake, which adds options: the '--' signals end of options so any you add after that may not get parsed correctly (depending on how you parse options).

I think it would be better for make not to insert the '--' automatically since it handles options and overrides fine without it. It only serves to trip up people like me :-)

# Makefile
$(warning MAKEFLAGS=$(MAKEFLAGS))
bar:
        #$(warning MAKEFLAGS=$(MAKEFLAGS))
#eof

address@hidden junk]$ make -k FOO=foo bar
Makefile:3: MAKEFLAGS=k
Makefile:5: MAKEFLAGS=k -- FOO=foo

In my application, I define $(XMAKE), similar to $(MAKE), which sometimes receives additional options, which must be parsed by my wrapper, xmake.sh. Since $(XMAKE) also must include a reference to $(MAKEFLAGS), I was having trouble getting past the '--' until I revised my code as follows:

# XMAKEFLAGS includes '-'; Gnu make $(MAKEFLAGS) sometimes does:
# long options start with '--'; if only short options occur, no '-' appears in $(MAKEFLAGS) # Since we may add XMAKE options after $(XMAKE), we can't use preceding '--', which appears in $(MAKEFLAGS) when subshells are begun:
# this messes up xmake.sh ability to parse arguments
_MAKEFLAGS=$(filter-out --,$(MAKEFLAGS))
define XMAKE
$(XMAKE_CMD) $(XMAKEFLAGS) -$(patsubst -%,%,$(word 1,$(_MAKEFLAGS))) $(wordlist 2,$(words $(_MAKEFLAGS)),$(_MAKEFLAGS))
endef
- Greg Keraunen
http://www.xmake.org





reply via email to

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