diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-02-13 06:29:03 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2026-02-13 07:55:09 +0100 |
| commit | decb51529889b8f2afd67811d635379f030a1b19 (patch) | |
| tree | 1532c71a884c17406a0b4e5b90d64f15033b037b /thumbnail/configure | |
| parent | 8703c35449c3a412c0781f41ddcabdc2dd6eaba9 (diff) | |
| download | slcl-decb51529889b8f2afd67811d635379f030a1b19.tar.gz | |
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.
Diffstat (limited to 'thumbnail/configure')
| -rwxr-xr-x | thumbnail/configure | 144 |
1 files changed, 144 insertions, 0 deletions
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 <<EOF > $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 |
