1 # Copyright (C) 1991,92,93,94,95,96,97,98,99 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) $(test-srcs))
94 tests: $(tests:%=$(objpfx)%.out)
97 ifeq ($(build-programs),yes)
98 binaries-all = $(others) $(sysdep-others) $(tests) $(test-srcs)
99 binaries-static = $(others-static)
101 binaries-all = $(tests) $(test-srcs)
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)lib%,$(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)lib%,$(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 .PHONY: distclean realclean subdir_distclean subdir_realclean \
135 subdir_clean subdir_mostlyclean subdir_testclean
136 subdir_mostlyclean: mostlyclean
138 subdir_distclean: distclean
139 subdir_realclean: realclean
140 subdir_testclean: do-tests-clean
144 .PHONY: subdir_echo-headers
145 subdir_echo-headers: echo-headers
147 .PHONY: subdir_echo-distinfo
148 subdir_echo-distinfo:
149 @echo $(addprefix +header+,$(headers) $(filter %.h,$(distribute))) \
150 $(addprefix +nodist+,$(generated) $(common-generated) $(dont_distribute))
152 # We want to install everything except the library itself, but update all
153 # our portions of the library because the parent make will install it later
154 # (likewise the stubs file).
155 .PHONY: subdir_install
156 subdir_install: install-no-libc.a lib-noranlib stubs
158 .PHONY: subdir_TAGS subdir_dist
162 # Convenient target to update all the generated source files.
164 generated: $(addprefix $(common-objpfx),$(common-generated)) \
165 $(addprefix $(objpfx),$(generated))
167 # Target required by the Hurd to ensure that all the MiG-generated
168 # headers are in place before building a subdirectory.
169 .PHONY: before-compile
170 before-compile: $(before-compile)
172 $(common-objpfx)dummy.o: $(common-objpfx)dummy.c $(before-compile);
175 define o-iterator-doit
176 $(common-objpfx)empty$o: $(common-objpfx)empty.c $(before-compile);
177 $$(compile-command.c)
179 object-suffixes-left := $(object-suffixes)
180 include $(o-iterator)
182 # There's no good place to put this - here will do.
183 # The dependencies are wrong if it's run from the top level.
184 ifeq ($(filter %posix, $(sysdirs)),)
195 stdio_lim = $(common-objpfx)bits/stdio_lim.h
197 $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
198 $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
199 $(common-objpfx)config.make
200 $(make-target-directory)
201 echo '#include "$(..)posix/bits/posix1_lim.h"' | \
202 SUNPRO_DEPENDENCIES='$(@:st=dT) $@' \
203 $(CC) $(+includes) -E -dM -xc - -o $(@:st=hT)
204 ifdef sed-remove-objpfx
205 sed $(sed-remove-objpfx) $(@:st=dT) > $(@:st=dt)
206 mv -f $(@:st=dt) $(@:st=d)
208 mv -f $(@:st=dT) $(@:st=d)
210 fopen_max=`sed -n 's/^#define OPEN_MAX //p' $(@:st=hT)`; \
211 filename_max=`sed -n 's/^#define PATH_MAX //p' $(@:st=hT)`; \
212 fopen_max=$${fopen_max:-16}; \
213 filename_max=$${filename_max:-1024}; \
214 sed -e "s/@FOPEN_MAX@/$$fopen_max/" \
215 -e "s/@FILENAME_MAX@/$$filename_max/" \
216 -e "s/@L_tmpnam@/$(L_tmpnam)/" \
217 -e "s/@TMP_MAX@/$(TMP_MAX)/" \
218 -e "s/@L_ctermid@/$(L_ctermid)/" \
219 -e "s/@L_cuserid@/$(L_cuserid)/" \
221 $(move-if-change) $(@:st=h.new) $(@:st=h)
222 # Remove these last so that they can be examined if something went wrong.
223 rm -f $(@:st=hT) $(@:st=dT)
227 -include $(stdio_lim:h=d)
229 common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st