Add Paris Observatory Information System website
[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 # Parameterized programs used by Makefile.
17 FIND?=find
18 SED?=sed
19
20 # Additional configurable path variables.
21 W3M_CGI_BIN?=$(PREFIX)/lib/w3m/cgi-bin
22 SYSCONFDIR?=/etc/ikiwiki
23 MANDIR?=$(PREFIX)/share/man
24
25 tflag=$(shell if [ -n "$$NOTAINT" ] && [ "$$NOTAINT" != 1 ]; then printf -- "-T"; fi)
26 extramodules=$(shell if [ "$$PROFILE" = 1 ]; then printf -- "-d:NYTProf"; fi)
27 outprogs=ikiwiki.out ikiwiki-transition.out ikiwiki-calendar.out
28 scripts=ikiwiki-update-wikilist ikiwiki-makerepo
29 sysconfdir_scripts=ikiwiki-mass-rebuild ikiwiki-update-wikilist
30
31 PROBABLE_INST_LIB=$(shell \\
32         if [ "$(INSTALLDIRS)" = "perl" ]; then \\
33                 echo $(INSTALLPRIVLIB); \\
34         elif [ "$(INSTALLDIRS)" = "site" ]; then \\
35                 echo $(INSTALLSITELIB); \\
36         elif [ "$(INSTALLDIRS)" = "vendor" ]; then \\
37                 echo $(INSTALLVENDORLIB); \\
38         fi \\
39 )
40
41 %.out: %.in
42         ./pm_filter $(PREFIX) $(VER) $(PROBABLE_INST_LIB) < $< > $@
43         chmod +x $@
44
45 ikiwiki.setup:
46         HOME=/home/me $(PERL) -Iblib/lib $(extramodules) $(tflag) ikiwiki.in -dumpsetup ikiwiki.setup
47
48 extra_build: $(outprogs) ikiwiki.setup docwiki sysconfdir
49         ./mdwn2man ikiwiki 1 doc/usage.mdwn > ikiwiki.man
50         ./mdwn2man ikiwiki-mass-rebuild 8 doc/ikiwiki-mass-rebuild.mdwn > ikiwiki-mass-rebuild.man
51         ./mdwn2man ikiwiki-makerepo 1 doc/ikiwiki-makerepo.mdwn > ikiwiki-makerepo.man
52         ./mdwn2man ikiwiki-transition 1 doc/ikiwiki-transition.mdwn > ikiwiki-transition.man
53         ./mdwn2man ikiwiki-update-wikilist 1 doc/ikiwiki-update-wikilist.mdwn > ikiwiki-update-wikilist.man
54         ./mdwn2man ikiwiki-calendar 1 doc/ikiwiki-calendar.mdwn > ikiwiki-calendar.man
55         $(MAKE) -C po
56         $(PERL) -pi.bkp -e "s/Version:.*/Version: $(VER)/" ikiwiki.spec
57         rm -f ikiwiki.spec.bkp
58         
59 docwiki:
60         $(PERL) -Iblib/lib $(extramodules) $(tflag) ikiwiki.in -setup docwiki.setup -refresh
61
62 sysconfdir:
63         $(PERL) -pi -e "s|/etc/ikiwiki|$(SYSCONFDIR)|g" $(sysconfdir_scripts)
64         
65 extra_clean:
66         $(PERL) -Iblib/lib $(extramodules) $(tflag) ikiwiki.in -setup docwiki.setup -clean
67         rm -f *.man $(outprogs) ikiwiki.setup plugins/*.pyc
68         $(MAKE) -C po clean
69
70 # Joey uses this before committing.
71 myclean: clean
72         git checkout po ikiwiki.spec
73
74 underlay_install:
75         install -d $(DESTDIR)$(PREFIX)/share/ikiwiki
76         for dir in `cd underlays && $(FIND) . -follow -type d`; do \
77                 install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
78                 for file in `$(FIND) underlays/$$dir -follow -maxdepth 1 -type f ! -name \\*.full.js ! -name \\*.full.css`; do \
79                         cp -pRL $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir 2>/dev/null || \
80                         install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
81                 done; \
82         done
83
84         # The directive docs become their own special underlay.
85         install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/directives/ikiwiki/directive
86         for file in doc/ikiwiki/directive/*; do \
87                 if [ -f "$$file" ]; then \
88                         cp -pRL $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/directives/ikiwiki/directive 2>/dev/null || \
89                         install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/directives/ikiwiki/directive; \
90                 fi \
91         done
92
93         # Themes have their base.css (if present) and then
94         # style.css appended to the normal one.
95         for theme in themes/*; do \
96                 install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/$$theme; \
97                 for file in $$theme/*; do \
98                         if echo "$$file" | grep -q style.css; then \
99                                 (cat doc/style.css; cat $$theme/base.css 2>/dev/null; cat $$file) >> $(DESTDIR)$(PREFIX)/share/ikiwiki/$$theme/style.css; \
100                         elif echo "$$file" | grep -q base.css; then \
101                                 :; \
102                         elif [ -f "$$file" ]; then \
103                                 cp -pRL $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$file 2>/dev/null || \
104                                 install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$file; \
105                         fi \
106                 done; \
107         done
108
109 extra_install: underlay_install
110         # Install example sites.
111         for dir in `cd doc/examples; $(FIND) . -type d ! -regex '.*discussion.*'`; do \
112                 install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/examples/$$dir; \
113         done
114         for file in `cd doc/examples; $(FIND) . -type f ! -regex '.*discussion.*'`; do \
115                 cp -pRL doc/examples/$$file $(DESTDIR)$(PREFIX)/share/ikiwiki/examples/$$file 2>/dev/null || \
116                 install -m 644 doc/examples/$$file $(DESTDIR)$(PREFIX)/share/ikiwiki/examples/$$file; \
117         done
118
119         for dir in `$(FIND) templates -follow -type d`; do \
120                 install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
121                 for file in `$(FIND) $$dir -follow -maxdepth 1 -type f`; do \
122                         install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
123                 done; \
124         done
125         
126         install -d $(DESTDIR)$(PREFIX)/lib/ikiwiki/plugins
127         for file in `$(FIND) plugins -maxdepth 1 -type f ! -path plugins/.\* ! -name \*demo\* -name \*.py`; do \
128                 install -m 644 $$file $(DESTDIR)$(PREFIX)/lib/ikiwiki/plugins; \
129         done
130         for file in `$(FIND) plugins -maxdepth 1 -type f ! -path plugins/.\* ! -name \*demo\* ! -name \*.py ! -name \*.pyc`; do \
131                 install -m 755 $$file $(DESTDIR)$(PREFIX)/lib/ikiwiki/plugins; \
132         done
133
134         install -d $(DESTDIR)$(MANDIR)/man1
135         install -m 644 ikiwiki.man $(DESTDIR)$(MANDIR)/man1/ikiwiki.1
136         install -m 644 ikiwiki-makerepo.man $(DESTDIR)$(MANDIR)/man1/ikiwiki-makerepo.1
137         install -m 644 ikiwiki-transition.man $(DESTDIR)$(MANDIR)/man1/ikiwiki-transition.1
138         install -m 644 ikiwiki-update-wikilist.man $(DESTDIR)$(MANDIR)/man1/ikiwiki-update-wikilist.1
139         install -m 644 ikiwiki-calendar.man $(DESTDIR)$(MANDIR)/man1/ikiwiki-calendar.1
140         
141         install -d $(DESTDIR)$(MANDIR)/man8
142         install -m 644 ikiwiki-mass-rebuild.man $(DESTDIR)$(MANDIR)/man8/ikiwiki-mass-rebuild.8
143         
144         install -d $(DESTDIR)$(PREFIX)/sbin
145         install ikiwiki-mass-rebuild $(DESTDIR)$(PREFIX)/sbin
146
147         install -d $(DESTDIR)$(W3M_CGI_BIN)
148         install ikiwiki-w3m.cgi $(DESTDIR)$(W3M_CGI_BIN)
149
150         install -d $(DESTDIR)$(PREFIX)/bin
151         for prog in $(outprogs) $(scripts); do \
152                 install $$prog $(DESTDIR)$(PREFIX)/bin/$$(echo $$prog | $(SED) 's/\.out//'); \
153         done
154
155         $(MAKE) -C po install DESTDIR=$(DESTDIR) PREFIX=$(PREFIX)
156         
157         # These might fail if a regular user is installing into a home
158         # directory.
159         -install -d $(DESTDIR)$(SYSCONFDIR)
160         -install -m 0644 wikilist $(DESTDIR)$(SYSCONFDIR)
161         -install -m 0644 auto.setup $(DESTDIR)$(SYSCONFDIR)
162         -install -m 0644 auto-blog.setup $(DESTDIR)$(SYSCONFDIR)
163
164 # The git/hg plugins want to chdir; so does Devel::Cover. Skip those tests
165 # to stop them hurting each other.
166 coverage:
167         cover -delete
168         $(MAKE) test PERL5OPT=-MDevel::Cover PERL5LIB=. TEST_FILES="$(filter-out t/git.t t/mercurial.t,$(wildcard t/*.t))"
169         cover
170 }
171 }
172
173 WriteMakefile(
174         NAME            => 'IkiWiki',
175         PREFIX          => "/usr/local",
176         PM_FILTER       => './pm_filter $(PREFIX) $(VER) $(PROBABLE_INST_LIB)',
177         MAN1PODS        => {},
178         PREREQ_PM       => {
179                 'XML::Simple'           => "0",
180                 'Text::Markdown'        => "0",
181                 'Date::Parse'           => "0",
182                 'HTML::Template'        => "0",
183                 'HTML::Scrubber'        => "0",
184                 'CGI::FormBuilder'      => "3.02.02",
185                 'CGI::Session'          => "0",
186                 'Mail::Sendmail'        => "0",
187                 'HTML::Parser'          => "0",
188                 'URI'                   => "0",
189                 'Data::Dumper'          => "2.11",
190         },
191 );