# Subroutine makefile for compiling libc modules linked into dynamic linker.
-# Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2002-2023 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
-# License along with the GNU C Library; if not, write to the Free
-# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-# 02111-1307 USA.
+# License along with the GNU C Library; if not, see
+# <https://www.gnu.org/licenses/>.
# This makefile is never used by itself, but only from the rtld-libc.a
# rule in Makefile, which does make -f librtld.mk -f rtld-Rules.
# When run from the elf/Makefile to build rtld-libc.a, $(subdir) is elf.
ifneq ($(subdir),elf)
ifndef rtld-modules
-error rtld-modules not set
+$(error rtld-modules not set)
endif
endif
# Running to build rtld-libc.a, driving runs of $(rtld-subdir-make), below.
ifndef rtld-subdirs
-error This makefile is a subroutine of elf/Makefile not to be used directly
+$(error This makefile is a subroutine of elf/Makefile not to be used directly)
endif
include ../Makeconfig
$(rtld-$(dir))))
@-rm -f $@T
$(AR) cq$(verbose) $@T $^
- $(RANLIB) $@T
mv -f $@T $@
# Use the verbose option of ar and tar when not running silently.
-ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
+ifeq ($(silent-make),no) # if not -s
verbose := v
-else # -s
+else # -s
verbose :=
endif # not -s
# Some other subdir's Makefile has provided all its normal rules,
# and we just provide some additional definitions.
+rtld-compile-command.S = $(compile-command.S) $(rtld-CPPFLAGS)
+rtld-compile-command.s = $(compile-command.s) $(rtld-CPPFLAGS)
+rtld-compile-command.c = $(compile-command.c) $(rtld-CPPFLAGS) $(rtld-CFLAGS)
+
# These are the basic compilation rules corresponding to the Makerules ones.
# The sysd-rules generated makefile already defines pattern rules for rtld-%
# targets built from sysdeps source files.
-$(objpfx)rtld-%.os: %.S $(before-compile); $(compile-command.S)
-$(objpfx)rtld-%.os: %.s $(before-compile); $(compile-command.s)
-$(objpfx)rtld-%.os: %.c $(before-compile); $(compile-command.c)
+$(objpfx)rtld-%.os: rtld-%.S $(before-compile)
+ $(rtld-compile-command.S)
+$(objpfx)rtld-%.os: rtld-%.s $(before-compile)
+ $(rtld-compile-command.s)
+$(objpfx)rtld-%.os: rtld-%.c $(before-compile)
+ $(rtld-compile-command.c)
+$(objpfx)rtld-%.os: %.S $(before-compile)
+ $(rtld-compile-command.S)
+$(objpfx)rtld-%.os: %.s $(before-compile)
+ $(rtld-compile-command.s)
+$(objpfx)rtld-%.os: %.c $(before-compile)
+ $(rtld-compile-command.c)
# The rules for generated source files.
-$(objpfx)rtld-%.os: $(objpfx)%.S $(before-compile); $(compile-command.S)
-$(objpfx)rtld-%.os: $(objpfx)%.s $(before-compile); $(compile-command.s)
-$(objpfx)rtld-%.os: $(objpfx)%.c $(before-compile); $(compile-command.c)
+$(objpfx)rtld-%.os: $(objpfx)rtld-%.S $(before-compile)
+ $(rtld-compile-command.S)
+$(objpfx)rtld-%.os: $(objpfx)rtld-%.s $(before-compile)
+ $(rtld-compile-command.s)
+$(objpfx)rtld-%.os: $(objpfx)rtld-%.c $(before-compile)
+ $(rtld-compile-command.c)
+$(objpfx)rtld-%.os: $(objpfx)%.S $(before-compile)
+ $(rtld-compile-command.S)
+$(objpfx)rtld-%.os: $(objpfx)%.s $(before-compile)
+ $(rtld-compile-command.s)
+$(objpfx)rtld-%.os: $(objpfx)%.c $(before-compile)
+ $(rtld-compile-command.c)
# The command line setting of rtld-modules (see above) tells us
# what we need to build, and that tells us what dependency files we need.
-include $(rtld-depfiles)
endif
-# Just in case we wind up e.g. regenerating dependencies for non-rtld objects,
-# we don't unconditionally modify the flags. For rtld-% targets, use the
-# special flags set below.
-CFLAGS += $(if $(filter rtld-%,$(@F)),$(CFLAGS-rtld))
-CPPFLAGS += $(if $(filter rtld-%,$(@F)),$(CPPFLAGS-rtld))
-
-
# This here is the whole point of all the shenanigans.
-CPPFLAGS-rtld := -DNOT_IN_libc=1 -DIS_IN_rtld=1
-CFLAGS-rtld := # blah
+# Set libof-* for each routine.
+cpp-srcs-left := $(rtld-modules:%.os=%)
+lib := rtld
+include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
+rtld-CFLAGS += $(no-stack-protector) $(no-fortify-source)
endif