summaryrefslogtreecommitdiff
path: root/Makefile
blob: b835f6431d3130d078185894d6c809ac33b05443 (plain)
  1. IKIWIKI_DEFAULTS ?= \
  2. --rcs git \
  3. --set cgi_wrappermode=00755 \
  4. --set git_wrappermode=06755 \
  5. --set srcdir='@CURDIR@/content' \
  6. --set destdir='@CURDIR@/build/html$(iki_flavor:%=-%)' \
  7. --set cgi_wrapper='@CURDIR@/build/cgi$(iki_flavor:%=-%)/ikiwiki.cgi' \
  8. --set git_wrapper='@CURDIR@/build/git/post-update-ikiwiki$(iki_flavor:%=-%)' \
  9. --set wikistatedir='@CURDIR@/.ikiwiki$(iki_flavor:%=-%)' \
  10. $(IKIWIKI_SHARED_DEFAULTS)
  11. export CURDIR
  12. cssprojects ?= $(wildcard shared/themes/goab styling)
  13. all: build
  14. -include shared/include.mk
  15. -include config/include.mk
  16. -include shared/themes/include.mk
  17. always-make = $(findstring B,$(MAKEFLAGS))
  18. avoid-broken-git = $(shell cd content && git symbolic-ref -q HEAD > /dev/null || echo " --no-rcs")
  19. iki_configfiles := $(or $(patsubst %.in,%,$(wildcard config/ikiwiki*.setup.in)),config/ikiwiki.setup)
  20. init: shared/.git content
  21. $(MAKE) $(iki_configfiles)
  22. shared/.git:
  23. git submodule init
  24. git submodule update --init --recursive
  25. config/ikiwiki.setup.in:
  26. $(if $(wildcard config),,mkdir config)
  27. $(if $(wildcard config/ikiwiki.setup.in),,touch config/ikiwiki.setup.in)
  28. configfiles: $(iki_configfiles)
  29. $(iki_configfiles): iki_flavor = $(if $(filter config/ikiwiki-%.setup,$@),$(@:config/ikiwiki-%.setup=%))
  30. $(iki_configfiles): % : %.in
  31. ikiwiki $(IKIWIKI_DEFAULTS) $(patsubst %,--setup %,$(wildcard $<)) --dumpsetup $@
  32. perl -i -pe '$$s=$$ENV{'CURDIR'}; s/\@CURDIR\@/$$s/g' $@
  33. content: notempty = $(wildcard $@/*.mdwn)
  34. content:
  35. $(if $(notempty),,mkdir -p '$@')
  36. $(if $(notempty),,printf '# Hello world!\n\nHello world!\n' > '$@/index.mdwn')
  37. build:
  38. $(if $(cssprojects),$(MAKE) $(cssprojects))
  39. $(foreach config,$(shell find config -name '*.setup'),ikiwiki --setup $(config)$(avoid-broken-git)$(if $(always-make), --rebuild, --refresh);)
  40. $(if $(wildcard forms),cd forms && find * -name '*.cgi' \
  41. -exec install -DT '{}' ../build/forms/'{}' ';' \
  42. -exec perl -i -pe "s:'../build':'$(CURDIR)/build':g" ../build/forms/'{}' ';')
  43. .PHONY: all build configfiles