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/Makefile | 36 ------------- thumbnail/configure | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++ thumbnail/main.c | 2 +- 3 files changed, 145 insertions(+), 37 deletions(-) delete mode 100644 thumbnail/Makefile create mode 100755 thumbnail/configure (limited to 'thumbnail') diff --git a/thumbnail/Makefile b/thumbnail/Makefile deleted file mode 100644 index 4ed1944..0000000 --- a/thumbnail/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -.POSIX: - -PROJECT = thumbnail -PREFIX = /usr/local -O = -Og -CDEFS = -D_FILE_OFFSET_BITS=64 # Required for large file support on 32-bit. -CFLAGS = $(O) $(CDEFS) -g -Wall -I../libweb/dynstr/include -I. \ - $$(pkg-config --cflags ImageMagick) -MD -MF $(@:.o=.d) -LDFLAGS = $(LIBS) -DEPS = $(OBJECTS:.o=.d) -DYNSTR = ../libweb/dynstr/libdynstr.a -DYNSTR_LIBS = -L../libweb/dynstr -ldynstr -LIBS = $$(pkg-config --libs ImageMagick) $(DYNSTR_LIBS) -OBJECTS = \ - crealpath.o \ - main.o \ - cftw.o - -all: $(PROJECT) - -install: all - cp thumbnail $(PREFIX)/bin/ - -clean: - rm -f $(OBJECTS) $(DEPS) - -distclean: clean - rm -f $(PROJECT) - -$(PROJECT): $(OBJECTS) $(DYNSTR) - $(CC) $(OBJECTS) $(LDFLAGS) $(LIBS) -o $@ - -$(DYNSTR): - +cd ../dynstr && $(MAKE) - --include $(DEPS) 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 diff --git a/thumbnail/main.c b/thumbnail/main.c index 7163043..c2bf27a 100644 --- a/thumbnail/main.c +++ b/thumbnail/main.c @@ -1,7 +1,7 @@ #define _POSIX_C_SOURCE 200809L #include "crealpath.h" -#include +#include "cftw.h" #include #include #include -- cgit v1.2.3