aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile.PL
blob: d70bb9ff7d33786017fa483a3244e6103e817eb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
use 5.006;
use strict;
use warnings FATAL => 'all';
use ExtUtils::MakeMaker;
use File::ShareDir::Install;

install_share dist => 'share';


WriteMakefile(
    NAME             => 'ManaTools',
    DISTNAME         => 'manatools',
    AUTHOR           => q{Angelo Naselli <anaselli@linux.it> - Matteo Pasotti <matteo.pasotti@gmail.com>},
    VERSION_FROM     => 'lib/ManaTools/Version.pm',
    ABSTRACT         => 'ManaTools is a generic launcher application that can run perl modules or external programs using Suse YUI abstarction.',
    LICENSE          => 'GPL_2',
    PL_FILES         => {},
    MIN_PERL_VERSION => 5.006,
    CONFIGURE_REQUIRES => {
        'ExtUtils::MakeMaker' => 0,
    },
    BUILD_REQUIRES => {
        'Test::More' => 0,
        'File::ShareDir::Install' => 0,
    },
    PREREQ_PM => {
        "Moose"              => 0,
        "Moose::Autobox"     => 0,
        "MooseX::Getopt"     => 0,
        "MooseX::ClassAttribute" => 0,
        "Config::Auto"       => 0,
        "Config::Hosts"      => 0,
        "Config::Tiny"       => 0,
        # ManaTools::Shared::Locales
        "Locale::gettext"    => 0,
        "Text::Iconv"        => 0,
        "Text::Diff"         => 0,
        "Date::Simple"       => 0,
        "DateTime::TimeZone" => 0,
        "Time::Piece"        => 0,
        "Time::HiRes"        => 0,
        "File::HomeDir"      => 0,
        "File::ShareDir"     => 0,
        "File::Copy"         => 0,
        "File::Remove"       => 0,
        "File::Basename"     => 0,
        "Sys::Syslog"        => 0,
        "Data::Password::Meter"    => 0,
        "Digest::MD5"        => 0,
        "IO::All"            => 0,
        "XML::Simple"        => 0,
        #Mandriva
        "MDK::Common"         => 0,
        "MDK::Common::File"   => 0,
        "MDK::Common::Func"   => 0,
        "MDK::Common::System" => 0,
        "MDK::Common::String" => 0,
        "MDK::Common::Various" => 0,
        "MDK::Common::DataStructure" => 0,
        "Net::DBus"           => 0,
        "URPM"                => 0,
        "Glib"                => 0,
        "POSIX"               => 0,
        "utf8"               => 0,

        "English"             => 0,
        "Modern::Perl"        => 1.03,
        "autodie"             => 2.20,
    },
    EXE_FILES => [ qw( scripts/mpan
                       scripts/mana
                       scripts/manaadduser
                       scripts/manaclock
                       scripts/manadm
                       scripts/manahost
                       scripts/manalog
                       scripts/manaproxy
                       scripts/manaservice
                       scripts/manauser
                       scripts/manawall
                       modules/contribfinder.py
                       modules/rpmdragora/dragora-urpm-addmedia
                       modules/rpmdragora/dragora-urpm-sources.pl
                       modules/rpmdragora/dragoraUpdate
                       modules/rpmdragora/rpmdragora
                       ) ],
    dist  => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
    clean => { FILES => 'ManaTools-*' },
);

package MY;

sub postamble {
    my $inherited = File::ShareDir::Install::postamble(@_);

    my $newTargets = << 'MAKE_FRAG';

# Installation directories
localedir = $(PREFIX)/share/locale

PGOAL = manatools

# perl files to search translatable strings in
PL_FILES = $(shell find lib/ManaTools/ -type f -name "*.pm") \
	$(shell find scripts/ -type f -name "*") \
	modules/rpmdragora/dragoraUpdate \
	modules/rpmdragora/rpmdragora \
	modules/rpmdragora/dragora-urpm-addmedia \
	modules/rpmdragora/dragora-urpm-sources.pl

# its files (let's use them all at the moment)
ITS_FILES = -i extras/polkit/policy.its \
            -i extras/conf/mpan/categories.its \
            -i extras/conf/mpan/settings.its \
            -i extras/conf/manawall/manawall.its 

# polkit files
POL_IN_FILES = $(shell find extras/polkit/*.policy.in)
POL_FILES = $(POL_IN_FILES:%.policy.in=%.policy)

# manatools configuration files
CONF_IN_FILES =  $(shell find  extras/conf/mpan/ -type f -name "*.conf.in") \
	$(shell find  extras/conf/manawall/ -type f -name "*.conf.in")
CONF_FILES = $(CONF_IN_FILES:%.conf.in=%.conf)

# deskrop files
DESKTOP_IN_FILES = $(shell find extras/desktop/*.desktop.in)
DESKTOP_FILES = $(DESKTOP_IN_FILES:%.desktop.in=%.desktop)

POFILES = $(shell find po/ -name "*.po")
MOFILES = $(POFILES:%.po=%.mo)
LANGS = $(POFILES:po/%.po=%)
LINGUAS = $(LANGS)

GOALS = $(PGOAL).pot  $(MOFILES)

locales: $(GOALS)

install_locales: locales 
	# add translation in policy file
	for p in $(POL_IN_FILES); do \
		itstool -j $$p $(ITS_FILES) -o "$${p%.*}" `ls po/*.mo`; \
	done
	for p in $(CONF_IN_FILES); do \
		itstool -j $$p $(ITS_FILES) -o "$${p%.*}" `ls po/*.mo`; \
	done
	echo $(LINGUAS) > po/LINGUAS
	for p in $(DESKTOP_IN_FILES); do \
		msgfmt --desktop --template $$p -d po -o "$${p%.*}"; \
	done
	cd po && for l in $(LANGS); do \
		install -d $(localedir)/$$l/LC_MESSAGES; \
		install -m 644 $$l.mo $(localedir)/$$l/LC_MESSAGES/$(PGOAL).mo; \
	done

clean_locales:
	rm -f po/*~ po/*.[oas] po/*.mo po/manatools_perl.pot po/manapol.pot \
	po/manaconf.pot po/manadesktop.pot $(POL_FILES) $(CONF_FILES) $(DESKTOP_FILES)

%.mo: %.po
	msgfmt --check -o $@ $<

$(PGOAL).pot: manatools_perl.pot manapol.pot manaconf.pot manadesktop.pot
	msgcat po/manatools_perl.pot po/manapol.pot \
	po/manaconf.pot po/manadesktop.pot > po/$@

manatools_perl.pot: $(PL_FILES)  
	xgettext --from-code=UTF-8 --language=Perl -D ./ -o po/$@ \
		--msgid-bugs-address="https://bugs.mageia.org/" \
		--package-name=$(NAME) --package-version=$(VERSION) \
		--copyright-holder="Angelo Naselli - Matteo Pasotti" \
		--keyword=N --keyword=N_ --keyword=P \
		$(PL_FILES)

manapol.pot: $(POL_IN_FILES)
	itstool -o po/$@ $(ITS_FILES) $(POL_IN_FILES)

manaconf.pot: $(CONF_IN_FILES)
	itstool -o po/$@ $(ITS_FILES) $(CONF_IN_FILES)

manadesktop.pot: $(DESKTOP_IN_FILES)
	xgettext $(DESKTOP_IN_FILES) -o po/manadesktop.pot 
	
update_n_merge: $(PGOAL).pot merge

merge:
	@for n in $(POFILES); do \
		echo "Merging $$n"; \
		msgmerge "$$n" po/$(PGOAL).pot > "$$n"t; \
		mv -f "$$n"t "$$n"; \
	done

MAKE_FRAG

    return $inherited . $newTargets;
}