File: Makefile

package info (click to toggle)
gnome-colors 5.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, jessie, jessie-kfreebsd, sid, stretch
  • size: 17,660 kB
  • ctags: 55
  • sloc: makefile: 253; sh: 13
file content (338 lines) | stat: -rw-r--r-- 12,174 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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
PROJECT := gnome-colors-src
DOCS := AUTHORS ChangeLog COPYING README
SIZES := 16x16 22x22 24x24 32x32
THEME_FILES := $(filter-out %~,$(wildcard themes/*))
LINKS_FILE := links
DIST_EXTRA := Makefile Palette.svg

gnome-colors_DIST_COMMON := yes
$(PROJECT)_DIST_COMMON := yes

BRANDING := \
	places/gnome-main-menu \
	places/gnome-starthere \
	places/mandrake \
	places/mandriva \
	places/novell-button \
	places/start-here

############################### Global variables ###############################

VERSION := $(shell head -n 1 ChangeLog | cut -d ' ' -f 1)

ifeq ($(THEME_FILES),)
ALL_THEMES := $(filter-out src,$(shell find * -maxdepth 1 ! -wholename '*/.*' -type f -name index.theme -printf "%h "))
THEMES := $(filter-out gnome-colors-common,$(ALL_THEMES))
THEME_BUILD_FILES = $(shell find $(1) ! -wholename '*/.*' -type f)
THEME_BUILD_LINKS = $(shell find $(1) ! -wholename '*/.*' -type l)
else
THEMES := $(notdir $(THEME_FILES))
ALL_THEMES := $(THEMES) gnome-colors-common
config = $(shell grep "^$(2)=" themes/$(1) | sed "s/^$(2)=//")
FIXED := $(shell find src/*x* ! -wholename '*/.*' -type f -name '*.svg')
SCALABLE := $(shell find src/scalable ! -wholename '*/.*' -type f -name '*.svg')
ICON_FILES := $(shell find src ! -wholename '*/.*' -type f -name '*.icon')
ONESIZE_FILES := $(patsubst src/scalable/%,%,$(SCALABLE))
LINK_LIST := $(shell sed "s/ /-->/" $(LINKS_FILE))
LINK_FILES := $(foreach link,$(LINK_LIST),$(lastword $(subst -->, ,$(link))))
THEME_BUILD_FILES = $(1)/index.theme \
	$(patsubst src/%,$(1)/%,$(SCALABLE)) \
	$(addprefix $(1)/,$(FIXED:src/%.svg=%.png)) \
	$(addprefix $(1)/24x24/,$(ONESIZE_FILES:%.svg=%.png)) \
	$(patsubst src/%,$(1)/%,$(ICON_FILES))
THEME_BUILD_LINKS = $(addprefix $(1)/scalable/,$(LINK_FILES:%.png=%.svg)) \
	$(foreach size,$(SIZES),$(addprefix $(1)/$(size)/,$(LINK_FILES)))
endif

THEME_BUILD = $(THEME_BUILD_FILES) $(THEME_BUILD_LINKS)
BUILD_FILES := $(foreach theme,$(THEMES),$(call THEME_BUILD_FILES,$(theme)))
BUILD_LINKS := $(foreach theme,$(THEMES),$(call THEME_BUILD_LINKS,$(theme)))
BUILD := $(BUILD_FILES) $(BUILD_LINKS)
COMMON_FILES := $(shell find gnome-colors-common ! -wholename '*/.*' -type f 2> /dev/null)
COMMON_LINKS := $(shell find gnome-colors-common ! -wholename '*/.*' -type l 2> /dev/null)
COMMON := $(COMMON_FILES) $(COMMON_LINKS)

################################### Building ###################################

# all should be the first target
all:

help::
	@echo "make targets:"

ifneq ($(THEME_FILES),)

COLORS = $(call config,$(1),Alternatives)

all: $(BUILD)

define color_template
$(1)_$(2)1 := $$(call config,$(1),$(2)_LightFolderBase)
$(1)_$(2)2 := $$(call config,$(1),$(2)_LightBase)
$(1)_$(2)3 := $$(call config,$(1),$(2)_MediumBase)
$(1)_$(2)4 := $$(call config,$(1),$(2)_DarkStroke)
$(1)_$(2)_sed := s/\#8fb3d9/$$($(1)_$(2)1)/g;s/\#729fcf/$$($(1)_$(2)2)/g;s/\#3465a4/$$($(1)_$(2)3)/g;s/\#204a87/$$($(1)_$(2)4)/g
$(1)_$(2)_FIXED := $(patsubst %.svg,%.png,$(foreach size,$(filter-out 24x24,$(SIZES)),$(addprefix $(size)/,$(call config,$(1),$(2)_Files))))
$(1)_$(2)_SCALABLE := $(patsubst %.png,%.svg,$(addprefix scalable/,$(call config,$(1),$(2)_Files)))
$(1)_$(2)_FILES := $$($(1)_$(2)_FIXED) $$($(1)_$(2)_SCALABLE)
$(1)_ALTERNATIVES += $$($(1)_$(2)_FILES)
endef

$(foreach theme,$(THEMES),$(foreach color,$(call COLORS,$(theme)),$(eval $(call color_template,$(theme),$(color)))))

define theme_template
$(1)_default1 := $$(call config,$(1),LightFolderBase)
$(1)_default2 := $$(call config,$(1),LightBase)
$(1)_default3 := $$(call config,$(1),MediumBase)
$(1)_default4 := $$(call config,$(1),DarkStroke)
$(1)_default_sed := s/\#8fb3d9/$$($(1)_default1)/g;s/\#729fcf/$$($(1)_default2)/g;s/\#3465a4/$$($(1)_default3)/g;s/\#204a87/$$($(1)_default4)/g

$(1): $(call THEME_BUILD,$(1))

$(1)/index.theme: src/index.theme themes/$(1)
	@if test ! -d $(1); then mkdir -p $(1); echo "mkdir -p $(1)"; fi
	sed "s/@NAME@/$(call config,$(1),Name)/" $$< > $$@
endef

$(foreach theme,$(THEMES),$(eval $(call theme_template,$(theme))))

define png_template
$(1)/$(2).png: src/$(2).svg themes/$(1)
	@if test ! -d $$(dir $$@); then mkdir -p $$(dir $$@); echo "mkdir -p $$(dir $$@)"; fi
	sed "$$($(1)_$(3)_sed)" $$< | inkscape --without-gui -f /dev/stdin -e "$$(CURDIR)/$$@"
endef

define svg_template
$(1)/$(2): src/$(2) themes/$(1)
	@if test ! -d $$(dir $$@); then mkdir -p $$(dir $$@); echo "mkdir -p $$(dir $$@)"; fi
	sed "$$($(1)_$(3)_sed)" $$< > $$@
endef

$(foreach theme,$(THEMES),$(foreach color,$(call COLORS,$(theme)), \
	$(foreach file,$(patsubst %.png,%,$($(theme)_$(color)_FIXED)),$(eval $(call png_template,$(theme),$(file),$(color)))) \
	$(foreach file,$($(theme)_$(color)_SCALABLE),$(eval $(call svg_template,$(theme),$(file),$(color)))) \
))

define 24_template
$(1)/24x24/$(2): $(1)/22x22/$(2)
	@if test ! -d $$(dir $$@); then mkdir -p $$(dir $$@); echo "mkdir -p $$(dir $$@)"; fi
	convert -bordercolor Transparent -border 1x1 $$< $$@
endef

define link_template
$(1)/$(3):
	@if test ! -d $$(dir $$@); then mkdir -p $$(dir $$@); echo "mkdir -p $$(dir $$@)"; fi
	ln -sf $(2) $$@
endef

define icon_template
$(2): $(1)
	@if test ! -d $$(dir $$@); then mkdir -p $$(dir $$@); echo "mkdir -p $$(dir $$@)"; fi
	cp $$< $$@
endef

first = $(firstword $(subst -->, ,$(1)))
last = $(lastword $(subst -->, ,$(1)))

$(foreach theme,$(THEMES), \
	$(foreach file,$(filter-out $(patsubst %.png,%,$($(theme)_ALTERNATIVES)),$(patsubst src/%.svg,%,$(FIXED))),$(eval $(call png_template,$(theme),$(file),default))) \
	$(foreach file,$(filter-out $($(theme)_ALTERNATIVES),$(patsubst src/%,%,$(SCALABLE))),$(eval $(call svg_template,$(theme),$(file),default))) \
	$(foreach file,$(ONESIZE_FILES:%.svg=%.png),$(eval $(call 24_template,$(theme),$(file)))) \
	$(foreach link,$(LINK_LIST),$(foreach size,$(SIZES),$(eval $(call link_template \
		,$(theme)/$(size),$(call first,$(link)),$(call last,$(link)))))) \
	$(foreach link,$(LINK_LIST),$(eval $(call link_template \
		,$(theme)/scalable,$(patsubst %.png,%.svg,$(call first,$(link))),$(patsubst %.png,%.svg,$(call last,$(link)))))) \
	$(foreach icon,$(ICON_FILES),$(eval $(call icon_template,$(icon),$(patsubst src/%,$(theme)/%,$(icon))))) \
)

help::
	@echo "    all                      Build all files for all themes (default target)."
	@echo "    THEME                    Build all files for THEME."

else

help::
	@echo "    all                      Does nothing (default target)."

endif

#################################### Cleanup ###################################

clean:
	rm -f *.tar *.tar.bz2 *.tar.gz
ifneq ($(THEME_FILES),)
	rm -rf $(THEMES)
endif

help::
	@echo "    clean                    Deletes all files created by this makefile."

.PHONY: clean

################################# Miscellaneous ################################

BROKEN_LINKS = $(shell find * ! -wholename '*/.*' -type l ! -exec test -r {} \; -printf "%p ")

check:
	@for link in $(BROKEN_LINKS); do echo "Found broken link $$link"; done
	@test -z "$(BROKEN_LINKS)"

fixperms:
	find * ! -wholename '*/.*' -a -type f -a ! -perm 644 -exec chmod 644 {} \; -printf "chmod 644 %p\n"

themes:
	@echo "Available themes:"
	@for theme in $(sort $(ALL_THEMES)); do echo $$theme; done

help::
	@echo "    check                    Performs self tests."
	@echo "    fixperms                 Fixes permissions of icon files."
	@echo "    help                     Displays this help."
	@echo "    themes                   Lists all available themes."

.PHONY: check fixperms help themes

################################# Distribution #################################

ifneq ($(THEME_FILES),)

DISTRIBUTIONS := $(PROJECT) \
	$(sort $(foreach theme,$(THEMES),$(call config,$(theme),Distribution)))
$(PROJECT)_DIST := \
	$(shell find src ! -wholename '*/.*' -type f) \
	$(THEME_FILES) \
	$(LINKS_FILE)

COMMON_LINKS1 := $(filter gnome-colors-common/16x16% gnome-colors-common/22x22%,$(COMMON_LINKS))
COMMON_LINKS2 := $(filter-out $(COMMON_LINKS1),$(COMMON_LINKS))

define dist_template
# The tar command must be split, otherwise you get this error:
# make: execvp: /bin/sh: Argument list too long
$(1)-$(VERSION).tar: $$(DOCS) $$(DIST_EXTRA) $$($(1)_DIST)
	$$(MAKE) fixperms
	tar -cf $$@ $$(filter-out $$(COMMON),$$^)
ifeq ($($(1)_DIST_COMMON),yes)
	tar -rf $$@ $$(COMMON_FILES)
	tar -rf $$@ $$(COMMON_LINKS1)
	tar -rf $$@ $$(COMMON_LINKS2)

$(1)-$(VERSION).tar: $$(COMMON)
endif

$(1)-$(VERSION).tar.bz2: $(1)-$(VERSION).tar
	bzip2 -cz9 $$< > $$@

$(1)-$(VERSION).tar.gz: $(1)-$(VERSION).tar
	gzip -cn9 $$< > $$@
endef

define dist_theme_template
$(call config,$(1),Distribution)-$(VERSION).tar: $(call THEME_BUILD,$(1))
endef

$(foreach dist,$(DISTRIBUTIONS),$(eval $(call dist_template,$(dist))))
$(foreach theme,$(THEMES),$(eval $(call dist_theme_template,$(theme))))

dist: gz

dist-src: $(PROJECT)-$(VERSION).tar.gz

bz2: $(addsuffix -$(VERSION).tar.bz2,$(DISTRIBUTIONS))

gz: $(addsuffix -$(VERSION).tar.gz,$(DISTRIBUTIONS))

help::
	@echo "    dist                     Creates distribution tar files."
	@echo "    dist-src                 Creates a source distribution tar file."
	@echo "    bz2                      Create distribution .tar.bz2 files."
	@echo "    gz                       Create distribution .tar.gz files."

endif

################################# Installation #################################

USER := ~/.icons
SYSTEM := $(DESTDIR)/usr/share/icons
BRANDING_FILES := $(patsubst %,gnome-colors-common/scalable/%.svg,$(BRANDING)) \
	$(foreach size,$(SIZES),$(patsubst %,gnome-colors-common/$(size)/%.png,$(BRANDING)))
UNBRANDED_COMMON := $(filter-out $(BRANDING_FILES),$(COMMON))

define install_template
$(SYSTEM)/$(1): $(1)
	install -D -m 644 $$< $$@

$(USER)/$(1): $(1)
	install -D -m 644 $$< $$@
endef

define install_links_template
$(SYSTEM)/$(1): $(1)
	cp -d $$< $$@

$(USER)/$(1): $(1)
	cp -d $$< $$@
endef

$(foreach file,$(BUILD_FILES) $(COMMON_FILES),$(eval $(call install_template,$(file))))
$(foreach file,$(BUILD_LINKS) $(COMMON_LINKS),$(eval $(call install_links_template,$(file))))

define theme_install_template
install-$(1): $$(addprefix $$(SYSTEM)/,$(call THEME_BUILD,$(1)))

user-install-$(1): $$(addprefix $$(USER)/,$(call THEME_BUILD,$(1)))

ifneq ($(COMMON),)
install-$(1): install-unbranded-gnome-colors-common
user-install-$(1): user-install-unbranded-gnome-colors-common
endif
endef

define theme_uninstall_template
uninstall-$(1):
	rm -rf $$(SYSTEM)/$(1)

user-uninstall-$(1):
	rm -rf $$(USER)/$(1)

.PHONY: uninstall-$(1) user-uninstall-$(1)
endef

$(foreach theme,$(THEMES),$(eval $(call theme_install_template,$(theme))))
$(foreach theme,$(ALL_THEMES),$(eval $(call theme_uninstall_template,$(theme))))

install-gnome-colors-common: $(addprefix $(SYSTEM)/,$(COMMON))

user-install-gnome-colors-common: $(addprefix $(USER)/,$(COMMON))

install-unbranded-gnome-colors-common: $(addprefix $(SYSTEM)/,$(UNBRANDED_COMMON))

user-install-unbranded-gnome-colors-common: $(addprefix $(USER)/,$(UNBRANDED_COMMON))

install: $(addprefix install-,$(ALL_THEMES))

user-install: $(addprefix user-install-,$(ALL_THEMES))

install-unbranded: $(addprefix install-,$(THEMES)) install-unbranded-gnome-colors-common

user-install-unbranded: $(addprefix user-install-,$(THEMES)) user-install-unbranded-gnome-colors-common

uninstall:
	rm -rf $(addprefix $(SYSTEM)/,$(ALL_THEMES))

user-uninstall:
	rm -rf $(addprefix $(USER)/,$(ALL_THEMES))

help::
	@echo "    install                  Installs all themes system-wide."
	@echo "    install-unbranded        Installs all themes unbranded system-wide."
	@echo "    uninstall                Removes all themes from the system."
	@echo "    user-install             Installs all themes into the user directory."
	@echo "    user-install-unbranded   Installs all themes unbranded for the user."
	@echo "    user-uninstall           Removes all themes from the user directory."
	@echo "    install-THEME            Installs THEME system-wide."
	@echo "    uninstall-THEME          Removes THEME from the system."
	@echo "    user-install-THEME       Installs THEME into the user directory."
	@echo "    user-uninstall-THEME     Removes THEME from the user directory."

.PHONY:  uninstall user-uninstall