From: Nick Bowler Date: Wed, 9 Mar 2022 02:03:48 +0000 (-0500) Subject: Generate and distribute some icon files. X-Git-Url: http://git.draconx.ca/gitweb/rrace.git/commitdiff_plain/8d65a2da164b109c520d21afd051e4347e194182 Generate and distribute some icon files. Since we now have code that generates nifty icons in various sizes, we can fairly easily make use of it to generate and install icon files. These files need to be distributed because the application cannot be run in the cross-compilation case, which will also avoid the distribution depending on external image conversion utilities. --- diff --git a/Makefile.am b/Makefile.am index acd8c2b..0566953 100644 --- a/Makefile.am +++ b/Makefile.am @@ -81,5 +81,69 @@ $(t_ewmhicon_OBJECTS): $(gnulib_headers) t_rng_test_LDADD = libgnu.a $(t_rng_test_OBJECTS): $(gnulib_headers) +GENPNG_V = $(GENPNG_V_@AM_V@) +GENPNG_V_ = $(GENPNG_V_@AM_DEFAULT_V@) +GENPNG_V_0 = @printf ' %$(DX_ALIGN_V)s %s\n' 'GEN ' $*.png; + +$(GENICONS:.png=.gen): + $(GENPNG_V) $(MKDIR_P) $(@D) + $(AM_V_at) s=`expr $(@F) : '[^0-9]*\([^.]*\)'`; \ + t/ewmhicon$(EXEEXT) -c yrwyogbbg "$$s" >$*.xpm +if USE_NETPBM + $(AM_V_at) $(XPMTOPPM) $*.xpm | $(PNMTOPNG) >$*-t.png +else +if USE_CONVERT + $(AM_V_at) $(CONVERT) $*.xpm $*-t.png +endif +endif + $(AM_V_at) $(OPTIPNG) -o7 -quiet $*-t.png + $(AM_V_at) mv -f $*-t.png $*.png +MOSTLYCLEANFILES += $(GENICONS:.png=-t.png) +DISTCLEANFILES += $(GENICONS:.png=.xpm) +MAINTAINERCLEANFILES += $(GENICONS) +SUFFIXES = .gen + +GENICONS = data/rr48x48.png data/rr32x32.png data/rr24x24.png data/rr16x16.png +$(GENICONS): ; + +build-icons: t/ewmhicon$(EXEEXT) $(GENICONS) + $(AM_V_at) set x $(GENICONS:.png=); shift; for f; do shift; \ + test -f "$$f.png" || test -f "$(srcdir)/$$f.png" || \ + { set x "$$@" "$$f.gen"; shift; }; \ + done; $(MAKE) $(AM_MAKEFLAGS) "$$@" +.PHONY: build-icons + +dist-hook: dist-icons +dist-icons: build-icons + $(MKDIR_P) $(distdir)/data + for f in $(GENICONS); do \ + if test -f "$$f"; \ + then cp "$$f" "$(distdir)/data" || exit; \ + else cp "$(srcdir)/$$f" "$(distdir)/data" || exit; \ + fi; done +.PHONY: dist-icons + +iconsdir = $(datarootdir)/icons/hicolor + +install-data-local: install-icons +install-icons: build-icons + for f in $(GENICONS); do \ + s=`expr "$$f" : '[^0-9]*\([^.]*\)'`; \ + od="$(DESTDIR)$(iconsdir)/$$s/apps"; \ + $(MKDIR_P) "$$od"; if test -f "$$f"; \ + then $(INSTALL_DATA) "$$f" "$$od/$(PACKAGE_TARNAME).png"; \ + else $(INSTALL_DATA) "$(srcdir)/$$f" "$$od/$(PACKAGE_TARNAME).png";\ + fi; done +.PHONY: install-icons + +uninstall-local: uninstall-icons +uninstall-icons: + for f in $(GENICONS); do \ + s=`expr "$$f" : '[^0-9]*\([^.]*\)'`; \ + od="$(DESTDIR)$(iconsdir)/$$s/apps"; \ + rm -f "$$od/$(PACKAGE_TARNAME).png"; \ + done +.PHONY: uninstall-icons + include $(top_srcdir)/lib/gnulib.mk include $(top_srcdir)/common/snippet/autotest.mk diff --git a/configure.ac b/configure.ac index 946fb53..3ef5c67 100644 --- a/configure.ac +++ b/configure.ac @@ -49,5 +49,55 @@ AC_CONFIG_TESTDIR([.], [t:.]) DX_PROG_AUTOTEST AM_CONDITIONAL([HAVE_AUTOTEST], [test x"$dx_cv_autotest_works" = x"yes"]) +AC_CHECK_PROGS([XPMTOPPM], [xpmtoppm]) +AC_CHECK_PROGS([PNMTOPNG], [pnmtopng]) +AC_CHECK_PROGS([CONVERT], [convert]) +AC_CHECK_PROGS([GM], [gm]) +AC_CACHE_CHECK([how to convert XPM to PNG], [dx_cv_xpm_to_png], +[cat >conftest.xpm <<'EOF' +/* XPM */ +static char *x[] = { +"1 1 1 1", +"x c #123456", +"x" +}; +EOF +check_conftest_png () { + od conftest.png | $AWK 'BEGIN { success=0; } +NR == 1 && $2 == "050211" && $3 == "043516" { success=1; } +NR == 1 && $2 == "104520" && $3 == "047107" { success=1; } +END { exit(!success); }' +} +rm -f conftest.png +for dx_cv_xpm_to_png in netpbm 'gm convert' convert unknown; do +AS_CASE([$dx_cv_xpm_to_png], + +[netpbm], +[AS_IF([$XPMTOPPM conftest.xpm >conftest.ppm 2>&AS_MESSAGE_LOG_FD], + [], [continue]) +AS_IF([$PNMTOPNG conftest.ppm >conftest.png 2>&AS_MESSAGE_LOG_FD], + [], [continue]) +AS_IF([check_conftest_png], [break])], + +[*convert], +[AS_CASE([$dx_cv_xpm_to_png], + [gm*], [test_convert="$GM convert"], + [test_convert="$CONVERT"]) +AS_IF([$test_convert conftest.xpm conftest.png >&AS_MESSAGE_LOG_FD 2>&1], + [], [continue]) +AS_IF([check_conftest_png], [break])]) +done +rm -f conftest.xpm conftest.ppm conftest.png]) + +AM_CONDITIONAL([USE_NETPBM], [test x"$dx_cv_xpm_to_png" = x"netpbm"]) +AM_CONDITIONAL([USE_CONVERT], + [AS_CASE([$dx_cv_xpm_to_png], [*convert], [], [false])]) + +AS_IF([test x"$dx_cv_xpm_to_png" = x"gm convert"], + [CONVERT="$GM convert"]) + +AC_CHECK_PROGS([OPTIPNG], [optipng]) +: "${OPTIPNG:=:}" + AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/data/.gitignore b/data/.gitignore new file mode 100644 index 0000000..5440e71 --- /dev/null +++ b/data/.gitignore @@ -0,0 +1 @@ +/rr??x??.[xp][pn][mg]