summaryrefslogtreecommitdiff
path: root/Makefile
blob: 17cc5ec382d7922cdbc40e5f0fb45682bccdb302 (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. sass_includes ?= shared/themes/default /usr/share/sass /usr/share/sass/stylesheets /usr/share/compass/frameworks/normalize-scss/stylesheets
  14. all: build
  15. -include shared/include.mk
  16. -include config/include.mk
  17. -include shared/themes/include.mk
  18. always-make = $(findstring B,$(MAKEFLAGS))
  19. avoid-broken-git = $(shell cd content && git symbolic-ref -q HEAD > /dev/null || echo " --no-rcs")
  20. iki_configfiles := $(or $(patsubst %.in,%,$(wildcard config/ikiwiki*.setup.in)),config/ikiwiki.setup)
  21. iki_projects = $(patsubst config/%.setup,build-iki/%,$(iki_configfiles))
  22. form_projects := $(patsubst forms/%.cgi,build-form/%,$(wildcard forms/*.cgi forms/*/*.cgi))
  23. init: shared/.git content
  24. $(MAKE) $(iki_configfiles)
  25. shared/.git:
  26. git submodule init
  27. git submodule update --init --recursive
  28. config/ikiwiki.setup.in:
  29. $(if $(wildcard config),,mkdir config)
  30. $(if $(wildcard config/ikiwiki.setup.in),,touch config/ikiwiki.setup.in)
  31. configfiles: $(iki_configfiles)
  32. $(iki_configfiles): iki_flavor = $(if $(filter config/ikiwiki-%.setup,$@),$(@:config/ikiwiki-%.setup=%))
  33. $(iki_configfiles): % : %.in
  34. ikiwiki $(IKIWIKI_DEFAULTS) \
  35. $(if $(IKIWIKI_UNDERLAYS)$(IKIWIKI_SHARED_UNDERLAYS),\
  36. --set-yaml add_underlays="$$(echo $(strip \
  37. $(IKIWIKI_UNDERLAYS) \
  38. $(IKIWIKI_SHARED_UNDERLAYS)) \
  39. | perl -pe 's/\s+/\n/g;s/^/- /gm')") \
  40. $(patsubst %,--setup %,$(wildcard $<)) --dumpsetup $@
  41. perl -i -pe '$$s=$$ENV{'CURDIR'}; s/\@CURDIR\@/$$s/g' $@
  42. content: notempty = $(wildcard $@/*.mdwn)
  43. content:
  44. $(if $(notempty),,mkdir -p '$@')
  45. $(if $(notempty),,printf '# Hello world!\n\nHello world!\n' > '$@/index.mdwn')
  46. build: $(iki_projects) $(form_projects)
  47. $(iki_projects): build-iki/%: config/%.setup $(cssprojects)
  48. ikiwiki --setup $<$(avoid-broken-git)$(if $(always-make), --rebuild, --refresh)
  49. $(form_projects): build-form/%: forms/%.cgi build-iki/ikiwiki
  50. install -DT $< build/$<
  51. perl -i -pe "s:'../build:'$(CURDIR)/build:g" build/$<
  52. cp -f build/html/$*/index.html build/html/$*/index.tmpl
  53. FORMBUILDER_NOHEADER=1 build/$< > build/html/$*/index.html~
  54. mv -f build/html/$*/index.html~ build/html/$*/index.html
  55. rm build/html/$*/index.tmpl
  56. .PHONY: all build build-iki/% build-form/% configfiles