File: rules

package info (click to toggle)
roundcube-plugins-extra 1.4.10%2B1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,776 kB
  • sloc: php: 4,711; javascript: 2,238; xml: 120; makefile: 94; sh: 79; awk: 51; python: 43
file content (140 lines) | stat: -rwxr-xr-x 5,813 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/make -f

# NOTE: installed with tr/_/-/ in the source tree since _ is not a valid
# character in in source names
PLUGINS = authres_status \
	compose_addressbook \
	contextmenu \
	dovecot_impersonate \
	fail2ban \
	html5_notifier \
	keyboard_shortcuts \
	listcommands \
	message_highlight \
	sauserprefs \
	thunderbird_labels
component_name = $(subst _,-,$(1))
topdir = $(firstword $(subst /, ,$(1)))

# source path of the given destination plugin path (relative to usr/share/roundcube/plugins/)
sourcepath = $(patsubst $(call topdir,$(1))/%,$(call component_name,$(call topdir,$(1)))/%,$(1))

update:
	debian/scripts/plugins.py

%:
	dh $@

GENERATED_JSFILES = thunderbird-labels/tb_label.js
GENERATED_CSSFILES = contextmenu/skins/elastic/contextmenu.css \
	sauserprefs/skins/elastic/sauserprefs.css \
	sauserprefs/skins/elastic/tabstyles.css
SRC_FILES := $(filter-out $(GENERATED_JSFILES) $(GENERATED_CSSFILES),$(shell find -P -- $(call component_name,$(PLUGINS)) -type f))
CONF_DIST_NAMES = config.inc.php.dist config.inc.php-dist
CHANGELOG_NAMES = changelog Changelog CHANGELOG changelog.txt
DOC_NAMES = README readme.md README.md MANUAL.md docs

GENERATED_FILES := $(GENERATED_JSFILES) $(GENERATED_CSSFILES)
JS_MINFILES = $(patsubst %.js,%.min.js,$(filter-out %.min.js,$(filter %.js,$(SRC_FILES) $(GENERATED_FILES))))
CSS_MINFILES = $(patsubst %.css,%.min.css,$(filter-out %.min.css,$(filter %.css,$(SRC_FILES) $(GENERATED_FILES))))
GENERATED_FILES += $(JS_MINFILES) $(CSS_MINFILES)

$(JS_MINFILES): %.min.js: %.js
	uglifyjs --compress --mangle --source-map "base='$(dir $@)',url='$(notdir $@).map'" \
		-o $@ -- $<

$(CSS_MINFILES): %.min.css: %.css
	cd $(dir $@) && cleancss --source-map -o $(notdir $@) -- $(notdir $<)

# Generate thunderbird-labels/tb_label.js from its .coffee sources
thunderbird-labels/tb_label.js: $(wildcard thunderbird-labels/coffeescripts/*.coffee)
	cd thunderbird-labels && ./coffee2js.sh

# Generate CSS from LESS sources
# We run the command in the Roundcube tree where can import
# ../../../../skins/elastic/styles/{variables,mixins}.
$(GENERATED_CSSFILES): %.css: %.less
	cd /usr/share/roundcube/plugins/jqueryui/themes/elastic && \
		lessc --source-map --rewrite-urls $(CURDIR)/$< $(CURDIR)/$@

GENERATED_MAPFILES = $(addsuffix .map,$(filter %.css %.js,$(GENERATED_FILES)))
GENERATED_FILES += $(GENERATED_MAPFILES)
$(GENERATED_MAPFILES): %.map: | % ;

# Pre-compress minified files
COMPRESSED_FILES = $(JS_MINFILES) $(CSS_MINFILES)
COMPRESSED_FILES := $(addsuffix .gz,$(COMPRESSED_FILES))
GENERATED_FILES += $(COMPRESSED_FILES)
$(COMPRESSED_FILES): %.gz: %
	pigz -11 -mnk -- $<

PLUGINS_CONFIGURABLE := $(foreach plugin,$(PLUGINS), $(addprefix $(plugin)/, \
	$(shell find -P -- $(call component_name,$(plugin)) \( -name "config.inc.php" \
		$(foreach confdist,$(CONF_DIST_NAMES),-o -name "$(confdist)") \) -type f -printf "%P\\n")))
PLUGINS_CONF_DIST = $(filter $(addprefix %/,$(CONF_DIST_NAMES)),$(PLUGINS_CONFIGURABLE))

# For each plugin with a config.inc.php[.-]dist, we symlink a config.inc.php in
# /etc/roundcube/plugins with some dummy content.  (If config.inc.php already
# exists,such as for keyboard_shortcuts, then it used instead.)
# NOTE: We assume that the plugin loads its configuration from a
# 'config.inc.php' file under the same directory holding the default
# configuration file (normally config.inc.php.dist but message-highlight calls
# it config.inc.php-dist).  If that file is not directly under the plugin
# directory, such as for html5_notifier, then we assume the plugin loads its
# configuration with $this->load_config('path/to/config.inc.php').
define genconf_target
GENERATED_FILES += $$(addsuffix config.inc.php,$$(dir $(1)))
$$(addsuffix config.inc.php,$$(dir $(1))): $(1)
	$$(file >$$@,<?php)
	$$(file >>$$@,// Empty configuration for $$(call topdir,$(2)))
	$$(file >>$$@,// See /usr/share/roundcube/plugins/$(2) for instructions)
	$$(file >>$$@,?>)
endef
$(foreach confdist,$(PLUGINS_CONF_DIST), $(eval $(call genconf_target, \
	$(call sourcepath,$(confdist)),$(confdist))))

execute_after_dh_auto_clean:
	@rm -f -- $(GENERATED_FILES)

override_dh_auto_build: $(GENERATED_FILES) ;
.SECONDARY:

execute_after_dh_auto_test:
	debian/scripts/check-long-description

execute_after_dh_install:
	# install plugins
	$(foreach plugin,$(PLUGINS), \
		dh_install --exclude=LICENSE --exclude=INSTALL \
			$(foreach x,$(CHANGELOG_NAMES) $(DOC_NAMES),--exclude=$(x)) \
			$(call component_name,$(plugin))/* usr/share/roundcube/plugins/$(plugin) && \
		) true

	# install plugin configuration
	$(foreach conffile,$(addsuffix config.inc.php,$(dir $(PLUGINS_CONFIGURABLE))), \
		dh_install $(call sourcepath,$(conffile)) etc/roundcube/plugins/$(call topdir,$(conffile)) && \
		) true

plugin_docs = $(wildcard $(addprefix $(call component_name,$(1))/,$(CHANGELOG_NAMES) $(DOC_NAMES)))
execute_after_dh_installdocs:
	$(foreach plugin,$(PLUGINS), \
		$(if $(call plugin_docs,$(plugin)), \
			dh_install $(call plugin_docs,$(plugin)) usr/share/doc/roundcube-plugins-extra/$(plugin),) && \
		) true

execute_after_dh_link:
	# symlink plugin configuration (and delete existing usr/share/roundcube/plugins/*/config.inc.php
	# file which we installed as etc/roundcube/plugins/*/config.inc.php instead)
	$(foreach conffile,$(addsuffix config.inc.php,$(dir $(PLUGINS_CONFIGURABLE))), \
		dh_link etc/roundcube/plugins/$(call topdir,$(conffile))/config.inc.php \
			usr/share/roundcube/plugins/$(conffile) && \
		) true

	# symlink plugin directories to var/lib/roundcube/plugins
	$(foreach plugin,$(PLUGINS), \
		dh_link usr/share/roundcube/plugins/$(plugin) var/lib/roundcube/plugins/$(plugin) && \
		) true

execute_after_dh_fixperms:
	find debian/roundcube-plugins-extra/usr/share/roundcube/plugins \
		\! -name "*.sh" -type f -execdir chmod -x -- {} +