]>
Commit | Line | Data |
---|---|---|
ce460d04 RM |
1 | # Subroutine makefile for compiling libc modules linked into dynamic linker. |
2 | ||
581c785b | 3 | # Copyright (C) 2002-2022 Free Software Foundation, Inc. |
ce460d04 RM |
4 | # This file is part of the GNU C Library. |
5 | ||
6 | # The GNU C Library is free software; you can redistribute it and/or | |
7 | # modify it under the terms of the GNU Lesser General Public | |
8 | # License as published by the Free Software Foundation; either | |
9 | # version 2.1 of the License, or (at your option) any later version. | |
10 | ||
11 | # The GNU C Library is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | # Lesser General Public License for more details. | |
15 | ||
16 | # You should have received a copy of the GNU Lesser General Public | |
59ba27a6 | 17 | # License along with the GNU C Library; if not, see |
5a82c748 | 18 | # <https://www.gnu.org/licenses/>. |
ce460d04 RM |
19 | |
20 | # This makefile is never used by itself, but only from the rtld-libc.a | |
21 | # rule in Makefile, which does make -f librtld.mk -f rtld-Rules. | |
22 | # librtld.mk is the generated file containing variable definitions for | |
23 | # `rtld-subdirs', a subset of the top-level $(subdirs) list; and for each | |
24 | # SUBDIR in $(rtld-subdirs), `rtld-SUBDIR' listing `module.os' file names. | |
25 | ||
26 | .PHONY: rtld-all | |
27 | rtld-all: | |
28 | ||
29 | # When run from the elf/Makefile to build rtld-libc.a, $(subdir) is elf. | |
0980fc87 RM |
30 | ifneq ($(subdir),elf) |
31 | ifndef rtld-modules | |
65b22ebc | 32 | $(error rtld-modules not set) |
0980fc87 RM |
33 | endif |
34 | endif | |
35 | ||
36 | ifndef rtld-modules | |
37 | # Running to build rtld-libc.a, driving runs of $(rtld-subdir-make), below. | |
ce460d04 RM |
38 | |
39 | ifndef rtld-subdirs | |
65b22ebc | 40 | $(error This makefile is a subroutine of elf/Makefile not to be used directly) |
ce460d04 RM |
41 | endif |
42 | ||
43 | include ../Makeconfig | |
44 | ||
45 | rtld-all: $(objpfx)rtld-libc.a | |
46 | ||
47 | $(objpfx)rtld-libc.a: $(foreach dir,$(rtld-subdirs),\ | |
48 | $(addprefix $(common-objpfx)$(dir)/rtld-,\ | |
49 | $(rtld-$(dir)))) | |
50 | @-rm -f $@T | |
747bf98e | 51 | $(AR) cq$(verbose) $@T $^ |
ce460d04 RM |
52 | mv -f $@T $@ |
53 | ||
747bf98e RM |
54 | # Use the verbose option of ar and tar when not running silently. |
55 | ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s | |
56 | verbose := v | |
bc96fbda | 57 | else # -s |
747bf98e RM |
58 | verbose := |
59 | endif # not -s | |
60 | ||
61 | ||
ce460d04 RM |
62 | # For each subdirectory, define a pattern rule that makes all of that |
63 | # subdirectory's modules at once with one recursive make command. | |
64 | object-suffixes-left := $(rtld-subdirs) | |
65 | define o-iterator-doit | |
66 | $(foreach obj,$(rtld-$o),$(common-objpfx)%/rtld-$(obj)): FORCE ; \ | |
67 | +$$(rtld-subdir-make) | |
68 | endef | |
69 | include $(patsubst %,../o-iterator.mk,$(object-suffixes-left)) | |
70 | ||
71 | # This is how we descend into each subdirectory. See below. | |
72 | define rtld-subdir-make | |
a5f2bd86 RM |
73 | $(MAKE) $(subdir-args) objdir=$(objdir) \ |
74 | -f Makefile -f ../elf/rtld-Rules rtld-all \ | |
ce460d04 RM |
75 | rtld-modules='$(addprefix rtld-,$(rtld-$*))' |
76 | endef | |
77 | ||
a5f2bd86 RM |
78 | # See subdir-target-args in ../Makefile for the model. |
79 | subdir-args = subdir=$*$(if $($*-srcdir),\ | |
80 | -C $($*-srcdir) ..=`pwd`/,\ | |
81 | -C $(..)$* ..=../) | |
82 | ||
ce460d04 RM |
83 | FORCE: |
84 | ||
85 | else | |
86 | ||
87 | # In this case we are being run by $(rtld-subdir-make), above. | |
88 | # Some other subdir's Makefile has provided all its normal rules, | |
89 | # and we just provide some additional definitions. | |
90 | ||
bfcacbde RM |
91 | rtld-compile-command.S = $(compile-command.S) $(rtld-CPPFLAGS) |
92 | rtld-compile-command.s = $(compile-command.s) $(rtld-CPPFLAGS) | |
5057feff | 93 | rtld-compile-command.c = $(compile-command.c) $(rtld-CPPFLAGS) $(rtld-CFLAGS) |
bfcacbde | 94 | |
ce460d04 RM |
95 | # These are the basic compilation rules corresponding to the Makerules ones. |
96 | # The sysd-rules generated makefile already defines pattern rules for rtld-% | |
97 | # targets built from sysdeps source files. | |
bc96fbda | 98 | $(objpfx)rtld-%.os: rtld-%.S $(before-compile) |
bfcacbde | 99 | $(rtld-compile-command.S) |
bc96fbda | 100 | $(objpfx)rtld-%.os: rtld-%.s $(before-compile) |
bfcacbde | 101 | $(rtld-compile-command.s) |
bc96fbda | 102 | $(objpfx)rtld-%.os: rtld-%.c $(before-compile) |
bfcacbde | 103 | $(rtld-compile-command.c) |
16cd816f | 104 | $(objpfx)rtld-%.os: %.S $(before-compile) |
bfcacbde | 105 | $(rtld-compile-command.S) |
16cd816f | 106 | $(objpfx)rtld-%.os: %.s $(before-compile) |
bfcacbde | 107 | $(rtld-compile-command.s) |
16cd816f | 108 | $(objpfx)rtld-%.os: %.c $(before-compile) |
bfcacbde | 109 | $(rtld-compile-command.c) |
ce460d04 RM |
110 | |
111 | # The rules for generated source files. | |
bfcacbde RM |
112 | $(objpfx)rtld-%.os: $(objpfx)rtld-%.S $(before-compile) |
113 | $(rtld-compile-command.S) | |
114 | $(objpfx)rtld-%.os: $(objpfx)rtld-%.s $(before-compile) | |
115 | $(rtld-compile-command.s) | |
116 | $(objpfx)rtld-%.os: $(objpfx)rtld-%.c $(before-compile) | |
117 | $(rtld-compile-command.c) | |
118 | $(objpfx)rtld-%.os: $(objpfx)%.S $(before-compile) | |
119 | $(rtld-compile-command.S) | |
120 | $(objpfx)rtld-%.os: $(objpfx)%.s $(before-compile) | |
121 | $(rtld-compile-command.s) | |
122 | $(objpfx)rtld-%.os: $(objpfx)%.c $(before-compile) | |
123 | $(rtld-compile-command.c) | |
ce460d04 RM |
124 | |
125 | # The command line setting of rtld-modules (see above) tells us | |
126 | # what we need to build, and that tells us what dependency files we need. | |
127 | rtld-all: $(addprefix $(objpfx),$(rtld-modules)) | |
128 | ||
129 | # Figure out the dependency files we need. After respecting the $(omit-deps) | |
130 | # list as applied to the names without the `rtld-', there may be none left. | |
362f5ae2 | 131 | rtld-depfiles := $(patsubst %,$(objpfx)rtld-%.os.d,\ |
ce460d04 RM |
132 | $(filter-out $(omit-deps),\ |
133 | $(rtld-modules:rtld-%.os=%))) | |
362f5ae2 RM |
134 | rtld-depfiles := $(strip $(wildcard $(rtld-depfiles)) \ |
135 | $(patsubst %.dt,%.d,\ | |
136 | $(wildcard $(rtld-depfiles:.d=.dt)))) | |
ce460d04 RM |
137 | ifdef rtld-depfiles |
138 | -include $(rtld-depfiles) | |
139 | endif | |
140 | ||
4f41c682 | 141 | # This here is the whole point of all the shenanigans. |
9cd47470 SP |
142 | # Set libof-* for each routine. |
143 | cpp-srcs-left := $(rtld-modules:%.os=%) | |
144 | lib := rtld | |
2bfdaedd | 145 | include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left)) |
9cd47470 | 146 | |
995635f9 NA |
147 | rtld-CFLAGS += $(no-stack-protector) |
148 | ||
ce460d04 | 149 | endif |