Improve 2013/endoh2/Makefile rule check

The fact it uses ruby is clear but the ruby script uses (via IO.popen())
the convert tool from the ImageMagick suite. When I first looked at it
and had the error it was not very clear to me what was going on. It was
not until another day when I looked at it again that I recalled that
convert is a tool that comes from ImageMagick which had previously been
on my MacBook Pro but hasn't been (until now) since macOS Sonoma was
installed.

Now the Makefile rule checks that both ruby and ImageMagick (via
checking for 'convert') are installed. If either aren't it will report
where they can be found and then after doing that if either are not
installed it exits 1. Otherwise if both are found it will run the
script.
This commit is contained in:
Cody Boone Ferguson committed 2023-10-13 02:42:03 -07:00
1 parent 4cc0d9bcb3
commit 8d8eb98ef6
3 files changed
+51 -1

No files matched your search

+23
View File
@@ -146,6 +146,29 @@ jpeg.jpg: jpeg
check: ${DATA}
${RM} -f jpeg2.c
@if ! type -P convert >/dev/null 2>&1; then \
echo "The 'convert' tool from ImageMagick could not be found." 1>&2; \
echo ""; 1>&2; \
echo "See the following website for ImageMagick:" 1>&2; \
echo ""; 1>&2; \
echo " https://imagemagick.org/script/download.php"; 1>&2; \
echo ""; 1>&2; \
echo "or use your OS package manager to install it." 1>&2; \
fi
@if ! type -P ${RUBY} >/dev/null 2>&1; then \
echo "${RUBY} language could not be found." 1>&2; \
echo "${RUBY} must be installed in order to run the $@ rule." 1>&2; \
echo ""; 1>&2; \
echo "See the following website for ${RUBY}:" 1>&2; \
echo ""; 1>&2; \
echo " https://www.ruby-lang.org/"; 1>&2; \
echo ""; 1>&2; \
echo "or use your OS package manager to install it." 1>&2; \
ERROR=1; \
fi
@if type -P ${RUBY} >/dev/null 2>&1 || ! type -P convert >/dev/null 2>&1; then \
exit 1; \
fi
${RUBY} ocr.rb jpeg.jpg > jpeg2.c
${DIFF} jpeg.c jpeg2.c && echo Check succeeded
+8 -1
View File
@@ -17,7 +17,14 @@ make
make check
```
You'll need to have Ruby installed to run all the automated checks.
You'll need to have both [Ruby](https://www.ruby-lang.org) and
[ImageMagick](https://imagemagick.org/) installed to run all the automated
checks.
If you do not have both, however, you can still do the below in the [try](#try)
section to enjoy the entry. The [Makefile](Makefile) `check` rule will check if
you have both and if either is not found it will report it and tell you where to
download one or both before exiting.
## Try: