From 0a3b61dbdd0688cf0ce24d492bcbba4914c7f947 Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Wed, 22 Jul 2026 15:32:50 +0000 Subject: [PATCH] build: fix bundled-readline out-of-tree (unblocks the non-Tcl build) The non-Tcl ("standard") configuration links the bundled GNU readline, and that path was broken two ways: * headers: readline's own headers use includes, so the readline source's parent must be on the include path. Nothing added it, so every module including readline (commands, textio, ...) failed with "readline/rlstdc.h: No such file". Add -I${MAGICSRC}/readline to CPPFLAGS for the bundled build only (@MAKE_READLINE@ = 1). * library: readline/Makefile ran "../readline/configure" from the build-readline dir -- a source-relative path that, out-of-tree, points into the (empty) build tree. Use ${MAGICSRC}/readline/readline/ configure so the out-of-source readline build finds its sources. Verified: `mkdir b; cd b; ../configure --without-tcl && make` now completes (rc=0) and produces the native magic binary; previously it died at commands/CmdFI.o (headers) then at the readline library build. Co-Authored-By: Claude Opus 4.8 (1M context) --- readline/Makefile | 2 +- scripts/defs.mak.in | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/readline/Makefile b/readline/Makefile index 1d517c7a..360f8469 100644 --- a/readline/Makefile +++ b/readline/Makefile @@ -62,7 +62,7 @@ build-readline: readline-create-symlinks echo --- building GNU readline ; \ $(MKDIR) -p build-readline ; \ (cd build-readline && CC="${CC}" CFLAGS="${CFLAGS}" LOCAL_DEFS="${READLINE_DEFS}" \ - "../readline/configure" --disable-shared) || exit 1 ; \ + "${MAGICSRC}/readline/readline/configure" --disable-shared) || exit 1 ; \ fi @(cd build-readline && ${MAKE}) || exit 1 diff --git a/scripts/defs.mak.in b/scripts/defs.mak.in index d64b1627..7c34faf3 100755 --- a/scripts/defs.mak.in +++ b/scripts/defs.mak.in @@ -146,6 +146,12 @@ CXX = @CXX@ # -I${srcdir}: this module's source dir, for same-directory headers CPPFLAGS = -I${MAGICDIR} -I${MAGICSRC} -I${srcdir} @CPPFLAGS@ CXXFLAGS = @CXXFLAGS@ +# Bundled GNU readline: its headers use includes, so the readline +# source's parent directory must be on the include path. Only for the bundled +# build (@MAKE_READLINE@ = 1); a no-op with a system or disabled readline. +ifeq (@MAKE_READLINE@,1) +CPPFLAGS += -I${MAGICSRC}/readline +endif DFLAGS_MAGICVERSION = -DMAGIC_VERSION=\"${MAGIC_VERSION}\" -DMAGIC_REVISION=\"${MAGIC_REVISION}\" -DMAGIC_COMMIT=\"${MAGIC_COMMIT}\" "-DMAGIC_BUILDDATE=\"${MAGIC_BUILDDATE}\"" DFLAGS = @extra_defs@ @stub_defs@ @DEFS@ ${DFLAGS_MAGICVERSION} -DGCORE=\"@GCORE@\" DFLAGS += -DSHDLIB_EXT=\"@SHDLIB_EXT@\" @NDEBUG_defs@ @DEBUG_defs@ ${FEATURE_FLAGS}