From decb51529889b8f2afd67811d635379f030a1b19 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Fri, 13 Feb 2026 06:29:03 +0100 Subject: Replace thumbnail Makefile with configure script The thumbnail subproject has dependencies against dynstr and ImageMagick6, which might or might not be available on the system, or might have been installed to non-standard paths. Therefore, it is more robust to rely on a configure script that checks whether the packages are available and how to deal with CFLAGS/LDFLAGS. --- thumbnail/configure | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100755 thumbnail/configure (limited to 'thumbnail/configure') diff --git a/thumbnail/configure b/thumbnail/configure new file mode 100755 index 0000000..3ca488b --- /dev/null +++ b/thumbnail/configure @@ -0,0 +1,144 @@ +#! /bin/sh + +set -e + +default_prefix=/usr/local +prefix=$default_prefix +default_CC='c99' +# FILE_OFFSET_BITS=64 is required for large file support on 32-bit platforms. +default_CFLAGS='-O1 -D_FILE_OFFSET_BITS=64 -MD' + +CC=${CC:-$default_CC} + +help() +{ + cat <<-EOF +$0 [OPTION ...] + +--prefix Set installation directory [$default_prefix] + +Some influential environment variables: + CC C compiler [$default_CC] + CFLAGS C compiler flags [$default_CFLAGS] + LDFLAGS Link-time flags [$default_LDFLAGS] +EOF +} + +while true; do + split_arg=0 + + if printf "%s" "$1" | grep -e '=' > /dev/null + then + key="$(printf "%s" "$1" | cut -d '=' -f1)" + value="$(printf "%s" "$1" | cut -d '=' -f2)" + split_arg=1 + else + key="$1" + value="$2" + fi + + case "$key" in + --prefix ) prefix="$value"; shift; test $split_arg -eq 0 && shift ;; + -h | --help ) help; exit 0 ;; + * ) test "$1" != "" && help && exit 1 || break ;; + esac +done + +if pkg-config ImageMagick-im6 +then + CFLAGS="$(pkg-config --cflags ImageMagick-im6) $CFLAGS" + LDFLAGS="$(pkg-config --libs ImageMagick-im6) $LDFLAGS" +else + echo "Error: ImageMagick-im6 not found." >&2 + exit 1 +fi + +if pkg-config dynstr +then + in_tree_dynstr=0 + CFLAGS="$(pkg-config --cflags dynstr) $CFLAGS" + LDFLAGS="$(pkg-config --libs dynstr) $LDFLAGS" +else + echo "Info: dynstr not found. Using in-tree copy" >&2 + in_tree_dynstr=1 + CFLAGS="-I../libweb/dynstr/include $CFLAGS" + LDFLAGS="-L../libweb/dynstr -ldynstr $LDFLAGS" +fi + +CFLAGS="$default_CFLAGS $CFLAGS" +LDFLAGS="$default_LDFLAGS $LDFLAGS" + +cleanup() +{ + rm -f $F +} + +F=/tmp/Makefile.thumbnail +trap cleanup EXIT + +cat < $F +.POSIX: + +CC = $CC +PREFIX = $prefix +DST = $prefix/bin +CFLAGS = $CFLAGS +LDFLAGS = $LDFLAGS +EOF + +cat <<"EOF" >> $F +.POSIX: + +PROJECT = thumbnail +DEPS = $(OBJECTS:.o=.d) +OBJECTS = \ + crealpath.o \ + main.o \ + cftw.o + +all: $(PROJECT) + +FORCE: + +install: all + install $(PROJECT) $(PREFIX)/bin/ + +$(PROJECT): $(OBJECTS) $(DYNSTR) + $(CC) $(OBJECTS) $(LDFLAGS) -o $@ +EOF + +if [ $in_tree_dynstr -ne 0 ] +then +cat <<"EOF" >> $F +DYNSTR = ../libweb/dynstr/libdynstr.a +$(PROJECT): $(DYNSTR) +$(DYNSTR): FORCE + +cd ../libweb/dynstr && $(MAKE) CC=$(CC) +EOF +fi + +cat <<"EOF" >> $F +clean: + rm -f $(OBJECTS) $(DEPS) +EOF + +if [ $in_tree_dynstr -ne 0 ] +then +cat <<"EOF" >> $F + +cd ../libweb/dynstr && $(MAKE) clean +EOF +fi + +cat <<"EOF" >> $F +distclean: clean + rm -f $(PROJECT) + rm Makefile +EOF + +# dynstr has no distclean target as of the time of this writing. + +cat <<"EOF" >> $F +-include $(DEPS) +EOF + +mv $F Makefile -- cgit v1.2.3