]> sipb.mit.edu Git - ikiwiki.git/blob - Makefile.PL
page.tmpl: Add Cache-Control must-revalidate to ensure that users (especially of...
[ikiwiki.git] / 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
33 %.out: %.in
34         ./pm_filter $(PREFIX) $(VER) $(PROBABLE_INST_LIB) < $< > $@
35         chmod +x $@
36
37 ikiwiki.setup: ikiwiki.out
38         HOME=/home/me $(PERL) -Iblib/lib $(extramodules) $(tflag) ikiwiki.out -libdir . -dumpsetup ikiwiki.setup
39
40 extra_build: $(outprogs) ikiwiki.setup docwiki
41         ./mdwn2man ikiwiki 1 doc/usage.mdwn > ikiwiki.man
42         ./mdwn2man ikiwiki-mass-rebuild 8 doc/ikiwiki-mass-rebuild.mdwn > ikiwiki-mass-rebuild.man
43         ./mdwn2man ikiwiki-makerepo 1 doc/ikiwiki-makerepo.mdwn > ikiwiki-makerepo.man
44         ./mdwn2man ikiwiki-transition 1 doc/ikiwiki-transition.mdwn > ikiwiki-transition.man
45         ./mdwn2man ikiwiki-update-wikilist 1 doc/ikiwiki-update-wikilist.mdwn > ikiwiki-update-wikilist.man
46         ./mdwn2man ikiwiki-calendar 1 doc/ikiwiki-calendar.mdwn > ikiwiki-calendar.man
47         $(MAKE) -C po
48         sed -i.bkp "s/Version:.*/Version: $$(perl -e '$$_=<>;print m/\((.*?)\)/'<debian/changelog)/" ikiwiki.spec
49         rm -f ikiwiki.spec.bkp
50         
51 docwiki: ikiwiki.out
52         $(PERL) -Iblib/lib $(extramodules) $(tflag) ikiwiki.out -libdir . -setup docwiki.setup -refresh
53
54 extra_clean:
55         $(PERL) -I. $(extramodules) $(tflag) ikiwiki.in -libdir . -setup docwiki.setup -clean
56         rm -f *.man $(outprogs) ikiwiki.setup plugins/*.pyc
57         $(MAKE) -C po clean
58
59 underlay_install:
60         install -d $(DESTDIR)$(PREFIX)/share/ikiwiki
61         for dir in `cd underlays && find . -follow -type d ! -regex '.*\.svn.*'`; do \
62                 install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
63                 for file in `find underlays/$$dir -follow -maxdepth 1 -type f`; do \
64                         cp -aL $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir 2>/dev/null || \
65                         install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
66                 done; \
67         done
68
69         # The directive docs become their own special underlay.
70         install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/directives/ikiwiki/directive
71         for file in doc/ikiwiki/directive/*; do \
72                 if [ -f "$$file" ]; then \
73                         install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/directives/ikiwiki/directive; \
74                 fi \
75         done
76         
77 extra_install: underlay_install
78         # Install example sites.
79         for dir in `cd doc/examples; find . -type d ! -regex '.*\.svn.*'`; do \
80                 install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/examples/$$dir; \
81         done
82         for file in `cd doc/examples; find . -type f ! -regex '.*\.svn.*'`; do \
83                 cp -aL doc/examples/$$file $(DESTDIR)$(PREFIX)/share/ikiwiki/examples/$$file 2>/dev/null || \
84                 install -m 644 doc/examples/$$file $(DESTDIR)$(PREFIX)/share/ikiwiki/examples/$$file; \
85         done
86
87         for dir in `find templates -follow -type d ! -regex '.*\.svn.*'`; do \
88                 install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
89                 for file in `find $$dir -follow -maxdepth 1 -type f`; do \
90                         install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
91                 done; \
92         done
93         
94         install -d $(DESTDIR)$(PREFIX)/lib/ikiwiki/plugins
95         for file in `find plugins -maxdepth 1 -type f ! -path plugins/.\* ! -name \*demo\* -name \*.py`; do \
96                 install -m 644 $$file $(DESTDIR)$(PREFIX)/lib/ikiwiki/plugins; \
97         done
98         for file in `find plugins -maxdepth 1 -type f ! -path plugins/.\* ! -name \*demo\* ! -name \*.py ! -name \*.pyc`; do \
99                 install -m 755 $$file $(DESTDIR)$(PREFIX)/lib/ikiwiki/plugins; \
100         done
101
102         install -d $(DESTDIR)$(PREFIX)/share/man/man1
103         install -m 644 ikiwiki.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki.1
104         install -m 644 ikiwiki-makerepo.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-makerepo.1
105         install -m 644 ikiwiki-transition.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-transition.1
106         install -m 644 ikiwiki-update-wikilist.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-update-wikilist.1
107         install -m 644 ikiwiki-calendar.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-calendar.1
108         
109         install -d $(DESTDIR)$(PREFIX)/share/man/man8
110         install -m 644 ikiwiki-mass-rebuild.man $(DESTDIR)$(PREFIX)/share/man/man8/ikiwiki-mass-rebuild.8
111         
112         install -d $(DESTDIR)$(PREFIX)/sbin
113         install ikiwiki-mass-rebuild $(DESTDIR)$(PREFIX)/sbin
114
115         install -d $(DESTDIR)$(W3M_CGI_BIN)
116         install ikiwiki-w3m.cgi $(DESTDIR)$(W3M_CGI_BIN)
117
118         install -d $(DESTDIR)$(PREFIX)/bin
119         for prog in $(outprogs); do \
120                 install $$prog $(DESTDIR)$(PREFIX)/bin/$$(shell echo $$prog | sed 's/\.out//'); \
121         done
122
123         $(MAKE) -C po install DESTDIR=$(DESTDIR) PREFIX=$(PREFIX)
124         
125         # These might fail if a regular user is installing into a home
126         # directory.
127         -install -d $(DESTDIR)/etc/ikiwiki
128         -install -m 0644 wikilist $(DESTDIR)/etc/ikiwiki
129         -install -m 0644 auto.setup $(DESTDIR)/etc/ikiwiki
130         -install -m 0644 auto-blog.setup $(DESTDIR)/etc/ikiwiki
131 }
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 );