source: trunk/LATMOS-Accounts/Makefile.PL @ 1546

Last change on this file since 1546 was 1546, checked in by nanardon, 8 years ago

Add I18N support

File size: 7.3 KB
Line 
1use 5.010000;
2use ExtUtils::MakeMaker;
3# See lib/ExtUtils/MakeMaker.pm for details of how to influence
4# the contents of the Makefile that is written.
5WriteMakefile(
6    NAME              => 'LATMOS::Accounts',
7    VERSION_FROM      => 'lib/LATMOS/Accounts.pm',
8    PREREQ_PM         => {
9        'Net::LDAP' => undef,
10        'Unicode::Map8' => undef,
11        'DBD::Pg' => undef,
12        'Crypt::RSA' => undef,
13        'MIME::Base64' => undef,
14        'Term::ReadKey' => undef,
15        'Config::IniFiles' => undef,
16        'Mail::Sendmail' => undef,
17        'Net::DNS' => undef,
18        'Template' => undef,
19        'Sys::Syslog' => undef,
20        'Pod::Usage' => undef,
21        'Unicode::String' => undef,
22        'Crypt::Cracklib' => undef,
23        'Net::IP' => undef,
24        'Net::IPv4Addr' => undef,
25        'Net::IPv6Addr' => undef,
26        'DateTime' => undef,
27        'SOAP::Lite' => undef,
28        'HTTP::Cookies' => undef,
29        'XML::XPath' => undef,
30    }, # e.g., Module::Name => 1.1
31    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
32      (ABSTRACT_FROM  => 'lib/LATMOS/Accounts.pm', # retrieve abstract from module
33       AUTHOR         => 'Thauvin Olivier <olivier.thauvin@latmos.ipsl.fr>') : ()),
34    EXE_FILES => [ qw(
35        bin/la-acls
36        bin/la-qacls
37        bin/la-attributes
38        bin/la-cli
39        bin/la-config
40        bin/la-create
41        bin/la-sql-crypt-passwd
42        bin/la-delete
43        bin/la-edit
44        bin/la-sql-find-expired
45        bin/la-group
46        bin/la-guser
47        bin/la-passwd
48        bin/la-query
49        bin/la-rename
50        bin/la-sql-rename-host
51        bin/la-sql-exchange-ip
52        bin/la-sql-exchange-hostname
53        bin/la-sql-switch-cname
54        bin/la-sql-rev
55        bin/la-search
56        bin/la-sync
57        bin/la-sync-manager
58        bin/la-sync-ctl
59        bin/la-warn-expire
60        bin/la-sql-freeip
61        bin/la-expired-reminder
62        bin/la-sql-upgrade
63        bin/la-sql-edit-form
64        bin/la-sql-updsshfp
65        bin/la-test-mail
66        bin/la-sql-log
67        bin/la-sql-runstat
68        bin/la-sql-stat2csv
69        ) ],
70        macro => {
71            INSTALLMAN5DIR      => '$(PERLPREFIX)/share/man/man5',
72            INSTALLMAN8DIR      => '$(PERLPREFIX)/share/man/man8',
73            DESTINSTALLMAN5DIR  => '$(DESTDIR)$(INSTALLMAN5DIR)',
74            DESTINSTALLMAN8DIR  => '$(DESTDIR)$(INSTALLMAN8DIR)',
75            LOCALEDIR           => '/usr/share/locale',
76            INST_MAN5DIR        => 'blib/man5',
77            INST_MAN8DIR        => 'blib/man8',
78            DESTRPMDIR          => '$(shell pwd)',
79            DATADIR             => '/usr/share/latmos-accounts',
80            DESTDATADIR         => '$(DESTDIR)$(DATADIR)',
81        },
82        MAN1PODS        => {
83            map {
84                my $targ = $_;
85                $targ =~ s{^man/man(\d)}{};
86                my $section = $1 || 1;
87                $targ =~ s{^bin/}{};
88                $targ =~ s/.pod$//;
89                ( $_ =>
90                    "\$(INST_MAN${section}DIR)/$targ.$section" );
91            } <man/man?/*.pod>, (grep { ! /~$/ } <bin/*>)
92        },
93
94);
95
96package MY;
97
98sub postamble {
99
100    my @po = map { m:lib/LATMOS/Accounts/I18N/([^\.]+)\.po$:; $1 }
101            glob('lib/LATMOS/Accounts/I18N/*.po');
102
103    my $makepo = join("\n\n", map {
104        "
105lib/LATMOS/Accounts/I18N/$_.po: lib/LATMOS/Accounts/I18N/messages.pot
106\t[ -f lib/LATMOS/Accounts/I18N/$_.po ] || msginit --no-translator --input=lib/LATMOS/Accounts/I18N/messages.pot --output= --locale=$_
107\tmsgmerge -U lib/LATMOS/Accounts/I18N/$_.po lib/LATMOS/Accounts/I18N/messages.pot
108
109        "
110        } @po
111    );
112
113    $makepo .= "\n\npo: " . join(' ', map { "lib/LATMOS/Accounts/I18N/$_.po" } @po) . "\n";
114
115    <<EOF;
116#.PHONY .= svnmanifest
117
118pot: lib/LATMOS/Accounts/I18N/messages.pot
119
120lib/LATMOS/Accounts/I18N/messages.pot:
121\tcat MANIFEST | egrep '^(lib|bin)' | xargs xgettext.pl -o lib/LATMOS/Accounts/I18N/messages.pot
122
123$makepo
124
125bin/la-sql-upgrade: bin/la-sql-upgrade.in
126\tcat \$< \| sed 's:\@DATADIR\@:\$(DATADIR):' > \$@
127\tchmod +x \$@
128
129svnmanifest:
130\tsvn ls -R| grep -v "/\$\$"  > MANIFEST
131
132ChangeLog:
133\tsvn log > ChangeLog
134
135latmos-accounts.spec: latmos-accounts.spec.in Makefile
136\tsed -e 's/\@VERSION@/\$(VERSION)/' < \$< > \$@
137
138rpm: \$(DISTVNAME).tar.gz latmos-accounts.spec
139\tmkdir ./noarch || :
140\trpmbuild -ba --clean\\
141\t --define "_sourcedir `pwd`" \\
142\t --define "_specdir `pwd`" \\
143\t --define "_srcrpmdir \$(DESTRPMDIR)" \\
144\t --define "_rpmdir \$(DESTRPMDIR)" \\
145\t latmos-accounts.spec
146
147svnrpm: \$(DISTVNAME).tar.gz latmos-accounts.spec
148\tmkdir \$(DESTRPMDIR)/noarch || :
149\trpmbuild -ba --clean\\
150\t --define "_sourcedir `pwd`" \\
151\t --define "_specdir `pwd`" \\
152\t --define "_srcrpmdir \$(DESTRPMDIR)" \\
153\t --define "_rpmdir \$(DESTRPMDIR)" \\
154\t --define "svnrelease `LC_ALL=C svn info | grep '^Revision:' | sed 's/Revision: //'`" \\
155\t latmos-accounts.spec
156
157podhtml: \$(MAN1PODS) \$(MAN3PODS)
158\tmkdir html || :
159\trm -f html/*
160\tperl scripts/pod2xhtml.pl \$(MAN1PODS) \$(MAN3PODS)
161
162EOF
163}
164
165sub installbin {
166    my $self = shift;
167    my $inherited = $self->SUPER::installbin(@_);
168    my $s = join '|', map quotemeta, @sbin_scripts;
169    # how to create needed directories under blib
170    $inherited .= $self->dir_target("\$(INST_$_)") for qw(MAN5DIR MAN8DIR);
171    $inherited;
172}
173
174sub top_targets {
175    my $inherited = shift->SUPER::top_targets(@_);
176    $inherited =~ s/^config ::/$& \$(INST_MAN5DIR)\$(DIRFILESEP).exists \$(INST_MAN8DIR)\$(DIRFILESEP).exists/m;
177    $inherited;
178}
179
180sub install {
181    my ($self) = @_;
182    my $section = $self->SUPER::install();
183
184    $section =~ s/(^install ::.*)/$1 install_config install_templates install_data install_po/m;
185    $section =~ s/\$\(INST_BIN\) \$\(DESTINSTALL(\w*)BIN\)/$& \$(INST_MAN5DIR) \$(DESTINSTALLMAN5DIR) \$(INST_MAN8DIR) \$(DESTINSTALLMAN8DIR)/g;
186
187    $section .= q[
188install_config ::
189        install -d $(DESTDIR)/etc
190        install -d $(DESTDIR)/etc/latmos-accounts
191        install sample/latmos-accounts.ini $(DESTDIR)/etc/latmos-accounts/latmos-accounts.ini
192        install sample/la-sync-list.ini $(DESTDIR)/etc/latmos-accounts/la-sync-list.ini
193        install sample/la-allowed-values.ini $(DESTDIR)/etc/latmos-accounts/la-allowed-values.ini
194        install sample/la-sync-manager.ini $(DESTDIR)/etc/latmos-accounts/la-sync-manager.ini
195
196install_templates ::
197        install -d $(DESTDIR)$(DATADIR)/templates
198        $(ABSPERLRUN) -MExtUtils::Install -e 'install({ templates => @ARGV })' \\
199                $(DESTDIR)$(DATADIR)/templates
200
201install_data ::
202        install -d $(DESTDIR)$(DATADIR)
203        $(ABSPERLRUN) -MExtUtils::Install -e 'install({ sqldata => @ARGV })' \\
204            $(DESTDIR)$(DATADIR)
205
206install_po ::
207        install -d $(DESTDIR)$(LOCALEDIR)/LATMOS::Accounts
208        $(ABSPERLRUN) -MExtUtils::Install -e 'install({ "lib/LATMOS/Accounts/I18N" => @ARGV })' \\
209        $(DESTDIR)$(LOCALEDIR)/LATMOS::Accounts
210];
211 
212    return $section;
213}
214
215sub test {
216    my $inherited = shift->SUPER::test(@_);
217
218    $inherited =~ s:^(test_dynamic .*):$1 test_scripts:m;
219
220    $inherited .= <<EOF;
221
222TESTLIVE_FILES = live-test/*.t
223TESTSCRIPTS_FILE = t/scripts.pl
224
225test_live :: pure_all
226\tPERL_DL_NONLAZY=1 \$(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness(\$(TEST_VERBOSE), '\$(INST_LIB)', '\$(INST_ARCHLIB)')" \$(TESTLIVE_FILES)
227
228test_scripts :: pure_all
229\tPERL_DL_NONLAZY=1 \$(FULLPERLRUN) "-I\$(INST_LIB)" "-I\$(INST_ARCHLIB)" \$(TESTSCRIPTS_FILE) \$(EXE_FILES)
230EOF
231    return $inherited;
232}
Note: See TracBrowser for help on using the repository browser.