From 213639b834cc124af74cb4525e9504d4a4fd1d12 Mon Sep 17 00:00:00 2001 From: Graham Percival Date: Wed, 21 Feb 2024 11:19:40 -0800 Subject: [PATCH] build: don't link to optional_mutex if it doesn't exist --- Makefile.inc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Makefile.inc b/Makefile.inc index 2ae1b810..e5390ced 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -14,11 +14,22 @@ IDIRS := ${IDIRS} # Default is no man pages MAN = +# The SUBDIR_DEPTH variable (defined above) initializes tracking the +# subdirectory depth, but it's not fully set at this stage in the build +# process. Instead, we jump back to the shell and print the (finalized) value +# of SUBDIR_DEPTH. This avoids an infinite loop because we query the Makefile +# (which does not include ../Makefile.inc), rather than Makefile.BSD (which +# would end up including this file again). +FINALIZED_SUBDIR_DEPTH != ${MAKE} -v SUBDIR_DEPTH + .if !defined(NOLIBALL) # Link everything to liball.a, unless they specifically ask not to use it. -# If appropriate, metabuild.sh will do: +LIBALL = ${SUBDIR_DEPTH}/liball/liball.a +.if exists(${FINALIZED_SUBDIR_DEPTH}/liball/optional_mutex_normal) +# If we have optional_mutex, add it. If appropriate, metabuild.sh will do: # s/optional_mutex_normal/optional_mutex_pthread/g -LIBALL = ${SUBDIR_DEPTH}/liball/liball.a ${SUBDIR_DEPTH}/liball/optional_mutex_normal/liball_optional_mutex_normal.a +LIBALL += ${SUBDIR_DEPTH}/liball/optional_mutex_normal/liball_optional_mutex_normal.a +.endif LDADD += ${LIBALL} DPADD += ${LIBALL} .endif