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