Add a testase for BZ #14602
[glibc.git] / elf / rtld-Rules
blob1e03332ca1894b678da230b9abc8c9db10877c2a
1 # Subroutine makefile for compiling libc modules linked into dynamic linker.
3 # Copyright (C) 2002-2012 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
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.
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.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with the GNU C Library; if not, see
18 # <http://www.gnu.org/licenses/>.
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.
26 .PHONY: rtld-all
27 rtld-all:
29 # When run from the elf/Makefile to build rtld-libc.a, $(subdir) is elf.
30 ifneq ($(subdir),elf)
31 ifndef rtld-modules
32 error rtld-modules not set
33 endif
34 endif
36 ifndef rtld-modules
37 # Running to build rtld-libc.a, driving runs of $(rtld-subdir-make), below.
39 ifndef rtld-subdirs
40 error This makefile is a subroutine of elf/Makefile not to be used directly
41 endif
43 include ../Makeconfig
45 rtld-all: $(objpfx)rtld-libc.a
47 $(objpfx)rtld-libc.a: $(foreach dir,$(rtld-subdirs),\
48                                 $(addprefix $(common-objpfx)$(dir)/rtld-,\
49                                             $(rtld-$(dir))))
50         @-rm -f $@T
51         $(AR) cq$(verbose) $@T $^
52         mv -f $@T $@
54 # Use the verbose option of ar and tar when not running silently.
55 ifeq    "$(findstring s,$(MAKEFLAGS))" ""       # if not -s
56 verbose := v
57 else                                            # -s
58 verbose :=
59 endif                                           # not -s
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))
71 # This is how we descend into each subdirectory.  See below.
72 define rtld-subdir-make
73 $(MAKE) $(subdir-args) objdir=$(objdir) \
74         -f Makefile -f ../elf/rtld-Rules rtld-all \
75         rtld-modules='$(addprefix rtld-,$(rtld-$*))'
76 endef
78 # See subdir-target-args in ../Makefile for the model.
79 subdir-args = subdir=$*$(if $($*-srcdir),\
80                             -C $($*-srcdir) ..=`pwd`/,\
81                             -C $(..)$* ..=../)
83 FORCE:
85 else
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.
91 # These are the basic compilation rules corresponding to the Makerules ones.
92 # The sysd-rules generated makefile already defines pattern rules for rtld-%
93 # targets built from sysdeps source files.
94 $(objpfx)rtld-%.os: rtld-%.S $(before-compile)
95         $(compile-command.S) $(rtld-CPPFLAGS)
96 $(objpfx)rtld-%.os: rtld-%.s $(before-compile)
97         $(compile-command.s) $(rtld-CPPFLAGS)
98 $(objpfx)rtld-%.os: rtld-%.c $(before-compile)
99         $(compile-command.c) $(rtld-CPPFLAGS)
100 $(objpfx)rtld-%.os: %.S $(before-compile)
101         $(compile-command.S) $(rtld-CPPFLAGS)
102 $(objpfx)rtld-%.os: %.s $(before-compile)
103         $(compile-command.s) $(rtld-CPPFLAGS)
104 $(objpfx)rtld-%.os: %.c $(before-compile)
105         $(compile-command.c) $(rtld-CPPFLAGS)
107 # The rules for generated source files.
108 $(objpfx)rtld-%.os: $(objpfx)rtld-%.S $(before-compile); $(compile-command.S)
109 $(objpfx)rtld-%.os: $(objpfx)rtld-%.s $(before-compile); $(compile-command.s)
110 $(objpfx)rtld-%.os: $(objpfx)rtld-%.c $(before-compile); $(compile-command.c)
111 $(objpfx)rtld-%.os: $(objpfx)%.S $(before-compile); $(compile-command.S)
112 $(objpfx)rtld-%.os: $(objpfx)%.s $(before-compile); $(compile-command.s)
113 $(objpfx)rtld-%.os: $(objpfx)%.c $(before-compile); $(compile-command.c)
115 # The command line setting of rtld-modules (see above) tells us
116 # what we need to build, and that tells us what dependency files we need.
117 rtld-all: $(addprefix $(objpfx),$(rtld-modules))
119 # Figure out the dependency files we need.  After respecting the $(omit-deps)
120 # list as applied to the names without the `rtld-', there may be none left.
121 rtld-depfiles := $(patsubst %,$(objpfx)rtld-%.os.d,\
122                             $(filter-out $(omit-deps),\
123                                          $(rtld-modules:rtld-%.os=%)))
124 rtld-depfiles := $(strip $(wildcard $(rtld-depfiles)) \
125                          $(patsubst %.dt,%.d,\
126                                     $(wildcard $(rtld-depfiles:.d=.dt))))
127 ifdef rtld-depfiles
128 -include $(rtld-depfiles)
129 endif
131 # This here is the whole point of all the shenanigans.
132 rtld-CPPFLAGS := -DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld
134 endif