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 <readline/*.h> 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) <noreply@anthropic.com>
This commit is contained in:
Darryl L. Miles 2026-07-22 15:32:50 +00:00 committed by R. Timothy Edwards
parent 03ddc11d25
commit 0a3b61dbdd
2 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -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 <readline/*.h> 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}