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 ` unconfuses emacs.
35 # This is benign and useless in GNU make before 3.63.
36 export subdir := $(subdir)
38 # This is the default target; it makes the library and auxiliary programs.
42 ifeq ($(build-programs),yes)
43 others: $(addprefix $(objpfx),$(extra-objs) \
44 $(install-lib) $(install-bin) \
45 $(install-rootsbin) $(install-sbin))
47 others: $(addprefix $(objpfx),$(extra-objs) \
51 ifneq "$(findstring env,$(origin headers))" ""
55 ifneq "$(findstring env,$(origin generated))" ""
59 ifneq "$(findstring env,$(origin common-generated))" ""
66 subdir_lib: lib-noranlib
68 # Some subdirs need to install a dummy library.
69 # They can use "$(objpfx)libfnord.a: $(dep-dummy-lib); $(make-dummy-lib)".
70 dep-dummy-lib = $(common-objpfx)dummy.o
72 $(AR) cr$(verbose) $@ $<
75 $(common-objpfx)dummy.c:
77 echo 'void __dummy__ (void) { }' > $@
78 $(common-objpfx)empty.c:
80 common-generated += dummy.o dummy.c empty.c \
81 $(addprefix empty,$(object-suffixes))
83 # This makes all the auxiliary and test programs.
86 ifeq ($(build-programs),yes)
87 others: $(addprefix $(objpfx),$(others) $(sysdep-others) $(extra-objs))
89 others: $(addprefix $(objpfx),$(extra-objs))
91 ifeq ($(cross-compiling),yes)
92 tests: $(addprefix $(objpfx),$(tests) $(tests-static) $(test-srcs))
94 ifneq (($build-static),yes)
95 tests: $(tests:%=$(objpfx)%.out)
97 tests: $(tests:%=$(objpfx)%.out) $(tests-static:%=$(objpfx)%.sout)
101 ifeq ($(build-programs),yes)
102 binaries-all = $(others) $(sysdep-others) $(tests) $(test-srcs)
103 binaries-static = $(others-static) $(tests-static) $(test-srcs-static)
105 binaries-all = $(tests) $(test-srcs)
106 binaries-static = $(tests-static) $(test-srcs-static)
109 binaries-shared = $(filter-out $(binaries-static), $(binaries-all))
111 ifneq "$(strip $(binaries-shared))" ""
112 $(addprefix $(objpfx),$(binaries-shared)): %: %.o \
113 $(sort $(filter $(common-objpfx)libc%,$(link-libc))) \
114 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
118 ifneq "$(strip $(binaries-static))" ""
119 $(addprefix $(objpfx),$(binaries-static)): %: %.o \
120 $(sort $(filter $(common-objpfx)libc%,$(link-libc-static))) \
121 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
125 ifneq "$(strip $(tests) $(test-srcs))" ""
126 # These are the implicit rules for making test outputs
127 # from the test programs and whatever input files are present.
128 $(objpfx)%.out: %.args $(objpfx)% %.input
129 $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` < $(word 3,$^) > $@
130 $(objpfx)%.out: %.args $(objpfx)%
131 $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` > $@
132 $(objpfx)%.out: %.input $(objpfx)%
133 $($*-ENV) $(built-program-cmd) < $(word 1,$^) > $@
134 $(objpfx)%.out: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
135 $($*-ENV) $(built-program-cmd) > $@
138 ifneq "$(strip $(tests-static) $(test-static-srcs))" ""
139 # These are the implicit rules for making test outputs
140 # from the test programs and whatever input files are present.
141 $(objpfx)%.sout: %.args $(objpfx)% %.input
142 $($*-ENV) $(built-program-file) `cat $(word 1,$^)` < $(word 3,$^) > $@
143 $(objpfx)%.sout: %.args $(objpfx)%
144 $($*-ENV) $(built-program-file) `cat $(word 1,$^)` > $@
145 $(objpfx)%.sout: %.input $(objpfx)%
146 $($*-ENV) $(built-program-file) < $(word 1,$^) > $@
147 $(objpfx)%.sout: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
148 $($*-ENV) $(built-program-file) > $@
151 .PHONY: distclean realclean subdir_distclean subdir_realclean \
152 subdir_clean subdir_mostlyclean
153 subdir_mostlyclean: mostlyclean
155 subdir_distclean: distclean
156 subdir_realclean: realclean
160 .PHONY: subdir_echo-headers
161 subdir_echo-headers: echo-headers
163 .PHONY: subdir_echo-distinfo
164 subdir_echo-distinfo:
165 @echo $(addprefix +header+,$(headers) $(filter %.h,$(distribute))) \
166 $(addprefix +nodist+,$(generated) $(common-generated) $(dont_distribute))
168 # We want to install everything except the library itself, but update all
169 # our portions of the library because the parent make will install it later
170 # (likewise the stubs file).
171 .PHONY: subdir_install
172 subdir_install: install-no-libc.a lib-noranlib stubs
174 .PHONY: subdir_TAGS subdir_dist
178 # Convenient target to update all the generated source files.
180 generated: $(addprefix $(common-objpfx),$(common-generated)) \
181 $(addprefix $(objpfx),$(generated))
183 # Target required by the Hurd to ensure that all the MiG-generated
184 # headers are in place before building a subdirectory.
185 .PHONY: before-compile
186 before-compile: $(before-compile)
188 define o-iterator-doit
189 $(common-objpfx)empty$o: $(common-objpfx)empty.c $(before-compile);
190 $$(compile-command.c)
192 object-suffixes-left := $(object-suffixes)
193 include $(o-iterator)
195 define o-iterator-doit
196 $(common-objpfx)dummy$o: $(common-objpfx)dummy.c $(before-compile);
197 $$(compile-command.c)
199 object-suffixes-left := $(object-suffixes)
200 include $(o-iterator)