1 # Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
4 # The GNU C Library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Library General Public License as
6 # published by the Free Software Foundation; either version 2 of the
7 # License, or (at your option) any later version.
9 # The GNU C Library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Library General Public License for more details.
14 # You should have received a copy of the GNU Library General Public
15 # License along with the GNU C Library; see the file COPYING.LIB. If not,
16 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 # Boston, MA 02111-1307, USA.
20 # Rules for making a subdirectory in the GNU C library.
21 # Each subdirectory Makefile defines some variables and includes this.
24 This makefile requires GNU Make.
27 all: # Don't let the default goal come from Makeconfig.
32 Each subdirectory makefile must define the `subdir' variable.
34 # This is benign and useless in GNU make before 3.63.
35 export subdir := $(subdir)
37 # This is the default target; it makes the library and auxiliary programs.
41 ifeq ($(build-programs),yes)
42 others: $(addprefix $(objpfx),$(extra-objs) \
43 $(install-lib) $(install-bin) \
44 $(install-rootsbin) $(install-sbin))
46 others: $(addprefix $(objpfx),$(extra-objs) \
50 ifneq "$(findstring env,$(origin headers))" ""
54 ifneq "$(findstring env,$(origin generated))" ""
58 ifneq "$(findstring env,$(origin common-generated))" ""
65 subdir_lib: lib-noranlib
67 # Some subdirs need to install a dummy library.
68 # They can use "$(objpfx)libfnord.a: $(dep-dummy-lib); $(make-dummy-lib)".
69 dep-dummy-lib = $(common-objpfx)dummy.o
71 $(AR) cr$(verbose) $@ $<
74 $(common-objpfx)dummy.c:
76 echo 'void __dummy__ (void) { }' > $@
77 $(common-objpfx)empty.c:
79 common-generated += dummy.o dummy.c empty.c \
80 $(addprefix empty,$(object-suffixes))
82 # This makes all the auxiliary and test programs.
85 ifeq ($(build-programs),yes)
86 others: $(addprefix $(objpfx),$(others) $(extra-objs))
88 others: $(addprefix $(objpfx),$(extra-objs))
90 ifeq ($(cross-compiling),yes)
91 tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
93 tests: $(tests:%=$(objpfx)%.out)
96 ifeq ($(build-programs),yes)
97 binaries-all = $(others) $(tests) $(test-srcs)
98 binaries-static = $(others-static) $(tests-static) $(test-srcs-static)
100 binaries-all = $(tests) $(test-srcs)
101 binaries-static = $(tests-static) $(test-srcs-static)
104 binaries-shared = $(filter-out $(binaries-static), $(binaries-all))
106 ifneq "$(strip $(binaries-shared))" ""
107 $(addprefix $(objpfx),$(binaries-shared)): %: %.o \
108 $(sort $(filter $(common-objpfx)libc%,$(link-libc))) \
109 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
113 ifneq "$(strip $(binaries-static))" ""
114 $(addprefix $(objpfx),$(binaries-static)): %: %.o \
115 $(sort $(filter $(common-objpfx)libc%,$(link-libc-static))) \
116 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
120 ifneq "$(strip $(tests) $(test-srcs))" ""
121 # These are the implicit rules for making test outputs
122 # from the test programs and whatever input files are present.
123 $(objpfx)%.out: %.args $(objpfx)% %.input
124 $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` < $(word 3,$^) > $@
125 $(objpfx)%.out: %.args $(objpfx)%
126 $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` > $@
127 $(objpfx)%.out: %.input $(objpfx)%
128 $($*-ENV) $(built-program-cmd) < $(word 1,$^) > $@
129 $(objpfx)%.out: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
130 $($*-ENV) $(built-program-cmd) > $@
133 .PHONY: distclean realclean subdir_distclean subdir_realclean \
134 subdir_clean subdir_mostlyclean
135 subdir_mostlyclean: mostlyclean
137 subdir_distclean: distclean
138 subdir_realclean: realclean
142 .PHONY: subdir_echo-headers
143 subdir_echo-headers: echo-headers
145 .PHONY: subdir_echo-distinfo
146 subdir_echo-distinfo:
147 @echo $(addprefix +header+,$(headers) $(filter %.h,$(distribute))) \
148 $(addprefix +nodist+,$(generated) $(common-generated) $(dont_distribute))
150 # We want to install everything except the library itself, but update all
151 # our portions of the library because the parent make will install it later
152 # (likewise the stubs file).
153 .PHONY: subdir_install
154 subdir_install: install-no-libc.a lib-noranlib stubs
156 .PHONY: subdir_TAGS subdir_dist
160 # Convenient target to update all the generated source files.
162 generated: $(addprefix $(common-objpfx),$(common-generated)) \
163 $(addprefix $(objpfx),$(generated))
165 define o-iterator-doit
166 $(common-objpfx)empty$o: $(common-objpfx)empty.c $(before-compile);
167 $$(compile-command.c)
169 object-suffixes-left := $(object-suffixes)
170 include $(o-iterator)
172 define o-iterator-doit
173 $(common-objpfx)dummy$o: $(common-objpfx)dummy.c $(before-compile);
174 $$(compile-command.c)
176 object-suffixes-left := $(object-suffixes)
177 include $(o-iterator)
179 ifndef libc.so-version
180 # Undefine this because it can't work when we libc.so is unversioned.
181 static-only-routines =
184 ifdef static-only-routines
185 # These routines are to be omitted from the shared library object,
186 # so we replace the PIC objects for them with the empty object file.
187 $(static-only-routines:%=$(objpfx)%.os): %.os: $(common-objpfx)empty.os
191 # Must build the routines as PIC, though, because they can end up in (users')
192 # shared objects. We don't want to use CFLAGS-os because users may, for
193 # example, make that processor-specific.
194 $(static-only-routines:%=$(objpfx)%.o): $(objpfx)%.o: %.c $(before-compile)
195 $(compile.c) $(pic-ccflag) $(OUTPUT_OPTION)
198 ifdef shared-only-routines
199 # If we have versioned code we don't need the old versions in any of the
201 define o-iterator-doit
202 $(shared-only-routines:%=$(objpfx)%$o): %$o: $(common-objpfx)empty$o;
206 object-suffixes-left := $(filter-out .os,$(object-suffixes))
207 include $(o-iterator)