create translated underlays in mdwn format
[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:Profile"; fi)
31
32 ikiwiki.out: ikiwiki.in
33         ./pm_filter $(PREFIX) $(VER) $(PROBABLE_INST_LIB) < ikiwiki.in > ikiwiki.out
34         chmod +x ikiwiki.out
35
36 ikiwiki.setup: ikiwiki.out
37         HOME=/home/me $(PERL) -Iblib/lib $(extramodules) $(tflag) ikiwiki.out -libdir . -dumpsetup ikiwiki.setup
38
39 extra_build: ikiwiki.out ikiwiki.setup docwiki
40         ./mdwn2man ikiwiki 1 doc/usage.mdwn > ikiwiki.man
41         ./mdwn2man ikiwiki-mass-rebuild 8 doc/ikiwiki-mass-rebuild.mdwn > ikiwiki-mass-rebuild.man
42         ./mdwn2man ikiwiki-makerepo 1 doc/ikiwiki-makerepo.mdwn > ikiwiki-makerepo.man
43         ./mdwn2man ikiwiki-transition 1 doc/ikiwiki-transition.mdwn > ikiwiki-transition.man
44         ./mdwn2man ikiwiki-update-wikilist 1 doc/ikiwiki-update-wikilist.mdwn > ikiwiki-update-wikilist.man
45         $(MAKE) -C po
46         
47 docwiki: ikiwiki.out
48         $(PERL) -Iblib/lib $(extramodules) $(tflag) ikiwiki.out -libdir . -setup docwiki.setup -refresh
49
50 underlaypo: ikiwiki.out
51         # copy all the files we want to translate into the
52         # po/underlays scrdir.
53         for file in `find underlays -follow -name \*.mdwn`; do \
54                 install -d po/$$(dirname $$file); \
55                 cp -aL $$file po/$$file 2>/dev/null || \
56                 install -m 644 $$file po/$$file; \
57         done
58         install -d po/underlays/directives/ikiwiki/directive
59         for file in doc/ikiwiki/directive/*; do \
60                 if [ -f "$$file" ]; then \
61                         cp -a $$file po/underlays/directives/ikiwiki/directive ||  \
62                         install -m 644 $$file po/underlays/directives/ikiwiki/directive; \
63                 fi \
64         done
65         install -d po/underlays/empty
66         $(PERL) -Iblib/lib $(extramodules) $(tflag) ikiwiki.out -libdir . -setup underlaypo.setup -refresh
67         PERL5LIB=. po/po2wiki underlaypo.setup
68         find po/underlays -name \*.mdwn | xargs rm -f
69
70 extra_clean:
71         rm -rf html doc/.ikiwiki
72         rm -f *.man ikiwiki.out ikiwiki.setup plugins/*.pyc
73         $(MAKE) -C po clean
74         rm -rf po/html po/underlays/.ikiwiki
75
76 extra_install:
77         install -d $(DESTDIR)$(PREFIX)/share/ikiwiki
78         for dir in `cd underlays && find . -follow -type d ! -regex '.*\.svn.*'`; do \
79                 install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
80                 for file in `find underlays/$$dir -follow -maxdepth 1 -type f`; do \
81                         cp -aL $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir 2>/dev/null || \
82                         install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
83                 done; \
84         done
85
86         # The directive docs become their own special underlay.
87         install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/directives/ikiwiki/directive
88         for file in doc/ikiwiki/directive/*; do \
89                 if [ -f "$$file" ]; then \
90                         install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/directives/ikiwiki/directive; \
91                 fi \
92         done
93         
94         # Install example sites.
95         for dir in `cd doc/examples; find . -type d ! -regex '.*\.svn.*'`; do \
96                 install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/examples/$$dir; \
97         done
98         for file in `cd doc/examples; find . -type f ! -regex '.*\.svn.*'`; do \
99                 cp -aL doc/examples/$$file $(DESTDIR)$(PREFIX)/share/ikiwiki/examples/$$file 2>/dev/null || \
100                 install -m 644 doc/examples/$$file $(DESTDIR)$(PREFIX)/share/ikiwiki/examples/$$file; \
101         done
102
103         for dir in `find templates -follow -type d ! -regex '.*\.svn.*'`; do \
104                 install -d $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
105                 for file in `find $$dir -follow -maxdepth 1 -type f`; do \
106                         install -m 644 $$file $(DESTDIR)$(PREFIX)/share/ikiwiki/$$dir; \
107                 done; \
108         done
109         
110         install -d $(DESTDIR)$(PREFIX)/lib/ikiwiki/plugins
111         for file in `find plugins -maxdepth 1 -type f ! -path plugins/.\* ! -name \*demo\* -name \*.py`; do \
112                 install -m 644 $$file $(DESTDIR)$(PREFIX)/lib/ikiwiki/plugins; \
113         done
114         for file in `find plugins -maxdepth 1 -type f ! -path plugins/.\* ! -name \*demo\* ! -name \*.py ! -name \*.pyc`; do \
115                 install -m 755 $$file $(DESTDIR)$(PREFIX)/lib/ikiwiki/plugins; \
116         done
117
118         install -d $(DESTDIR)$(PREFIX)/share/man/man1
119         install -m 644 ikiwiki.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki.1
120         install -m 644 ikiwiki-makerepo.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-makerepo.1
121         install -m 644 ikiwiki-transition.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-transition.1
122         install -m 644 ikiwiki-update-wikilist.man $(DESTDIR)$(PREFIX)/share/man/man1/ikiwiki-update-wikilist.1
123         
124         install -d $(DESTDIR)$(PREFIX)/share/man/man8
125         install -m 644 ikiwiki-mass-rebuild.man $(DESTDIR)$(PREFIX)/share/man/man8/ikiwiki-mass-rebuild.8
126         
127         install -d $(DESTDIR)$(PREFIX)/sbin
128         install ikiwiki-mass-rebuild $(DESTDIR)$(PREFIX)/sbin
129
130         install -d $(DESTDIR)$(W3M_CGI_BIN)
131         install ikiwiki-w3m.cgi $(DESTDIR)$(W3M_CGI_BIN)
132
133         install -d $(DESTDIR)$(PREFIX)/bin
134         install ikiwiki.out $(DESTDIR)$(PREFIX)/bin/ikiwiki
135         install ikiwiki-makerepo ikiwiki-transition ikiwiki-update-wikilist $(DESTDIR)$(PREFIX)/bin/
136
137         $(MAKE) -C po install DESTDIR=$(DESTDIR) PREFIX=$(PREFIX)
138         
139         # These might fail if a regular user is installing into a home
140         # directory.
141         -install -d $(DESTDIR)/etc/ikiwiki
142         -install -m 0644 wikilist $(DESTDIR)/etc/ikiwiki
143         -install -m 0644 auto.setup $(DESTDIR)/etc/ikiwiki
144         -install -m 0644 auto-blog.setup $(DESTDIR)/etc/ikiwiki
145 }
146 }
147
148 WriteMakefile(
149         NAME            => 'IkiWiki',
150         PREFIX          => "/usr/local",
151         PM_FILTER       => './pm_filter $(PREFIX) $(VER) $(PROBABLE_INST_LIB)',
152         MAN1PODS        => {},
153         PREREQ_PM       => {
154                 'XML::Simple'           => 0,
155                 'Text::Markdown'        => 0,
156                 'Date::Parse'           => 0,
157                 'HTML::Template'        => 0,
158                 'HTML::Scrubber'        => 0,
159                 'CGI::FormBuilder'      => 3.02.02,
160                 'CGI::Session'          => 0,
161                 'Mail::Sendmail'        => 0,
162                 'HTML::Parser'          => 0,
163                 'URI'                   => 0,
164                 'Data::Dumper'          => 2.11,
165         },
166 );