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 tests: $(tests:%=$(objpfx)%.out) $(tests-static:%=$(objpfx)%.sout)
97 ifeq ($(build-programs),yes)
98 binaries-all = $(others) $(sysdep-others) $(tests) $(test-srcs)
99 binaries-static = $(others-static) $(tests-static) $(test-srcs-static)
101 binaries-all = $(tests) $(test-srcs)
102 binaries-static = $(tests-static) $(test-srcs-static)
105 binaries-shared = $(filter-out $(binaries-static), $(binaries-all))
107 ifneq "$(strip $(binaries-shared))" ""
108 $(addprefix $(objpfx),$(binaries-shared)): %: %.o \
109 $(sort $(filter $(common-objpfx)libc%,$(link-libc))) \
110 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
114 ifneq "$(strip $(binaries-static))" ""
115 $(addprefix $(objpfx),$(binaries-static)): %: %.o \
116 $(sort $(filter $(common-objpfx)libc%,$(link-libc-static))) \
117 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
121 ifneq "$(strip $(tests) $(test-srcs))" ""
122 # These are the implicit rules for making test outputs
123 # from the test programs and whatever input files are present.
124 $(objpfx)%.out: %.args $(objpfx)% %.input
125 $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` < $(word 3,$^) > $@
126 $(objpfx)%.out: %.args $(objpfx)%
127 $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` > $@
128 $(objpfx)%.out: %.input $(objpfx)%
129 $($*-ENV) $(built-program-cmd) < $(word 1,$^) > $@
130 $(objpfx)%.out: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
131 $($*-ENV) $(built-program-cmd) > $@
134 ifneq "$(strip $(tests-static) $(test-static-srcs))" ""
135 # These are the implicit rules for making test outputs
136 # from the test programs and whatever input files are present.
137 $(objpfx)%.sout: %.args $(objpfx)% %.input
138 $($*-ENV) $(built-program-file) `cat $(word 1,$^)` < $(word 3,$^) > $@
139 $(objpfx)%.sout: %.args $(objpfx)%
140 $($*-ENV) $(built-program-file) `cat $(word 1,$^)` > $@
141 $(objpfx)%.sout: %.input $(objpfx)%
142 $($*-ENV) $(built-program-file) < $(word 1,$^) > $@
143 $(objpfx)%.sout: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
144 $($*-ENV) $(built-program-file) > $@
147 .PHONY: distclean realclean subdir_distclean subdir_realclean \
148 subdir_clean subdir_mostlyclean
149 subdir_mostlyclean: mostlyclean
151 subdir_distclean: distclean
152 subdir_realclean: realclean
156 .PHONY: subdir_echo-headers
157 subdir_echo-headers: echo-headers
159 .PHONY: subdir_echo-distinfo
160 subdir_echo-distinfo:
161 @echo $(addprefix +header+,$(headers) $(filter %.h,$(distribute))) \
162 $(addprefix +nodist+,$(generated) $(common-generated) $(dont_distribute))
164 # We want to install everything except the library itself, but update all
165 # our portions of the library because the parent make will install it later
166 # (likewise the stubs file).
167 .PHONY: subdir_install
168 subdir_install: install-no-libc.a lib-noranlib stubs
170 .PHONY: subdir_TAGS subdir_dist
174 # Convenient target to update all the generated source files.
176 generated: $(addprefix $(common-objpfx),$(common-generated)) \
177 $(addprefix $(objpfx),$(generated))
179 # Target required by the Hurd to ensure that all the MiG-generated
180 # headers are in place before building a subdirectory.
181 .PHONY: before-compile
182 before-compile: $(before-compile)
184 define o-iterator-doit
185 $(common-objpfx)empty$o: $(common-objpfx)empty.c $(before-compile);
186 $$(compile-command.c)
188 object-suffixes-left := $(object-suffixes)
189 include $(o-iterator)
191 define o-iterator-doit
192 $(common-objpfx)dummy$o: $(common-objpfx)dummy.c $(before-compile);
193 $$(compile-command.c)
195 object-suffixes-left := $(object-suffixes)
196 include $(o-iterator)