summaryrefslogtreecommitdiff
path: root/Makefile
blob: b5547343c9c6d2b9386a0aec983334cb103e4a19 (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) \
  32. $(if $(IKIWIKI_UNDERLAYS)$(IKIWIKI_SHARED_UNDERLAYS),\
  33. --set-yaml add_underlays="$$(echo $(strip \
  34. $(IKIWIKI_UNDERLAYS) \
  35. $(IKIWIKI_SHARED_UNDERLAYS)) \
  36. | perl -pe 's/\s+/\n/g;s/^/- /gm')") \
  37. $(patsubst %,--setup %,$(wildcard $<)) --dumpsetup $@
  38. perl -i -pe '$$s=$$ENV{'CURDIR'}; s/\@CURDIR\@/$$s/g' $@
  39. content: notempty = $(wildcard $@/*.mdwn)
  40. content:
  41. $(if $(notempty),,mkdir -p '$@')
  42. $(if $(notempty),,printf '# Hello world!\n\nHello world!\n' > '$@/index.mdwn')
  43. build:
  44. $(if $(cssprojects),$(MAKE) $(cssprojects))
  45. set -e;\
  46. $(foreach config,$(shell find config -name '*.setup'),ikiwiki --setup $(config)$(avoid-broken-git)$(if $(always-make), --rebuild, --refresh);)
  47. $(if $(wildcard forms),cd forms && find * -name '*.cgi' \
  48. -exec install -DT '{}' ../build/forms/'{}' ';' \
  49. -exec perl -i -pe "s:'../build':'$(CURDIR)/build':g" ../build/forms/'{}' ';')
  50. .PHONY: all build configfiles