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