2017-04-25 14:41:48 +02:00
|
|
|
# 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@
|
|
|
|
|
|
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@
|
|
|
|
|
|
|
|
|
|
# Derive this module's source directory (and VPATH) from where make is running
|
|
|
|
|
# (CURDIR, a build directory) relative to the build top (abspath of MAGICDIR):
|
|
|
|
|
# build top = $(abspath $(MAGICDIR))
|
|
|
|
|
# subpath = "/tiles", or "" at the top
|
|
|
|
|
# srcdir = $(MAGICSRC)$(subpath)
|
|
|
|
|
BUILD_TOP := $(abspath $(MAGICDIR))
|
|
|
|
|
# Anchored prefix strip (patsubst matches the whole word, so BUILD_TOP must be a
|
|
|
|
|
# leading prefix): "" at the build top, "/tiles" in a subdir. Unlike $(subst …)
|
|
|
|
|
# this cannot mis-fire if BUILD_TOP happens to recur later in the path.
|
|
|
|
|
MODULE_SUBPATH := $(patsubst $(BUILD_TOP)%,%,$(CURDIR))
|
|
|
|
|
srcdir := $(MAGICSRC)$(MODULE_SUBPATH)
|
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
|
|
|
# Only set VPATH inside a module (sub)directory, never at the build top: a
|
|
|
|
|
# top-level VPATH into the source tree could let a stale source-tree
|
|
|
|
|
# database/database.h shadow the copy we must (re)generate in the build tree.
|
|
|
|
|
ifneq ($(MODULE_SUBPATH),)
|
2026-07-22 14:33:37 +02:00
|
|
|
VPATH := $(srcdir)
|
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
|
|
|
endif
|
2026-07-22 17:49:58 +02:00
|
|
|
|
|
|
|
|
# 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
|
2026-07-22 14:33:37 +02:00
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
|
|
2017-04-25 14:41:48 +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
|
2017-04-25 14:41:48 +02:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
2020-01-28 16:40:01 +01:00
|
|
|
# Install targets may be different if dist_prefix is set by configure
|
2020-01-28 18:29:44 +01:00
|
|
|
INSTALL_BINDIR = @DIST_DIR@/bin
|
|
|
|
|
INSTALL_MANDIR = @DIST_DIR@/share/man
|
|
|
|
|
INSTALL_LIBDIR = @DIST_DIR@/lib
|
2020-01-28 16:40:01 +01:00
|
|
|
INSTALL_SYSDIR = ${INSTALL_LIBDIR}/magic/sys
|
|
|
|
|
INSTALL_SCMDIR = ${INSTALL_LIBDIR}/magic/scm
|
|
|
|
|
INSTALL_TCLDIR = ${INSTALL_LIBDIR}/magic/tcl
|
|
|
|
|
|
2017-04-25 14:41:48 +02:00
|
|
|
MAIN_EXTRA_LIBS = @extra_libs@
|
2026-07-20 13:03:14 +02:00
|
|
|
LD_FIRST_LIBS = @ld_first_libs@
|
2017-04-25 14:41:48 +02:00
|
|
|
LD_EXTRA_LIBS = @ld_extra_libs@
|
|
|
|
|
LD_SHARED = @ld_extra_objs@
|
|
|
|
|
TOP_EXTRA_LIBS = @top_extra_libs@
|
|
|
|
|
SUB_EXTRA_LIBS = @sub_extra_libs@
|
2024-10-17 22:15:30 +02:00
|
|
|
LIBS = @LIBS@
|
2017-04-25 14:41:48 +02:00
|
|
|
|
|
|
|
|
MODULES += @modules@
|
|
|
|
|
UNUSED_MODULES += @unused@
|
|
|
|
|
PROGRAMS += @programs@
|
|
|
|
|
INSTALL_CAD_DIRS += @cadinstall@
|
|
|
|
|
|
|
|
|
|
RM = rm -f
|
2024-10-21 15:31:50 +02:00
|
|
|
RMDIR = rmdir
|
2017-04-25 14:41:48 +02:00
|
|
|
CP = cp
|
2024-10-21 15:31:50 +02:00
|
|
|
MV = mv
|
|
|
|
|
LN = ln
|
2017-04-25 14:41:48 +02:00
|
|
|
AR = ar
|
2024-10-16 16:56:25 +02:00
|
|
|
ARFLAGS = cr
|
2020-06-29 17:07:43 +02:00
|
|
|
LINK = @LD@ -r
|
2017-04-25 14:41:48 +02:00
|
|
|
LD = @LD@
|
2024-10-21 15:31:50 +02:00
|
|
|
MKDIR = mkdir
|
2025-03-21 12:39:21 +01:00
|
|
|
PERL = @PERL@
|
2024-10-17 22:15:30 +02:00
|
|
|
SED = @SED@
|
2026-07-22 17:02:51 +02:00
|
|
|
LATEX = @LATEX@
|
|
|
|
|
DVIPS = @DVIPS@
|
2017-08-25 20:13:30 +02:00
|
|
|
MCPP = @MCPP@
|
2020-02-19 20:25:58 +01:00
|
|
|
MSED = @MSED@
|
2017-04-25 14:41:48 +02:00
|
|
|
RANLIB = @RANLIB@
|
|
|
|
|
SHDLIB_EXT = @SHDLIB_EXT@
|
2022-05-28 23:51:20 +02:00
|
|
|
ZLIB_FLAG = @ZLIB_FLAG@
|
2026-07-20 16:21:56 +02:00
|
|
|
LDDL_FLAGS = @LDDL_FLAGS@
|
2017-04-25 14:41:48 +02:00
|
|
|
LD_RUN_PATH = @LD_RUN_PATH@
|
|
|
|
|
LIB_SPECS = @LIB_SPECS@
|
2017-10-13 16:28:07 +02:00
|
|
|
LIB_SPECS_NOSTUB = @LIB_SPECS_NOSTUB@
|
2022-03-30 16:55:08 +02:00
|
|
|
LIB_SPECS_GRNULL = @LIB_SPECS_GRNULL@
|
2017-04-25 14:41:48 +02:00
|
|
|
WISH_EXE = @WISH_EXE@
|
|
|
|
|
TCL_LIB_DIR = @TCL_LIB_DIR@
|
2024-10-16 19:08:50 +02:00
|
|
|
|
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)
|
|
|
|
|
MAGIC_COMMIT ?= $(shell git -C ${MAGICSRC} rev-parse HEAD)
|
2024-10-16 19:08:50 +02:00
|
|
|
MAGIC_BUILDDATE ?= $(shell date | tr -d '\r\n')
|
|
|
|
|
|
|
|
|
|
# This allow inheritence of the values from toplevel Makefile
|
|
|
|
|
export MAGIC_VERSION
|
|
|
|
|
export MAGIC_REVISION
|
|
|
|
|
export MAGIC_COMMIT
|
|
|
|
|
export MAGIC_BUILDDATE
|
2017-04-25 14:41:48 +02:00
|
|
|
|
|
|
|
|
CC = @CC@
|
|
|
|
|
CPP = @CPP@
|
|
|
|
|
CXX = @CXX@
|
|
|
|
|
|
2025-02-13 09:19:42 +01:00
|
|
|
###
|
|
|
|
|
### 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
|
|
|
|
|
|
2026-07-22 17:49:58 +02:00
|
|
|
# -I${GENINC}: generated headers (build top in-tree, build/include relocated)
|
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
|
2026-07-22 17:49:58 +02:00
|
|
|
CPPFLAGS = -I${GENINC} -I${MAGICSRC} -I${srcdir} @CPPFLAGS@
|
2026-07-20 16:21:56 +02:00
|
|
|
CXXFLAGS = @CXXFLAGS@
|
2026-07-22 17:32:50 +02:00
|
|
|
# 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
|
2024-10-16 19:08:50 +02:00
|
|
|
DFLAGS_MAGICVERSION = -DMAGIC_VERSION=\"${MAGIC_VERSION}\" -DMAGIC_REVISION=\"${MAGIC_REVISION}\" -DMAGIC_COMMIT=\"${MAGIC_COMMIT}\" "-DMAGIC_BUILDDATE=\"${MAGIC_BUILDDATE}\""
|
2024-10-16 16:34:39 +02:00
|
|
|
DFLAGS = @extra_defs@ @stub_defs@ @DEFS@ ${DFLAGS_MAGICVERSION} -DGCORE=\"@GCORE@\"
|
2025-02-13 09:19:42 +01:00
|
|
|
DFLAGS += -DSHDLIB_EXT=\"@SHDLIB_EXT@\" @NDEBUG_defs@ @DEBUG_defs@ ${FEATURE_FLAGS}
|
2024-10-16 16:34:39 +02:00
|
|
|
DFLAGS_NOSTUB = @extra_defs@ @DEFS@ ${DFLAGS_MAGICVERSION} -DGCORE=\"@GCORE@\"
|
2025-02-13 09:19:42 +01:00
|
|
|
DFLAGS_NOSTUB += -DSHDLIB_EXT=\"@SHDLIB_EXT@\" @NDEBUG_defs@ @DEBUG_defs@ ${FEATURE_FLAGS}
|
2017-04-25 14:41:48 +02:00
|
|
|
CFLAGS = @CFLAGS@ @SHLIB_CFLAGS@ @INC_SPECS@
|
|
|
|
|
|
2026-07-20 16:21:56 +02:00
|
|
|
LDFLAGS = @LDFLAGS@
|
|
|
|
|
|
2017-04-25 14:41:48 +02:00
|
|
|
READLINE_DEFS = @rl_defs@
|
|
|
|
|
READLINE_LIBS = @rl_libs@
|
|
|
|
|
|
|
|
|
|
DEPEND_FILE = Depend
|
|
|
|
|
DEPEND_FLAG = @DEPEND_FLAG@
|
|
|
|
|
EXEEXT = @EXEEXT@
|
|
|
|
|
|
|
|
|
|
GR_CFLAGS = @X_CFLAGS@ @gr_cflags@
|
2024-10-17 11:56:15 +02:00
|
|
|
GR_DFLAGS = @gr_dflags@
|
2024-10-16 11:23:21 +02:00
|
|
|
GR_LIBS = @X_LIBS@ @X_PRE_LIBS@ @gr_libs@ @X_EXTRA_LIBS@
|
2017-04-25 14:41:48 +02:00
|
|
|
GR_SRCS = @gr_srcs@
|
|
|
|
|
GR_HELPER_SRCS = @gr_hsrcs@
|
|
|
|
|
GR_HELPER_PROG = @gr_hprog@
|
|
|
|
|
|
|
|
|
|
OA = @OA@
|
|
|
|
|
OA_LIBS = @OA_LIBS@
|
|
|
|
|
|
|
|
|
|
DEPSRCS = ${SRCS}
|
2024-10-04 21:07:03 +02:00
|
|
|
C_OBJS = ${SRCS:.c=.o}
|
|
|
|
|
CXX_OBJS = ${CXXSRCS:.cpp=.o}
|
|
|
|
|
OBJS = ${CXX_OBJS} ${C_OBJS}
|
2017-04-25 14:41:48 +02:00
|
|
|
LIB_OBJS = ${LIB_SRCS:.c=.o}
|
2023-07-16 18:37:48 +02:00
|
|
|
CLEANS = Depend ${OBJS} ${LIB_OBJS} lib${MODULE}.a lib${MODULE}.o ${MODULE}
|
2024-10-08 09:08:25 +02:00
|
|
|
|
|
|
|
|
# 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@
|