2014-07-01 Oddmuse Setup Using Makefiles

Here’s how I do it:

My home directory contains two directories for every site. One directory is the document root for the site, and other directory is the data directory for the wiki. Thus, you’ll see *alexschroeder.ch* (includes wiki.pl) and *alexschroeder* (the wiki data directory which isn’t published via the web server).

The home directory has a clone of the Oddmuse sources in `~/src/oddmuse` and a Makefile as follows:

all:
	rm -rf ~/src/oddmuse/build; \
	cd ~/src/oddmuse; \
	git pull; \
	make prepare;

install:
	cd alexschroeder.ch; make
	cd alexschroeder/modules; make
	cd communitywiki.org; make
	cd communitywiki/modules; make
	...

Remember that those commands are all indented using a TAB.

The command `make prepare` prepares a copy of all the Oddmuse sources with version information in the `~/src/oddmuse/build` directory.

In every document root you’ll find another Makefile containing a `wiki.pl` wrapper script as follows:

#!/usr/bin/perl
package OddMuse;
$DataDir = '/home/alex/alexschroeder';
do 'current.pl';

It also contains a Makefile which will update `current.pl`. The Makefile usually also does a bunch of other, site-specific things. Update CSS files, update other scripts, and so on.

current.pl: ~/src/oddmuse/build/wiki.pl
	cp {body}lt; $@

Every `modules` directory also contains a Makefile. These Makefiles are all just linked because these are always identical:

concat.pl: source/*.pl
	cat $^ > $@

source/%.pl: ~/src/oddmuse/build/%.pl
	cp {body}lt; $@

This is a bit weird. Years ago, I believed that concatenating all those module files would speed up the wiki. Who knows whether that’s true. I never measured it.

Anyway, you copy all the modules you want into the `source` directory and run `make` in the `modules` directory. This will update any outdated copies in the source directory and concatenate them all into one single file called `concat.pl`. If you want to delete modules or add new modules, delete `concat.pl` and run `make` again.

So, at the top level, I can run `make && make install`. This pulls the new revisions from git, runs `make prepare` which populates the `build` directory with all the version information in the source files. The new `wiki.pl` script replaces existing copies of `current.pl` and the new modules get copied to the `source` directories, all of the modules are concatenated into a single `concat.pl` file for the `modules` directory.

Easy...

Well, it makes life easier for people maintaining multiple Oddmuse wikis.

​#Oddmuse