1 # This is free and unencumbered software released into the public
2 # domain. To the extent possible under law, the author of this file
3 # waives all copyright and related or neighboring rights to it.
5 $(call include-once.
,programs.mk
)
8 ICONUTIL
:= $(call command-v
,iconutil icnsutil
)
11 PNGCRUSHFLAGS ?
= -brute
-blacken
-reduce
-q
12 CRUSH.png ?
= $(PNGCRUSH
) $(PNGCRUSHFLAGS
) -ow
17 # First: xcf2png by default calls zcat rather than gzcat. This is
18 # totally always broken; non-GNU zcat forces a .Z extension on its
19 # input filename. So we can't rely on xcf2png's default behavior.
20 # Luckily it offers -Z for a custom decompression program.
22 # BUT: When Gimp saves a .xcf.gz (and related formats), it doesn't
23 # truncate the file, it just writes until it's done and closes, and
24 # whatever data was after that, is still after that. This is terrible
25 # because it means the file never shrinks, but it's still nominally a
26 # valid gzip file, according to http://www.gzip.org/#faq8.
28 # BUT: The suggestion to use gzip -q in the FAQ doesn't work for
29 # non-GNU gzip. It shuts up the 'warning,' yes, but it still exits
30 # with status code 1 (not even 2, like GNU gzip does for all
31 # warnings). It does write out the data perfectly well, at least.
33 # BUT (of course): The non-zero exit (somewhat reasonably) makes
34 # xcf2png barf and die before writing anything even though it got all
37 # So: 1) use gunzip, 2) manually feed it to xcf2png, 3) hope nothing
38 # is set to die based on pipe status, 4) hope that if the xcf data is
39 # truly busted xcf2png will do something helpful.
41 gunzip
-c
$< |
$(XCF2PNG
) - > $@
43 # https://korewanetadesu.com/make-icons.html
45 %.icns
: %.iconset
$$(wildcard $$(@D
)/$$*.iconset
/icon_
*.png
)
46 $(ICONUTIL
) -c icns
-o
$@
$<
48 %.ico
: %.iconset
$$(wildcard $$(@D
)/$$*.iconset
/icon_
*[0-9].png
)
49 convert
-background transparent
-colors
256 $(filter-out $<,$^
) $@
51 find-iconsets
= $(shell find
$1 -type d
-name
'*.iconset')
52 find-xcfs
= $(shell find
$1 -type f
-name
'*.xcf.gz' -or
-name
'*.xcf')
54 iconset
>icons
= $(1:.iconset
=.icns
) $(1:.iconset
=.ico
)
55 xcf
>png
= $(patsubst %.xcf
,%.png
,$(patsubst %.xcf.gz
,%.xcf
,$1))
57 pngcrush-stampprefix ?
= $(stampprefix
)
58 pngcrush-stampify
= $(1:%.png
=$(pngcrush-stampprefix
)%.png.crushed
)
60 $(pngcrush-stampprefix
)%.png.crushed
: %.png