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