summaryrefslogtreecommitdiff
path: root/Makefile.PL
blob: 7906f65934f5cf549b697c507b7321b7b97bafcb (plain)
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. use ExtUtils::MakeMaker;
  5. # Add a few more targets.
  6. sub MY::postamble {
  7. q{
  8. all:: extra_build
  9. clean:: extra_clean
  10. install:: extra_install
  11. pure_install:: extra_install
  12. VER=$(shell perl -e '$$_=<>;print m/\((.*?)\)/'<debian/changelog)
  13. # Parameterized programs used by Makefile.
  14. FIND?=find
  15. SED?=sed
  16. # Additional configurable path variables.
  17. W3M_CGI_BIN?=$(PREFIX)/lib/w3m/cgi-bin
  18. tflag=$(shell if [ -n "$$NOTAINT" ] && [ "$$NOTAINT" != 1 ]; then printf -- "-T"; fi)
  19. extramodules=$(shell if [ "$$PROFILE" = 1 ]; then printf -- "-d:NYTProf"; fi)
  20. outprogs=ikiwiki.out ikiwiki-transition.out ikiwiki-calendar.out
  21. scripts=ikiwiki-update-wikilist ikiwiki-makerepo
  22. PROBABLE_INST_LIB=$(shell \\
  23. if [ "$(INSTALLDIRS)" = "perl" ]; then \\
  24. echo $(INSTALLPRIVLIB); \\
  25. elif [ "$(INSTALLDIRS)" = "site" ]; then \\
  26. echo $(INSTALLSITELIB); \\
  27. elif [ "$(INSTALLDIRS)" = "vendor" ]; then \\
  28. echo $(INSTALLVENDORLIB); \\
  29. fi \\
  30. )
  31. %.out: %.in
  32. ./pm_filter $(PREFIX) $(VER) $(PROBABLE_INST_LIB) < $< > $@
  33. chmod +x $@
  34. ikiwiki.setup:
  35. HOME=/home/me $(PERL) -Iblib/lib $(extramodules) $(tflag) ikiwiki.in -dumpsetup ikiwiki.setup
  36. extra_build: $(outprogs) ikiwiki.setup docwiki
  37. ./mdwn2man ikiwiki 1 doc/usage.mdwn > ikiwiki.man
  38. ./mdwn2man ikiwiki-mass-rebuild 8 doc/ikiwiki-mass-rebuild.mdwn > ikiwiki-mass-rebuild.man
  39. ./mdwn2man ikiwiki-makerepo 1 doc/ikiwiki-makerepo.mdwn > ikiwiki-makerepo.man
  40. ./mdwn2man ikiwiki-transition 1 doc/ikiwiki-transition.mdwn > ikiwiki-transition.man
  41. ./mdwn2man ikiwiki-update-wikilist 1 doc/ikiwiki-update-wikilist.mdwn > ikiwiki-update-wikilist.man
  42. ./mdwn2man ikiwiki-calendar 1 doc/ikiwiki-calendar.mdwn > ikiwiki-calendar.man
  43. $(MAKE) -C po
  44. $(SED) -i.bkp "s/Version:.*/Version: $$(perl -e '$$_=<>;print m/\((.*?)\)/'<debian/changelog)/" ikiwiki.spec
  45. rm -f ikiwiki.spec.bkp
  46. docwiki:
  47. $(PERL) -Iblib/lib $(extramodules) $(tflag) ikiwiki.in -setup docwiki.setup -refresh
  48. extra_clean:
  49. $(PERL) -Iblib/lib $(extramodules) $(tflag) ikiwiki.in -setup docwiki.setup -clean
  50. rm -f *.man $(outprogs) ikiwiki.setup plugins/*.pyc
  51. $(MAKE) -C po clean
  52. # Joey uses this before committing.
  53. myclean: clean
  54. git checkout po ikiwiki.spec
  55. underlay_install:
  56. install -d $(DESTDIR)$(PREFIX)/share/ikiwiki
  57. for dir in `cd underlays && $(FIND) . -follow -type d ! -regex '.*\.svn.*'`; do \
  58. install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
  59. for file in `$(FIND) underlays/$$dir -follow -maxdepth 1 -type f`; do \
  60. cp -aL $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir 2>/dev/null || \
  61. install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
  62. done; \
  63. done
  64. # The directive docs become their own special underlay.
  65. install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/directives/ikiwiki/directive
  66. for file in doc/ikiwiki/directive/*; do \
  67. if [ -f "$$file" ]; then \
  68. cp -aL $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/directives/ikiwiki/directive 2>/dev/null || \
  69. install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/directives/ikiwiki/directive; \
  70. fi \
  71. done
  72. # Themes have their base.css (if present) and then
  73. # style.css appended to the normal one.
  74. for theme in themes/*; do \
  75. install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/$$theme; \
  76. for file in $$theme/*; do \
  77. if echo "$$file" | grep -q style.css; then \
  78. (cat doc/style.css; cat $$theme/base.css 2>/dev/null; cat $$file) >> $(DESTDIR)$(PREFIX)/share/ikiwiki/$$theme/style.css; \
  79. elif echo "$$file" | grep -q base.css; then \
  80. :; \
  81. elif [ -f "$$file" ]; then \
  82. cp -aL $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$file 2>/dev/null || \
  83. install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$file; \
  84. fi \
  85. done; \
  86. done
  87. extra_install: underlay_install
  88. # Install example sites.
  89. for dir in `cd doc/examples; $(FIND) . -type d ! -regex '.*\.svn.*'`; do \
  90. install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/examples/$$dir; \
  91. done
  92. for file in `cd doc/examples; $(FIND) . -type f ! -regex '.*\.svn.*'`; do \
  93. cp -aL doc/examples/$$file $(DESTDIR)$(PREFIX)/share/ikiwiki/examples/$$file 2>/dev/null || \
  94. install -m 644 doc/examples/$$file $(DESTDIR)$(PREFIX)/share/ikiwiki/examples/$$file; \
  95. done
  96. for dir in `$(FIND) templates -follow -type d ! -regex '.*\.svn.*'`; do \
  97. install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
  98. for file in `$(FIND) $$dir -follow -maxdepth 1 -type f`; do \
  99. install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
  100. done; \
  101. done
  102. install -d $(DESTDIR)$(PREFIX)/lib/ikiwiki/plugins
  103. for file in `$(FIND) plugins -maxdepth 1 -type f ! -path plugins/.\* ! -name \*demo\* -name \*.py`; do \
  104. install -m 644 $$file $(DESTDIR)$(PREFIX)/lib/ikiwiki/plugins; \
  105. done
  106. for file in `$(FIND) plugins -maxdepth 1 -type f ! -path plugins/.\* ! -name \*demo\* ! -name \*.py ! -name \*.pyc`; do \
  107. install -m 755 $$file $(DESTDIR)$(PREFIX)/lib/ikiwiki/plugins; \
  108. done
  109. install -d $(DESTDIR)$(PREFIX)/share/man/man1
  110. install -m 644 ikiwiki.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki.1
  111. install -m 644 ikiwiki-makerepo.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-makerepo.1
  112. install -m 644 ikiwiki-transition.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-transition.1
  113. install -m 644 ikiwiki-update-wikilist.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-update-wikilist.1
  114. install -m 644 ikiwiki-calendar.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-calendar.1
  115. install -d $(DESTDIR)$(PREFIX)/share/man/man8
  116. install -m 644 ikiwiki-mass-rebuild.man $(DESTDIR)$(PREFIX)/share/man/man8/ikiwiki-mass-rebuild.8
  117. install -d $(DESTDIR)$(PREFIX)/sbin
  118. install ikiwiki-mass-rebuild $(DESTDIR)$(PREFIX)/sbin
  119. install -d $(DESTDIR)$(W3M_CGI_BIN)
  120. install ikiwiki-w3m.cgi $(DESTDIR)$(W3M_CGI_BIN)
  121. install -d $(DESTDIR)$(PREFIX)/bin
  122. for prog in $(outprogs) $(scripts); do \
  123. install $$prog $(DESTDIR)$(PREFIX)/bin/$$(echo $$prog | $(SED) 's/\.out//'); \
  124. done
  125. $(MAKE) -C po install DESTDIR=$(DESTDIR) PREFIX=$(PREFIX)
  126. # These might fail if a regular user is installing into a home
  127. # directory.
  128. -install -d $(DESTDIR)/etc/ikiwiki
  129. -install -m 0644 wikilist $(DESTDIR)/etc/ikiwiki
  130. -install -m 0644 auto.setup $(DESTDIR)/etc/ikiwiki
  131. -install -m 0644 auto-blog.setup $(DESTDIR)/etc/ikiwiki
  132. }
  133. }
  134. WriteMakefile(
  135. NAME => 'IkiWiki',
  136. PREFIX => "/usr/local",
  137. PM_FILTER => './pm_filter $(PREFIX) $(VER) $(PROBABLE_INST_LIB)',
  138. MAN1PODS => {},
  139. PREREQ_PM => {
  140. 'XML::Simple' => "0",
  141. 'Text::Markdown' => "0",
  142. 'Date::Parse' => "0",
  143. 'HTML::Template' => "0",
  144. 'HTML::Scrubber' => "0",
  145. 'CGI::FormBuilder' => "3.02.02",
  146. 'CGI::Session' => "0",
  147. 'Mail::Sendmail' => "0",
  148. 'HTML::Parser' => "0",
  149. 'URI' => "0",
  150. 'Data::Dumper' => "2.11",
  151. },
  152. );