Default rules

From Projects
Jump to: navigation, search

Note as of June 11, 2010 there are twice as many default makefiles as before, so that we can include variable definitions before the projects' makefiles and rule definitions after.

The WW makefiles use:

Makefiles are read in this order:

  • WW's makefile-before
  • The site's makefile-before
  • The project's GNUmakefile, makefile, or Makefile (*)
  • The site's makefile-after
    • Our theobio wikis' makefile-after also includes, before its own code: all project source files whose name ends in .mk, that are located in the project's main directory (not subdirectories), in unspecified order
  • WW's makefile-after

This ordering allows the site to override WW's variable definitions (in makefile-before) and its rules (in makefile-after), and allows the project to override both WW's and the site's contributions.

The WW and site files are located in the in the resources subdirectory of the WorkingWiki source code directory. Editing files in the resources/site/ subdirectory should work transparently – please report any glitches. Please don't modify files outside the site directory, since they're periodically updated from the central source code repository and should be the same on all WorkingWiki installations.

  • JD argues that we should aim to have the site makefiles editable on a particular wiki (viewable by all "users" of a given farm, but editable only by members of some admin wiki). LW points out that we can probably do this with existing tools. Stay tuned.

(*) But see below about the special role of GNUmakefile.

Automatic makefiles

As of Fall 2012 we've made a design change, in which WorkingWiki implements its default rules by inserting an automatically generated makefile called GNUmakefile into each project. This is a change from the previous design, in which WW used -f arguments to make to have it read in the WW makefiles as well as the project's own makefiles.

We hope this change will make it easier to design projects that depend on each other, and to export projects and use them outside the wikis. See https://sourceforge.net/p/workingwiki/feature-requests/51 for some details.

This is a place for notes on this changeover, including problems and tips on makefile design.

Recursive makes

In the old system, the official way to have your project make something in another project is

$(MAKE) -C $(OTHER_DIR) -f $(RESOURCES)/makefile target.

In the new system, the special glue makefile isn't needed, so you can do

$(MAKE) -C $(OTHER_DIR) target.

I've made some small changes to the central makefiles so that projects with the former kind of command should work in the new system as well, so that they don't break, even though that isn't the recommended way to do it in the new system.

WW_EXTRA_MKFILES

Here on the theobio wikis, there's a rule that reads in the project's .mk files as makefiles. It used to read all the .mk files in the project's base directory, but now it just includes the ones that are source files and are in the base directory of the project.

I came across a situation where a project programmatically generates a .mk file in a subdirectory and then invokes make with a -f argument to include that makefile as well as the others. I had some trouble getting that to work with the new setup.

I added a WW_EXTRA_MKFILES variable, so now the way to do that is

$(MAKE) WW_EXTRA_MKFILES=subdir/generated.mk target(s)

... seems to work fine. WuLi