aboutsummaryrefslogtreecommitdiffstats
path: root/make-stage-2.mk
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-07-02 00:37:38 +0200
committerMattias Andrée <maandree@kth.se>2023-07-02 00:38:53 +0200
commit94683b40016c6011809ce9b88eb35f180aada647 (patch)
tree2d9b1b8fde7faed515ec335e8b2306b9bd20eb25 /make-stage-2.mk
parentImprove makfile (diff)
downloadsimple-icon-theme-94683b40016c6011809ce9b88eb35f180aada647.tar.gz
simple-icon-theme-94683b40016c6011809ce9b88eb35f180aada647.tar.bz2
simple-icon-theme-94683b40016c6011809ce9b88eb35f180aada647.tar.xz
Fix icon listing and make Makefile portable
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'make-stage-2.mk')
-rw-r--r--make-stage-2.mk132
1 files changed, 23 insertions, 109 deletions
diff --git a/make-stage-2.mk b/make-stage-2.mk
index 5482c26..4891da1 100644
--- a/make-stage-2.mk
+++ b/make-stage-2.mk
@@ -1,4 +1,4 @@
-## Not compatible with POSIX make, tested with GNU make
+.POSIX:
CONFIGFILE = config.mk
include $(CONFIGFILE)
@@ -16,114 +16,28 @@ DIRS =\
include icons.mk
-ALL_PNG_ICONS = $(foreach S,$(SIZES),$(foreach I,$(ICONS),$(S)x$(S)$(DIR_SUFFIX)/$(I).png))
-
-all: index.theme $(ALL_PNG_ICONS)
-
-all-fast: index.theme all-fast-icons
-
-index.theme: Makefile
- set -e;\
- printf '%s\n' \
- '[Icon Theme]'\
- 'Name=$(THEME_NAME)'\
- 'Comment=$(THEME_DESC)'\
- 'Example=folder'\
- ''\
- '# KDE specific stuff'\
- 'DisplayDepth=32'\
- 'LinkOverlay=link_overlay'\
- 'LockOverlay=lock_overlay'\
- 'ZipOverlay=zip_overlay'\
- 'DesktopDefault=48'\
- 'DesktopSizes='$$(printf ',%s' $(SIZES) | sed 's/^,//')\
- 'ToolbarDefault=22'\
- 'ToolbarSizes=8,16,22,32,48'\
- 'MainToolbarDefault=22'\
- 'MainToolbarSizes=8,16,22,32,48'\
- 'SmallDefault=16'\
- 'SmallSizes=16'\
- 'PanelDefault=32'\
- 'PanelSizes='$$(printf ',%s' $(SIZES) | sed 's/^,//')\
- ''\
- > index.theme
- printf 'Directories=' >> index.theme
- set -e;\
- for s in $(SIZES); do\
- for d in $(DIRS); do\
- printf ',%sx%s/%s' $$s $$s $$d;\
- done;\
- done | sed 's/^,//' >> index.theme
- set -e;\
- for d in $(DIRS); do\
- printf ',scalable/%s' $$d;\
- done >> index.theme
- printf '\n' >> index.theme
- set -e;\
- for s in $(SIZES) scalable; do\
- for d in $(DIRS); do\
- printf '\n';\
- ./make-dir-info $$s $$d;\
- done;\
- done >> index.theme
-
-all-fast-icons: $(ICONS:=.x)
-
-scalable-$(DIR_SUFFIX_)/%.svg: scalable/%.svg
- @mkdir -p -- "$$(dirname "$@")"
- if ! test "$@" = "scalable/$*.svg"; then\
- if test -L "scalable/$*.svg"; then\
- ln -sf "$$(readlink -- "scalable/$*.svg")" $@;\
- else\
- sed < scalable/$*.svg > $@\
- -e 's/#[bB][eE][bB][eE][bB][eE]/#$(BASE_COLOUR)/g'\
- -e 's/#[eE][fF]2929/#$(ALARM_RED)/g'\
- -e 's/#[fF]57900/#$(ALARM_ORANGE)/g'\
- -e 's/#[cC][dD]656[cC]/#$(RED)/g'\
- -e 's/#[dD]69553/#$(ORANGE)/g'\
- -e 's/#[cC][cC][aA][dD]47/#$(YELLOW)/g'\
- -e 's/#32[aA]679/#$(GREEN)/g'\
- -e 's/#00[aA]09[fF]/#$(CYAN)/g'\
- -e 's/#2495[bB][eE]/#$(BLUE)/g'\
- -e 's/#[aA]46[eE][bB]0/#$(MAGENTA)/g'\
- -e 's/#000000/#$(OUTLINE)/g';\
- fi;\
+all:
+
+include generated.mk
+include portable.mk
+include unportable.mk
+
+# For implementation that do not support pattern matching rules
+.DEFAULT:
+ +@set -e;\
+ if printf '%s\n' "$@" | grep '^scalable' > /dev/null; then\
+ sed < unportable.mk '1s|%|'"$$(printf '%s\n' "$@" | sed 's|^scalable/\(.*\)\.svg$$|\1|')"'|g' | $(MAKE) -f - "$@";\
+ elif printf '%s\n' "$@" | grep '\.png$$' > /dev/null; then\
+ printf '%s\n' "$@" >&2 ;\
+ $(MAKE) -f make-stage-2.mk conv &&\
+ f="$$(printf '%s\n' "$@" | sed 's|^[^/]*\/\(.*\)\.png$$|\1|')" &&\
+ if test -n "$(DIR_SUFFIX)"; then \
+ $(MAKE) -f make-stage-2.mk scalable$(DIR_SUFFIX)/$$f.svg; \
+ fi && \
+ sed '/^[a-zA-Z0-9].*=/,$$d' < generated.mk | sed 's|%|'"$$f"'|g' | $(MAKE) -f - "$@";\
+ else\
+ printf 'No rule to make target %s\n' "$@" >&2;\
+ exit 2;\
fi
-%.x: conv
- @if test -n "$(DIR_SUFFIX)"; then $(MAKE) scalable$(DIR_SUFFIX)/$*.svg; fi
- @ # Does work as a dependeny in GNU make for some reason,
- @ # additionally, this lets us avoid starting make once
- @ # extra for every icon
- ./conv scalable$(DIR_SUFFIX)/$*.svg $(SIZES)
-
-conv: conv.c
- $(CC) -o $@ $< $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
-
-include generated-rules.mk
-
-install: index.theme $(ALL_PNG_ICONS)
- mkdir -p -- "$(DESTDIR)$(ICONPREFIX)"
- set -e;\
- for d in $(DIRS); do\
- for s in $(SIZES); do\
- mkdir -p -- "$(DESTDIR)$(ICONPREFIX)/$(THEME_DIR)/$${s}x$${s}/$${d}";\
- done;\
- mkdir -p -- "$(DESTDIR)$(ICONPREFIX)/$(THEME_DIR)/scalable/$${d}";\
- done
- set -e;\
- for i in $(ICONS); do\
- for s in $(SIZES); do\
- cp -P -- "$${s}x$${s}$(DIR_SUFFIX)/$${i}.png" "$(DESTDIR)$(ICONPREFIX)/$(THEME_DIR)/$${s}x$${s}/$${i}.png";\
- done;\
- cp -P -- "scalable$(DIR_SUFFIX)/$${i}.svg" "$(DESTDIR)$(ICONPREFIX)/$(THEME_DIR)/scalable/$${i}.svg";\
- done
- cp -- index.theme "$(DESTDIR)$(ICONPREFIX)/$(THEME_DIR)/index.theme"
-
-uninstall:
- rm -rf -- "$(DESTDIR)$(ICONPREFIX)/$(THEME_DIR)"
-
-clean:
- +@$(MAKE) -f Makefile clean
-
.PHONY: all all-fast all-fast-icons install uninstall clean