1 # Copyright (C) 1991-2000, 2002 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 Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the 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 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, write to the Free
16 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
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) \
45 $(install-bin) $(install-bin-script) \
46 $(install-rootsbin) $(install-sbin))
48 others: $(addprefix $(objpfx),$(extra-objs) \
52 ifneq "$(findstring env,$(origin headers))" ""
56 ifneq "$(findstring env,$(origin generated))" ""
60 ifneq "$(findstring env,$(origin common-generated))" ""
67 subdir_lib: lib-noranlib
69 # Some subdirs need to install a dummy library.
70 # They can use "$(objpfx)libfnord.a: $(dep-dummy-lib); $(make-dummy-lib)".
71 dep-dummy-lib = $(common-objpfx)dummy.o
73 $(AR) cr$(verbose) $@ $<
76 $(common-objpfx)dummy.c:
78 (echo 'extern void __dummy__ (void);'; \
79 echo 'void __dummy__ (void) { }') > $@
80 common-generated += dummy.o dummy.c
82 # This makes all the auxiliary and test programs.
85 ifeq ($(build-programs),yes)
86 others: $(addprefix $(objpfx),$(others) $(sysdep-others) $(extra-objs))
88 others: $(addprefix $(objpfx),$(extra-objs))
90 ifeq ($(cross-compiling),yes)
91 tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
94 ifeq ($(build-bounded),yes)
95 tests-bp.out = $(tests:%=$(objpfx)%-bp.out)
96 xtests-bp.out = $(tests:%=$(objpfx)%-bp.out) $(xtests:%=$(objpfx)%-bp.out)
98 tests: $(tests:%=$(objpfx)%.out) $(tests-bp.out)
99 xtests: $(tests:%=$(objpfx)%.out) $(xtests:%=$(objpfx)%.out) $(xtests-bp.out)
102 ifeq ($(build-programs),yes)
103 binaries-all = $(others) $(sysdep-others) $(tests) $(xtests) $(test-srcs)
104 binaries-static = $(others-static) $(tests-static)
106 binaries-all = $(tests) $(xtests) $(test-srcs)
110 binaries-shared = $(filter-out $(binaries-static), $(binaries-all))
112 ifneq "$(strip $(binaries-shared))" ""
113 $(addprefix $(objpfx),$(binaries-shared)): %: %.o \
114 $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
115 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
119 ifneq "$(strip $(binaries-static))" ""
120 $(addprefix $(objpfx),$(binaries-static)): %: %.o \
121 $(sort $(filter $(common-objpfx)lib%,$(link-libc-static))) \
122 $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
126 ifeq ($(build-bounded),yes)
127 binaries-bounded = $(addsuffix -bp,$(tests) $(xtests) $(test-srcs))
128 $(addprefix $(objpfx),$(binaries-bounded)): %-bp: %.ob \
129 $(sort $(filter $(common-objpfx)lib%,$(link-libc-bounded))) \
130 $(addprefix $(csu-objpfx),start.ob) $(+preinit) $(+postinit)
134 ifneq "$(strip $(tests) $(xtests) $(test-srcs))" ""
135 # These are the implicit rules for making test outputs
136 # from the test programs and whatever input files are present.
138 make-test-out = GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
139 $($*-ENV) $(built-program-cmd) $($*-ARGS)
140 $(objpfx)%-bp.out: %.input $(objpfx)%-bp
141 $(make-test-out) > $@ < $(word 1,$^)
142 $(objpfx)%.out: %.input $(objpfx)%
143 $(make-test-out) > $@ < $(word 1,$^)
144 $(objpfx)%.out: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
145 $(make-test-out) > $@
149 .PHONY: distclean realclean subdir_distclean subdir_realclean \
150 subdir_clean subdir_mostlyclean subdir_testclean
151 subdir_mostlyclean: mostlyclean
153 subdir_distclean: distclean
154 subdir_realclean: realclean
155 subdir_testclean: do-tests-clean
159 .PHONY: subdir_echo-headers
160 subdir_echo-headers: echo-headers
162 .PHONY: subdir_echo-distinfo
163 subdir_echo-distinfo:
164 @echo $(addprefix +header+,$(headers) $(filter %.h,$(distribute))) \
165 $(addprefix +nodist+,$(generated) $(common-generated) $(dont_distribute))
167 # We want to install everything except the library itself, but update all
168 # our portions of the library because the parent make will install it later
169 # (likewise the stubs file).
170 .PHONY: subdir_install
171 subdir_install: install-no-libc.a lib-noranlib stubs
173 .PHONY: subdir_TAGS subdir_dist
177 # Convenient target to update all the generated source files.
179 generated: $(addprefix $(common-objpfx),$(common-generated)) \
180 $(addprefix $(objpfx),$(generated))
182 # Target required by the Hurd to ensure that all the MiG-generated
183 # headers are in place before building a subdirectory.
184 .PHONY: before-compile
185 before-compile: $(before-compile)
187 $(common-objpfx)dummy.o: $(common-objpfx)dummy.c $(before-compile);
190 # There's no good place to put this - here will do.
191 # The dependencies are wrong if it's run from the top level.
192 ifeq ($(filter %posix, $(sysdirs)),)
203 stdio_lim = $(common-objpfx)bits/stdio_lim.h
205 $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
206 $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
207 $(common-objpfx)config.make
208 $(make-target-directory)
209 echo '#include "$(..)posix/bits/posix1_lim.h"' | \
210 SUNPRO_DEPENDENCIES='$(@:st=dT) $@' \
211 $(CC) $(+includes) -E -dM -xc - -o $(@:st=hT)
212 echo '#include "$(..)misc/sys/uio.h"' | \
213 SUNPRO_DEPENDENCIES='$(@:st=dT) $@' \
214 $(CC) -D_LIBC=1 $(+includes) -E -dM -xc - | cat - >> $(@:st=hT)
215 ifdef sed-remove-objpfx
216 sed $(sed-remove-objpfx) $(@:st=dT) > $(@:st=dt)
217 cat $(@:st=dt) >> $(@:st=d)
219 cat $(@:st=dT) >> $(@:st=d)
221 fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`; \
222 filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`; \
223 iov_max=`sed -n 's/^#define UIO_MAXIOV //p' $(@:st=hT)`; \
224 fopen_max=$${fopen_max:-16}; \
225 filename_max=$${filename_max:-1024}; \
226 if [ -z $$iov_max ]; then \
227 define_iov_max="# undef IOV_MAX"; \
229 define_iov_max="# define IOV_MAX $$iov_max"; \
231 sed -e "s/@FOPEN_MAX@/$$fopen_max/" \
232 -e "s/@FILENAME_MAX@/$$filename_max/" \
233 -e "s/@L_tmpnam@/$(L_tmpnam)/" \
234 -e "s/@TMP_MAX@/$(TMP_MAX)/" \
235 -e "s/@L_ctermid@/$(L_ctermid)/" \
236 -e "s/@L_cuserid@/$(L_cuserid)/" \
237 -e "s/@define_IOV_MAX@/$$define_iov_max/" \
239 $(move-if-change) $(@:st=h.new) $(@:st=h)
240 # Remove these last so that they can be examined if something went wrong.
241 rm -f $(@:st=hT) $(@:st=dT) $(@:st=dt)
245 -include $(stdio_lim:h=d)
247 common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st