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