myrules.mk

  • Revision slug: myrules.mk
  • Revision title: myrules.mk
  • Revision id: 168811
  • Created:
  • Creator: Benjamin Smedberg
  • Is current revision? No
  • Comment document myconfig.mk and myrules.mk

Revision Content

Developers can add arbitrary makefile changes to the entire tree using special files <tt>myconfig.mk</tt> and <tt>myrules.mk</tt>:

objdir/config/myconfig.mk
If present, this file is included near the end of config.mk, after build variables have been configured.

objdir/config/myrules.mk
If present, this file is included near the end of rules.mk, after all of the default rules.

Example: altering build variables using myconfig.mk

This is example is taken from the XPCOMGC project gcobject-config.mk.

Objective:
Run a special Dehydra script over the codebase.
Plan:
Replace the normal variable which specifies a static analysis script with a different value
Implementation:
Create the following file in objdir/config/myconfig.mk:
DEHYDRA_FLAGS = -fplugin=$(DEHYDRA_PATH) -fplugin-arg="$(topsrcdir)/.hg/patches/gcobject.js $(@F).gcobject-results"

Example: Adding a new target using myrules.mk

This example taken from the XPCOMGC project pork-rules.mk.

Objective:
Collect a list of every preprocessed C++ file in Mozilla, for later processing using automatic rewriting tools.
Plan:
Create a target which will dump the list of files
Usage:
Run <tt>make echo-iifiles IIFILES_LIST=/path/to/store-list</tt>.
Implementation:
Create the following file in objdir/config/myrules.mk:
relativesrcdir = $(subst $(topsrcdir)/,,$(srcdir))

IIFILES_LIST = $(error Please specify IIFILES_LIST)

echo-iifiles_tier_%:
	@echo "$@"
	@$(MAKE_TIER_SUBMAKEFILES)
	@$(EXIT_ON_ERROR) \
	  $(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) echo-iifiles; ) true

echo-iifiles::
	@($(foreach f,$(patsubst %.cc,%.ii,$(CPPSRCS:.cpp=.ii)),printf "$(relativesrcdir)/$(f)\n";) true) >> $(IIFILES_LIST)
	+$(LOOP_OVER_DIRS)
	+$(LOOP_OVER_TOOL_DIRS)

# PSM build rules don't use DIRS... recurse manually
ifeq (security/manager,$(relativesrcdir))
echo-iifiles::
	@$(EXIT_ON_ERROR) \
	  $(foreach dir,boot ssl locales pki,$(MAKE) -C $(dir) echo-iifiles; )
endif

Revision Source

<p>Developers can add arbitrary makefile changes to the entire tree using special files <tt>myconfig.mk</tt> and <tt>myrules.mk</tt>:
</p><p></p><dl>
<dt><var>objdir</var>/config/myconfig.mk
</dt><dd>If present, this file is included near the end of <a href="en/Config.mk">config.mk</a>, after build variables have been configured.
<p></p></dd><dt><var>objdir</var>/config/myrules.mk
</dt><dd>If present, this file is included near the end of <a href="en/Rules.mk">rules.mk</a>, after all of the default rules.
</dd></dl>

<h3 name="Example:_altering_build_variables_using_myconfig.mk"> Example: altering build variables using myconfig.mk </h3>
<p>This is example is taken from the XPCOMGC project <a class="external" href="http://hg.mozilla.org/users/bsmedberg_mozilla.com/xpcomgc-patches/index.cgi/file/1cf47cdb0feb/gcobject-config.mk">gcobject-config.mk</a>.
</p><p></p><dl>
<dt>Objective:
</dt><dd>Run a special <a href="en/Dehydra">Dehydra</a> script over the codebase.
</dd><dt>Plan:
</dt><dd>Replace the normal variable which specifies a static analysis script with a different value
</dd><dt>Implementation:
</dt><dd>Create the following file in <var>objdir</var>/config/myconfig.mk:

<pre>DEHYDRA_FLAGS = -fplugin=$(DEHYDRA_PATH) -fplugin-arg="$(topsrcdir)/.hg/patches/gcobject.js $(@F).gcobject-results"
</pre>
<p></p></dd></dl>

<h3 name="Example:_Adding_a_new_target_using_myrules.mk"> Example: Adding a new target using myrules.mk </h3>
<p>This example taken from the XPCOMGC project <a class="external" href="http://hg.mozilla.org/users/bsmedberg_mozilla.com/xpcomgc-patches/index.cgi/file/1cf47cdb0feb/pork-rules.mk">pork-rules.mk</a>.
</p><p></p><dl>
<dt>Objective:
</dt><dd>Collect a list of every preprocessed C++ file in Mozilla, for later processing using automatic rewriting tools.
</dd><dt>Plan:
</dt><dd>Create a target which will dump the list of files
</dd><dt>Usage:
</dt><dd>Run <tt>make echo-iifiles IIFILES_LIST=/path/to/store-list</tt>.
</dd><dt>Implementation:
</dt><dd>Create the following file in <var>objdir</var>/config/myrules.mk:

<pre>relativesrcdir = $(subst $(topsrcdir)/,,$(srcdir))

IIFILES_LIST = $(error Please specify IIFILES_LIST)

echo-iifiles_tier_%:
	@echo "$@"
	@$(MAKE_TIER_SUBMAKEFILES)
	@$(EXIT_ON_ERROR) \
	  $(foreach dir,$(tier_$*_dirs),$(MAKE) -C $(dir) echo-iifiles; ) true

echo-iifiles::
	@($(foreach f,$(patsubst %.cc,%.ii,$(CPPSRCS:.cpp=.ii)),printf "$(relativesrcdir)/$(f)\n";) true) &gt;&gt; $(IIFILES_LIST)
	+$(LOOP_OVER_DIRS)
	+$(LOOP_OVER_TOOL_DIRS)

# PSM build rules don't use DIRS... recurse manually
ifeq (security/manager,$(relativesrcdir))
echo-iifiles::
	@$(EXIT_ON_ERROR) \
	  $(foreach dir,boot ssl locales pki,$(MAKE) -C $(dir) echo-iifiles; )
endif
</pre>
<p></p></dd></dl>
Revert to this revision