magic/scripts/defs.mak.in

233 lines
9.6 KiB
Makefile
Raw Normal View History

# defs.mak.in --
# source file for autoconf-generated "defs.mak" for magic
# @configure_input@
# Feel free to change the values in here to suit your needs.
# Be aware that running scripts/configure again will overwrite
# any changes!
SHELL = @SHELL@
build: VPATH-enable shared make machinery (out-of-tree) With the autoconf layer relocatable, teach the shared make files to read sources from the source tree and write objects into the build tree. The ~26 "standard" and "near-standard" module Makefiles now build out-of-tree with no per-module edits. scripts/defs.mak.in: * Add MAGICSRC = @abs_top_srcdir@ (absolute source top) and derive each module's srcdir/VPATH from CURDIR relative to the build top: BUILD_TOP := $(abspath $(MAGICDIR)) MODULE_SUBPATH := $(subst $(BUILD_TOP),,$(CURDIR)) srcdir := $(MAGICSRC)$(MODULE_SUBPATH) VPATH := $(srcdir) (MAGICDIR keeps meaning the *build* top; in-tree the trees coincide.) * CPPFLAGS: add -I${MAGICSRC} (source top, for "<module>/<hdr>.h") and -I${srcdir} (same-dir headers), keeping -I${MAGICDIR} for the generated database/database.h in the build top. * MAGIC_VERSION/REVISION read ${MAGICSRC}/VERSION; MAGIC_COMMIT uses `git -C ${MAGICSRC}` so it works from a build dir outside the work-tree. rules.mak: * Compile rule: `-c $*.c` -> `-c $< -o $@` so the source is found via VPATH in srcdir and the object is written to the build cwd. * Depend and tags rules: prefix sources with $(srcdir)/ (they are passed to the compiler/ctags directly, which do not honor VPATH). scripts/configure.in: AC_CONFIG_FILES([rules.mak:rules.mak]) copies the VPATH-aware rules.mak into the build top, so a single ${MAGICDIR} resolves both `include`s in every subdir Makefile. Regenerated configure. Known limitation (v1): the Depend post-processing sed strips absolute-path headers, so with an absolute srcdir most header deps are dropped; out-of-tree incremental header-change rebuilds are weaker. Depend is already "optimistic/optional"; relativizing is a follow-up. Verified out-of-tree: `tiles` and `drc` (the latter #includes the generated database/database.h) build to completion; all objects land in the build tree; the source tree stays clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 14:33:37 +02:00
# --- out-of-tree (VPATH) support ------------------------------------------
# MAGICDIR is set by each subdir Makefile to the relative path back to the
# *build* top (that is where the generated defs.mak / rules.mak live, and where
# the generated database/database.h is written). MAGICSRC is the absolute path
# to the *source* top. For an in-tree build the two trees coincide.
MAGICSRC = @abs_top_srcdir@
# BUILD_TOP is the absolute build top; GENINC (below) needs it either way.
build: VPATH-enable shared make machinery (out-of-tree) With the autoconf layer relocatable, teach the shared make files to read sources from the source tree and write objects into the build tree. The ~26 "standard" and "near-standard" module Makefiles now build out-of-tree with no per-module edits. scripts/defs.mak.in: * Add MAGICSRC = @abs_top_srcdir@ (absolute source top) and derive each module's srcdir/VPATH from CURDIR relative to the build top: BUILD_TOP := $(abspath $(MAGICDIR)) MODULE_SUBPATH := $(subst $(BUILD_TOP),,$(CURDIR)) srcdir := $(MAGICSRC)$(MODULE_SUBPATH) VPATH := $(srcdir) (MAGICDIR keeps meaning the *build* top; in-tree the trees coincide.) * CPPFLAGS: add -I${MAGICSRC} (source top, for "<module>/<hdr>.h") and -I${srcdir} (same-dir headers), keeping -I${MAGICDIR} for the generated database/database.h in the build top. * MAGIC_VERSION/REVISION read ${MAGICSRC}/VERSION; MAGIC_COMMIT uses `git -C ${MAGICSRC}` so it works from a build dir outside the work-tree. rules.mak: * Compile rule: `-c $*.c` -> `-c $< -o $@` so the source is found via VPATH in srcdir and the object is written to the build cwd. * Depend and tags rules: prefix sources with $(srcdir)/ (they are passed to the compiler/ctags directly, which do not honor VPATH). scripts/configure.in: AC_CONFIG_FILES([rules.mak:rules.mak]) copies the VPATH-aware rules.mak into the build top, so a single ${MAGICDIR} resolves both `include`s in every subdir Makefile. Regenerated configure. Known limitation (v1): the Depend post-processing sed strips absolute-path headers, so with an absolute srcdir most header deps are dropped; out-of-tree incremental header-change rebuilds are weaker. Depend is already "optimistic/optional"; relativizing is a follow-up. Verified out-of-tree: `tiles` and `drc` (the latter #includes the generated database/database.h) build to completion; all objects land in the build tree; the source tree stays clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 14:33:37 +02:00
BUILD_TOP := $(abspath $(MAGICDIR))
# Minimal srcdir fallback. Every module converted to Makefile.in sets
# `srcdir` (and VPATH) from @srcdir@ *before* including this file. The only
# Makefiles that do NOT are readline/ (intentionally never converted) and the
# top-level Makefile; neither compiles magic sources through the pattern rules, so
# neither needs VPATH. We only default `srcdir` -- derived from where make is
# running (CURDIR, a build dir) relative to BUILD_TOP -- so that CPPFLAGS, which
# lists -I${srcdir}, stays well-formed. The patsubst is an anchored prefix strip:
# "" at the build top, "/readline" in the readline subdir.
ifeq ($(origin srcdir),undefined)
srcdir := $(MAGICSRC)$(patsubst $(BUILD_TOP)%,%,$(CURDIR))
endif
# Generated headers (currently just database/database.h) are exposed through a
# single include directory, ${GENINC}:
# * in-tree (build top == source top): the top itself, so the header stays at
# $(builddir)/database/database.h and -I${GENINC} == the old -I${MAGICDIR}.
# * relocated (out-of-tree): a clean $(builddir)/include, so #include
# <database/database.h> resolves under include/ and the raw build top is
# never on the compiler search path.
ifeq ($(BUILD_TOP),$(MAGICSRC))
GENINC := ${MAGICDIR}
else
GENINC := ${MAGICDIR}/include
endif
DATABASE_H := ${GENINC}/database/database.h
build: VPATH-enable shared make machinery (out-of-tree) With the autoconf layer relocatable, teach the shared make files to read sources from the source tree and write objects into the build tree. The ~26 "standard" and "near-standard" module Makefiles now build out-of-tree with no per-module edits. scripts/defs.mak.in: * Add MAGICSRC = @abs_top_srcdir@ (absolute source top) and derive each module's srcdir/VPATH from CURDIR relative to the build top: BUILD_TOP := $(abspath $(MAGICDIR)) MODULE_SUBPATH := $(subst $(BUILD_TOP),,$(CURDIR)) srcdir := $(MAGICSRC)$(MODULE_SUBPATH) VPATH := $(srcdir) (MAGICDIR keeps meaning the *build* top; in-tree the trees coincide.) * CPPFLAGS: add -I${MAGICSRC} (source top, for "<module>/<hdr>.h") and -I${srcdir} (same-dir headers), keeping -I${MAGICDIR} for the generated database/database.h in the build top. * MAGIC_VERSION/REVISION read ${MAGICSRC}/VERSION; MAGIC_COMMIT uses `git -C ${MAGICSRC}` so it works from a build dir outside the work-tree. rules.mak: * Compile rule: `-c $*.c` -> `-c $< -o $@` so the source is found via VPATH in srcdir and the object is written to the build cwd. * Depend and tags rules: prefix sources with $(srcdir)/ (they are passed to the compiler/ctags directly, which do not honor VPATH). scripts/configure.in: AC_CONFIG_FILES([rules.mak:rules.mak]) copies the VPATH-aware rules.mak into the build top, so a single ${MAGICDIR} resolves both `include`s in every subdir Makefile. Regenerated configure. Known limitation (v1): the Depend post-processing sed strips absolute-path headers, so with an absolute srcdir most header deps are dropped; out-of-tree incremental header-change rebuilds are weaker. Depend is already "optimistic/optional"; relativizing is a follow-up. Verified out-of-tree: `tiles` and `drc` (the latter #includes the generated database/database.h) build to completion; all objects land in the build tree; the source tree stays clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 14:33:37 +02:00
# --------------------------------------------------------------------------
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
mandir = @mandir@
build: top Makefile.in + build-dir orchestration (out-of-tree) Make a plain `make` in a build directory build every module into the build tree. The top Makefile becomes a configure-generated Makefile.in, and each recursion drives a build subdirectory (created on demand) using the module Makefile from the source tree. Makefile -> Makefile.in (config.status generates Makefile in the build top via AC_CONFIG_FILES([Makefile:Makefile.in])): * Add MAGICSRC = @abs_top_srcdir@; read VERSION and re-run configure from ${MAGICSRC}. * Every descent `(cd $$dir && ${MAKE} <goal>)` and `${MAKE} -C $(dir $@) <goal>` becomes: mkdir -p <builddir> && ${MAKE} -C <builddir> \ -f ${MAGICSRC}/<dir>/Makefile <goal> so the build subdir need not pre-exist and the source Makefile is used. Applied to modules/libs/depend pattern rules and the tcllibrary/mains/techs/install/clean loops. * database/database.h: generate from ${MAGICSRC}/.../database.h.in into the build tree (mkdir -p database), via the generated build-tree ${MAGICDIR}/scripts/makedbh. * install-dirs/install-tcl-dirs use ${SCRIPTS}/mkdirs (now source-tree); clean skips absent build subdirs; distclean/dist/tags updated for the split source/build layout. scripts/defs.mak.in: * SCRIPTS now points at the source tree (${MAGICSRC}/scripts) for the static helpers (mkdirs, printmans, ...); the one generated helper, makedbh, is referenced directly at ${MAGICDIR}/scripts (build tree). * Guard VPATH so it is set only inside module subdirectories, never at the build top -- a top-level VPATH into the source tree could let a stale source database/database.h shadow the build-tree copy. scripts/configure.in: AC_CONFIG_FILES([Makefile:Makefile.in]); regenerated scripts/configure. Verified out-of-tree: `../configure && make modules && make libs` builds all 33 module libraries (lib*.o and lib*.a) plus the generated database/database.h into the build tree, with no errors and the source tree left clean. A full `make` (link the magic program, build techs) still needs the later outlier fixes (magic/, scmos/, ...). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 14:42:35 +02:00
# Source-tree helper scripts (mkdirs, printmans, preproc.py, ...). The one
# generated script, makedbh, lives in the *build* tree at ${MAGICDIR}/scripts.
SCRIPTS = ${MAGICSRC}/scripts
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
# Override standard "make" target when compiling under TCL
ALL_TARGET = @ALL_TARGET@
INSTALL_TARGET = @INSTALL_TARGET@
# Change libdir to install in a different place
BINDIR = ${bindir}
MANDIR = ${mandir}
LIBDIR = ${libdir}
SYSDIR = ${libdir}/magic/sys
SCMDIR = ${libdir}/magic/scm
TCLDIR = ${libdir}/magic/tcl
# Install targets may be different if dist_prefix is set by configure
INSTALL_BINDIR = @DIST_DIR@/bin
INSTALL_MANDIR = @DIST_DIR@/share/man
INSTALL_LIBDIR = @DIST_DIR@/lib
INSTALL_SYSDIR = ${INSTALL_LIBDIR}/magic/sys
INSTALL_SCMDIR = ${INSTALL_LIBDIR}/magic/scm
INSTALL_TCLDIR = ${INSTALL_LIBDIR}/magic/tcl
MAIN_EXTRA_LIBS = @extra_libs@
LD_FIRST_LIBS = @ld_first_libs@
LD_EXTRA_LIBS = @ld_extra_libs@
LD_SHARED = @ld_extra_objs@
TOP_EXTRA_LIBS = @top_extra_libs@
SUB_EXTRA_LIBS = @sub_extra_libs@
LIBS = @LIBS@
MODULES += @modules@
UNUSED_MODULES += @unused@
PROGRAMS += @programs@
INSTALL_CAD_DIRS += @cadinstall@
RM = rm -f
RMDIR = rmdir
CP = cp
MV = mv
LN = ln
AR = ar
ARFLAGS = cr
LINK = @LD@ -r
LD = @LD@
MKDIR = mkdir
2025-03-21 12:39:21 +01:00
PERL = @PERL@
SED = @SED@
build: auto-detect latex/dvips and regenerate docs in default make When latex and dvips are available, the default no-arg "make" now regenerates the PostScript documentation from its .tex sources into the build tree; otherwise the pre-built PostScript shipped in the source tree is used as-is at install time. Documentation is always available either way -- installing latex simply refreshes it from source. configure (scripts/configure.in, regenerated scripts/configure): * AC_PATH_PROG for latex + dvips; DOCS_TARGET = "docs" only when both are found; AC_SUBST(LATEX/DVIPS/DOCS_TARGET). * Configuration summary prints "LaTeX docs: yes/no". scripts/defs.mak.in: export LATEX/DVIPS. Makefile.in: * all: ... $(DOCS_TARGET) -- pulls in "docs" only when latex was found. * docs: best-effort -- `make -k` + a warning on failure so a document that will not typeset (or a missing texlive package) never fails the build; install falls back to the pre-built PostScript for those. doc/latexfiles/Makefile: * use ${LATEX}/${DVIPS} from defs.mak. * the .tex include figures as ../psfigures/*.ps; point the build-tree ../psfigures at ${MAGICSRC}/doc/psfigures (no-op in-tree) so latex and dvips find them while outputs stay in the build tree. CI: main.yml and main-aarch64.yml install texlive-latex-base/-recommended + texlive-fonts-recommended so the Linux builds exercise doc regeneration (best-effort, never fatal). README.Tcl: document latex/dvips as an optional prerequisite for docs. .gitignore: ignore in-tree doc build artifacts (doc/latexfiles/psfiles/, *.dvi/*.aux/*.log); the pre-built doc/psfiles/ stays tracked. Verified out-of-tree with TeX Live 2024: configure reports "LaTeX docs: yes"; `make` regenerates 27/28 documents into the build tree (maint1.tex has a genuine LaTeX error and falls back), stays exit 0; `make install` installs the 27 regenerated PostScript from the build tree and maint1 from the source pre-built copy; the source tree is not modified. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 17:02:51 +02:00
LATEX = @LATEX@
DVIPS = @DVIPS@
MCPP = @MCPP@
MSED = @MSED@
RANLIB = @RANLIB@
SHDLIB_EXT = @SHDLIB_EXT@
ZLIB_FLAG = @ZLIB_FLAG@
LDDL_FLAGS = @LDDL_FLAGS@
LD_RUN_PATH = @LD_RUN_PATH@
LIB_SPECS = @LIB_SPECS@
LIB_SPECS_NOSTUB = @LIB_SPECS_NOSTUB@
LIB_SPECS_GRNULL = @LIB_SPECS_GRNULL@
WISH_EXE = @WISH_EXE@
TCL_LIB_DIR = @TCL_LIB_DIR@
build: VPATH-enable shared make machinery (out-of-tree) With the autoconf layer relocatable, teach the shared make files to read sources from the source tree and write objects into the build tree. The ~26 "standard" and "near-standard" module Makefiles now build out-of-tree with no per-module edits. scripts/defs.mak.in: * Add MAGICSRC = @abs_top_srcdir@ (absolute source top) and derive each module's srcdir/VPATH from CURDIR relative to the build top: BUILD_TOP := $(abspath $(MAGICDIR)) MODULE_SUBPATH := $(subst $(BUILD_TOP),,$(CURDIR)) srcdir := $(MAGICSRC)$(MODULE_SUBPATH) VPATH := $(srcdir) (MAGICDIR keeps meaning the *build* top; in-tree the trees coincide.) * CPPFLAGS: add -I${MAGICSRC} (source top, for "<module>/<hdr>.h") and -I${srcdir} (same-dir headers), keeping -I${MAGICDIR} for the generated database/database.h in the build top. * MAGIC_VERSION/REVISION read ${MAGICSRC}/VERSION; MAGIC_COMMIT uses `git -C ${MAGICSRC}` so it works from a build dir outside the work-tree. rules.mak: * Compile rule: `-c $*.c` -> `-c $< -o $@` so the source is found via VPATH in srcdir and the object is written to the build cwd. * Depend and tags rules: prefix sources with $(srcdir)/ (they are passed to the compiler/ctags directly, which do not honor VPATH). scripts/configure.in: AC_CONFIG_FILES([rules.mak:rules.mak]) copies the VPATH-aware rules.mak into the build top, so a single ${MAGICDIR} resolves both `include`s in every subdir Makefile. Regenerated configure. Known limitation (v1): the Depend post-processing sed strips absolute-path headers, so with an absolute srcdir most header deps are dropped; out-of-tree incremental header-change rebuilds are weaker. Depend is already "optimistic/optional"; relativizing is a follow-up. Verified out-of-tree: `tiles` and `drc` (the latter #includes the generated database/database.h) build to completion; all objects land in the build tree; the source tree stays clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 14:33:37 +02:00
MAGIC_VERSION ?= $(shell cat ${MAGICSRC}/VERSION | cut -d. -f1-2)
MAGIC_REVISION ?= $(shell cat ${MAGICSRC}/VERSION | cut -d. -f3)
# git may be absent (source tarball) or ${MAGICSRC} not a work-tree: fall back to
# empty rather than emitting an error.
MAGIC_COMMIT ?= $(shell git -C ${MAGICSRC} rev-parse HEAD 2>/dev/null)
# "-DMAGIC_NO_BUILDDATE" when configured with --disable-magic-builddate, else
# empty. buildinfo.c reports an empty MagicCompileTime under that define.
MAGIC_BUILDDATE_DEFS = @MAGIC_BUILDDATE_DEFS@
# Only compute the (volatile) build date when it will actually be baked in --
# skipping it under --disable-magic-builddate avoids the parse-time date spawn.
ifeq (${MAGIC_BUILDDATE_DEFS},)
# Honor SOURCE_DATE_EPOCH (reproducible builds -- appimage/npm tarballs) when set,
2026-07-23 17:19:22 +02:00
# else the current time. The SOURCE_DATE_EPOCH branch uses UTC so a reproducible
# stamp does not depend on the builder's zone; the plain-`date` fallback is local.
MAGIC_BUILDDATE ?= $(shell if [ -n "$$SOURCE_DATE_EPOCH" ]; then \
date -u -d "@$$SOURCE_DATE_EPOCH" 2>/dev/null \
|| date -u -r "$$SOURCE_DATE_EPOCH" 2>/dev/null; \
else date; fi | tr -d '\r\n')
endif
# This allow inheritence of the values from toplevel Makefile
export MAGIC_VERSION
export MAGIC_REVISION
export MAGIC_COMMIT
export MAGIC_BUILDDATE
CC = @CC@
CPP = @CPP@
CXX = @CXX@
###
### Feature flags (to enable uncomment these from ./defs.mak after your ./configure)
###
### SUPPORT_DIRECT_MALLOC: this removes the legacy malloc/free APIs that are
### not thread-safe and have a defer-free-by-1 quirk that maybe covering
### up unknown problems. See utils/malloc.[ch] for more info.
###
### Status: EXPERIMENTAL (this is expected to uncover issues we don't know about yet)
#FEATURE_FLAGS += -DSUPPORT_DIRECT_MALLOC
###
### SUPPORT_REMOVE_MALLOC_LEGACY this completely removes the older non-threadsafe API
### from the output binaries.
### This option is dependent on SUPPORT_DIRECT_MALLOC
###
### Status: NOT-STABILITY-AFFECTING (if your binary links you are good to continue)
#FEATURE_FLAGS += -DSUPPORT_REMOVE_MALLOC_LEGACY
# -I${GENINC}: generated headers (build top in-tree, build/include relocated)
build: VPATH-enable shared make machinery (out-of-tree) With the autoconf layer relocatable, teach the shared make files to read sources from the source tree and write objects into the build tree. The ~26 "standard" and "near-standard" module Makefiles now build out-of-tree with no per-module edits. scripts/defs.mak.in: * Add MAGICSRC = @abs_top_srcdir@ (absolute source top) and derive each module's srcdir/VPATH from CURDIR relative to the build top: BUILD_TOP := $(abspath $(MAGICDIR)) MODULE_SUBPATH := $(subst $(BUILD_TOP),,$(CURDIR)) srcdir := $(MAGICSRC)$(MODULE_SUBPATH) VPATH := $(srcdir) (MAGICDIR keeps meaning the *build* top; in-tree the trees coincide.) * CPPFLAGS: add -I${MAGICSRC} (source top, for "<module>/<hdr>.h") and -I${srcdir} (same-dir headers), keeping -I${MAGICDIR} for the generated database/database.h in the build top. * MAGIC_VERSION/REVISION read ${MAGICSRC}/VERSION; MAGIC_COMMIT uses `git -C ${MAGICSRC}` so it works from a build dir outside the work-tree. rules.mak: * Compile rule: `-c $*.c` -> `-c $< -o $@` so the source is found via VPATH in srcdir and the object is written to the build cwd. * Depend and tags rules: prefix sources with $(srcdir)/ (they are passed to the compiler/ctags directly, which do not honor VPATH). scripts/configure.in: AC_CONFIG_FILES([rules.mak:rules.mak]) copies the VPATH-aware rules.mak into the build top, so a single ${MAGICDIR} resolves both `include`s in every subdir Makefile. Regenerated configure. Known limitation (v1): the Depend post-processing sed strips absolute-path headers, so with an absolute srcdir most header deps are dropped; out-of-tree incremental header-change rebuilds are weaker. Depend is already "optimistic/optional"; relativizing is a follow-up. Verified out-of-tree: `tiles` and `drc` (the latter #includes the generated database/database.h) build to completion; all objects land in the build tree; the source tree stays clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 14:33:37 +02:00
# -I${MAGICSRC}: source top, for "<module>/<header>.h" includes
# -I${srcdir}: this module's source dir, for same-directory headers
CPPFLAGS = -I${GENINC} -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}\" ${MAGIC_BUILDDATE_DEFS}
ifeq (${MAGIC_BUILDDATE_DEFS},)
DFLAGS_MAGICVERSION += "-DMAGIC_BUILDDATE=\"${MAGIC_BUILDDATE}\""
endif
build: isolate build-info defines into utils/buildinfo.c (ccache-friendly) MAGIC_VERSION / MAGIC_REVISION / MAGIC_COMMIT / MAGIC_BUILDDATE were on the global DFLAGS, so every object's compile command line carried them. Because the command line is part of ccache/sccache's hash key and MAGIC_BUILDDATE changes every second, that meant a cache miss on every unit on every build; it also smeared the baked-in date/commit across "whenever each file last recompiled". Move the four values into a single translation unit: * utils/magic_buildinfo.h -- extern MagicVersion/MagicRevision/MagicCommit/ MagicCompileTime (MagicCommit is new; the other three moved here from utils/magic.h, which now includes this header). * utils/buildinfo.c -- the ONLY unit compiled with the version defines (target-specific `buildinfo.o: DFLAGS += ${DFLAGS_MAGICVERSION}` in utils/Makefile.in); it defines the four globals. ${DFLAGS_MAGICVERSION} is removed from the global DFLAGS/DFLAGS_NOSTUB. Consumers updated to read the runtime symbol instead of the compile-time macro: * magicTop.c / tclmagic.c no longer define the globals (the MAGIC_WRAPPER duplicate-symbol guard is gone -- buildinfo.o owns them for every variant, including WASM, which links both mains). * Tcl_PkgProvide/PkgRequire in router/ext2spice/lef/ext2sim/plot/tclmagic now pass MagicVersion. * extflat: EFVersion (a static-initialized copy of MAGIC_VERSION) is dropped; EFread.c compares the .ext version against MagicVersion directly -- the same value ExtCell.c already *writes* into .ext files, so read and write are now consistent. Verified: only buildinfo.o carries -DMAGIC_* (hash/DBio/windCmdSZ carry none); Tcl (375 files) and --without-tcl builds rc=0, version/commit/date embedded in tclmagic.so, magicTop.o no longer defines MagicVersion; in-tree source clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 15:55:20 +02:00
DFLAGS = @extra_defs@ @stub_defs@ @DEFS@ -DGCORE=\"@GCORE@\"
DFLAGS += -DSHDLIB_EXT=\"@SHDLIB_EXT@\" @NDEBUG_defs@ @DEBUG_defs@ ${FEATURE_FLAGS}
build: isolate build-info defines into utils/buildinfo.c (ccache-friendly) MAGIC_VERSION / MAGIC_REVISION / MAGIC_COMMIT / MAGIC_BUILDDATE were on the global DFLAGS, so every object's compile command line carried them. Because the command line is part of ccache/sccache's hash key and MAGIC_BUILDDATE changes every second, that meant a cache miss on every unit on every build; it also smeared the baked-in date/commit across "whenever each file last recompiled". Move the four values into a single translation unit: * utils/magic_buildinfo.h -- extern MagicVersion/MagicRevision/MagicCommit/ MagicCompileTime (MagicCommit is new; the other three moved here from utils/magic.h, which now includes this header). * utils/buildinfo.c -- the ONLY unit compiled with the version defines (target-specific `buildinfo.o: DFLAGS += ${DFLAGS_MAGICVERSION}` in utils/Makefile.in); it defines the four globals. ${DFLAGS_MAGICVERSION} is removed from the global DFLAGS/DFLAGS_NOSTUB. Consumers updated to read the runtime symbol instead of the compile-time macro: * magicTop.c / tclmagic.c no longer define the globals (the MAGIC_WRAPPER duplicate-symbol guard is gone -- buildinfo.o owns them for every variant, including WASM, which links both mains). * Tcl_PkgProvide/PkgRequire in router/ext2spice/lef/ext2sim/plot/tclmagic now pass MagicVersion. * extflat: EFVersion (a static-initialized copy of MAGIC_VERSION) is dropped; EFread.c compares the .ext version against MagicVersion directly -- the same value ExtCell.c already *writes* into .ext files, so read and write are now consistent. Verified: only buildinfo.o carries -DMAGIC_* (hash/DBio/windCmdSZ carry none); Tcl (375 files) and --without-tcl builds rc=0, version/commit/date embedded in tclmagic.so, magicTop.o no longer defines MagicVersion; in-tree source clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 15:55:20 +02:00
DFLAGS_NOSTUB = @extra_defs@ @DEFS@ -DGCORE=\"@GCORE@\"
DFLAGS_NOSTUB += -DSHDLIB_EXT=\"@SHDLIB_EXT@\" @NDEBUG_defs@ @DEBUG_defs@ ${FEATURE_FLAGS}
CFLAGS = @CFLAGS@ @SHLIB_CFLAGS@ @INC_SPECS@
# Set only by configure --enable-ccache-prefix-map (empty otherwise). Maps the
# absolute source root to "." in the compiled output so a cached object carries
# no tree-specific paths -- required for correct cross-tree ccache sharing (pair
# with CCACHE_BASEDIR=<build top> in the environment for cross-tree *hits*).
CCACHE_PREFIX_MAP_FLAG = @CCACHE_PREFIX_MAP_FLAG@
ifneq (${CCACHE_PREFIX_MAP_FLAG},)
CFLAGS += ${CCACHE_PREFIX_MAP_FLAG}=${MAGICSRC}=.
endif
LDFLAGS = @LDFLAGS@
READLINE_DEFS = @rl_defs@
READLINE_LIBS = @rl_libs@
build: per-file automatic dependencies (.deps), retire the Depend/sed machinery Replace the monolithic per-directory `Depend` file -- generated by a separate, serial `make depend` pass (one `gcc -MM` over all sources) and post-processed by sed -- with automake-style per-file dependency fragments produced as a side effect of each compile. rules.mak's %.o rule now adds, when the compiler supports it, -MMD -MP -MF .deps/<stem>.d so every object records the (non-system) headers it used. Those fragments are `-include`d best-effort: absent on a first build, present and correct after. Benefits: * self-maintaining -- no explicit depend step; deps refresh on every compile; * parallel -- generated during the (already parallel) compile, no barrier; * -MMD already drops system headers (what the sed did) and -MP tolerates a removed/renamed header, so the sed post-processing is gone; * fixes out-of-tree incremental header tracking: with an absolute srcdir the old sed stripped the now-absolute *local* header paths too, silently losing them; the .d files keep them. configure probes `-MMD -MP` (AUTODEP_FLAGS; empty and best-effort-skipped if the compiler cannot). clean/distclean remove .deps (rm -r); .gitignore replaces the obsolete */Depend with .deps/. `make depend` is kept as a no-op for callers that still invoke it (e.g. the WASM build script). Verified out-of-tree (--disable-ccache): 324 .d files, 0 Depend files, a header touch recompiles its dependents, no-op rebuild is idle, clean clears .deps. (The top-level depend phase still runs here as a no-op; removed next.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 16:47:29 +02:00
# Per-file dependency flags ("-MMD -MP" when the compiler supports it, else
# empty); used by the %.o rule in rules.mak to write .deps/<stem>.d as a compile
# side effect. Replaces the old serial "make depend" / Depend-file machinery.
AUTODEP_FLAGS = @AUTODEP_FLAGS@
EXEEXT = @EXEEXT@
GR_CFLAGS = @X_CFLAGS@ @gr_cflags@
GR_DFLAGS = @gr_dflags@
GR_LIBS = @X_LIBS@ @X_PRE_LIBS@ @gr_libs@ @X_EXTRA_LIBS@
GR_SRCS = @gr_srcs@
GR_HELPER_SRCS = @gr_hsrcs@
GR_HELPER_PROG = @gr_hprog@
OA = @OA@
OA_LIBS = @OA_LIBS@
C_OBJS = ${SRCS:.c=.o}
CXX_OBJS = ${CXXSRCS:.cpp=.o}
OBJS = ${CXX_OBJS} ${C_OBJS}
LIB_OBJS = ${LIB_SRCS:.c=.o}
build: per-file automatic dependencies (.deps), retire the Depend/sed machinery Replace the monolithic per-directory `Depend` file -- generated by a separate, serial `make depend` pass (one `gcc -MM` over all sources) and post-processed by sed -- with automake-style per-file dependency fragments produced as a side effect of each compile. rules.mak's %.o rule now adds, when the compiler supports it, -MMD -MP -MF .deps/<stem>.d so every object records the (non-system) headers it used. Those fragments are `-include`d best-effort: absent on a first build, present and correct after. Benefits: * self-maintaining -- no explicit depend step; deps refresh on every compile; * parallel -- generated during the (already parallel) compile, no barrier; * -MMD already drops system headers (what the sed did) and -MP tolerates a removed/renamed header, so the sed post-processing is gone; * fixes out-of-tree incremental header tracking: with an absolute srcdir the old sed stripped the now-absolute *local* header paths too, silently losing them; the .d files keep them. configure probes `-MMD -MP` (AUTODEP_FLAGS; empty and best-effort-skipped if the compiler cannot). clean/distclean remove .deps (rm -r); .gitignore replaces the obsolete */Depend with .deps/. `make depend` is kept as a no-op for callers that still invoke it (e.g. the WASM build script). Verified out-of-tree (--disable-ccache): 324 .d files, 0 Depend files, a header touch recompiles its dependents, no-op rebuild is idle, clean clears .deps. (The top-level depend phase still runs here as a no-op; removed next.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 16:47:29 +02:00
CLEANS = ${OBJS} ${LIB_OBJS} lib${MODULE}.a lib${MODULE}.o ${MODULE}
# allows Makefile to be selective
MAKE_TCL = @MAKE_TCL@
MAKE_X11 = @MAKE_X11@
MAKE_GL = @MAKE_GL@
MAKE_GLU = @MAKE_GLU@
MAKE_CAIRO = @MAKE_CAIRO@
MAKE_READLINE = @MAKE_READLINE@