summaryrefslogtreecommitdiff
path: root/Makefile
blob: 4f99a5ecf6054a3042f66300797a7be0e8c7f3a6 (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. init: shared/.git content
  22. $(MAKE) $(iki_configfiles)
  23. shared/.git:
  24. git submodule init
  25. git submodule update --init --recursive
  26. config/ikiwiki.setup.in:
  27. $(if $(wildcard config),,mkdir config)
  28. $(if $(wildcard config/ikiwiki.setup.in),,touch config/ikiwiki.setup.in)
  29. configfiles: $(iki_configfiles)
  30. $(iki_configfiles): iki_flavor = $(if $(filter config/ikiwiki-%.setup,$@),$(@:config/ikiwiki-%.setup=%))
  31. $(iki_configfiles): % : %.in
  32. ikiwiki $(IKIWIKI_DEFAULTS) \
  33. $(if $(IKIWIKI_UNDERLAYS)$(IKIWIKI_SHARED_UNDERLAYS),\
  34. --set-yaml add_underlays="$$(echo $(strip \
  35. $(IKIWIKI_UNDERLAYS) \
  36. $(IKIWIKI_SHARED_UNDERLAYS)) \
  37. | perl -pe 's/\s+/\n/g;s/^/- /gm')") \
  38. $(patsubst %,--setup %,$(wildcard $<)) --dumpsetup $@
  39. perl -i -pe '$$s=$$ENV{'CURDIR'}; s/\@CURDIR\@/$$s/g' $@
  40. content: notempty = $(wildcard $@/*.mdwn)
  41. content:
  42. $(if $(notempty),,mkdir -p '$@')
  43. $(if $(notempty),,printf '# Hello world!\n\nHello world!\n' > '$@/index.mdwn')
  44. build:
  45. $(if $(cssprojects),$(MAKE) $(cssprojects))
  46. set -e;\
  47. $(foreach config,$(shell find config -name '*.setup'),ikiwiki --setup $(config)$(avoid-broken-git)$(if $(always-make), --rebuild, --refresh);)
  48. set -e;\
  49. $(foreach path,$(patsubst forms/%,%,$(wildcard forms/*.cgi forms/*/*.cgi)),\
  50. install -DT 'forms/$(path)' 'build/forms/$(path)'; \
  51. perl -i -pe "s:'../build/:'$(CURDIR)/build/:g" 'build/forms/$(path)';\
  52. $(foreach htmlstempath,$(path:%.cgi=build/html/%),\
  53. cp -f $(htmlstempath).html $(htmlstempath).tmpl;\
  54. FORMBUILDER_NOHEADER=1 'build/forms/$(path)' > $(htmlstempath).html~;\
  55. mv -f $(htmlstempath).html~ $(htmlstempath).html;\
  56. rm $(htmlstempath).tmpl))
  57. .PHONY: all build configfiles