]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
clean up and simplify rules to build makefile libraries
authorAlan T. DeKok <aland@freeradius.org>
Thu, 1 Jan 2026 16:44:25 +0000 (11:44 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 1 Jan 2026 18:09:45 +0000 (13:09 -0500)
Makefile
scripts/build/make/common.mk

index 8377f150632656297bbe40e3c3bdc74eaa796c8a..ca55ca83443bde692c44ba4e4ea2ae0963714fbd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -146,24 +146,35 @@ build/autoconf.mk: src/include/autoconf.h
     ifeq "$(findstring libfreeradius-make,$(MAKECMDGOALS))" ""
 
       #
-      #  Avoid calling shell if we don't need to build support libraries
+      #  Manually check the dependencies.  This is because we want to
+      #  use special rules for building these libraries.  So we can't
+      #  rely on the normal GNU make dependencies.
       #
-      ifeq "$(wildcard build/lib/.libs/libfreeradius-make-dlopen.${BUILD_LIB_EXT})" ""
-        BUILD_MAKE_LIBS=yes
-      endif
-      ifeq "$(wildcard build/lib/.libs/libfreeradius-make-version.${BUILD_LIB_EXT})" ""
-        BUILD_MAKE_LIBS=yes
-      endif
-      ifeq "$(wildcard build/lib/.libs/libfreeradius-make-util.${BUILD_LIB_EXT})" ""
-        BUILD_MAKE_LIBS=yes
-      endif
+      define MAKE_LIB_CHECK
+        ifeq "$(wildcard build/lib/.libs/libfreeradius-make-${1}.${BUILD_LIB_EXT})" ""
+          BUILD_MAKE_LIBS += libfreeradius-make-${1}.${BUILD_LIB_EXT}
+        endif
+      endef
+
+      $(foreach x, dlopen util version,$(eval $(call MAKE_LIB_CHECK,${x})))
 
       ifdef BUILD_MAKE_LIBS
-        define n
+        #
+        #  Define a variable which contains one new line.  Note that
+        #  it needs to contain multiple lines, not just one.
+        #
+        define newline
 
 
         endef
-        $(info $(subst CC,$nCC,$(shell $(MAKE) VERBOSE=$(VERBOSE) libfreeradius-make-dlopen.${BUILD_LIB_EXT} libfreeradius-make-version.${BUILD_LIB_EXT} libfreeradius-make-util.${BUILD_LIB_EXT})))
+
+        #
+        #  Run the shell command to build the targets.  The result is
+        #  mashed all on one line, so we do some horrible
+        #  substitutions to get it on multiple lines.  Then, we print
+        #  out the result.
+        #
+        $(info $(subst gmake[,$(newline)gmake[,$(subst LINK,$(newline)LINK,$(subst CC,$(newline)CC,$(shell $(MAKE) VERBOSE=$(VERBOSE) ${BUILD_MAKE_LIBS})))))
       endif
 
       load build/lib/.libs/libfreeradius-make-dlopen.${BUILD_LIB_EXT}(dlopen_gmk_setup)
index 5f90b36ce117a3a3aa0d36468f0904a5fe15a090..783a37dbe7412b0811b6a1a328338001e4d45280 100644 (file)
@@ -10,7 +10,7 @@ SOURCES                               := ${TARGET_NAME}.c log.c
 #
 $(TARGET): CFLAGS              := $(filter-out -W% -fsanitize%,$(CFLAGS))
 $(TARGET): CPPFLAGS            := $(filter-out -W%,$(CPPFLAGS))
-$(TARGET): LDFLAGS             := $(filter-out -fsanitize% --rtlib=%,$(LDFLAGS))
+$(TARGET): LDFLAGS             := $(filter-out -fsanitize% --rtlib=% --unwindlib=%,$(LDFLAGS))
 
 #
 #  This gets built with the BUILD_CC i.e. the one we use to bootstrap