Optimize for kernels which are known to have the vfork syscall.
[glibc/pb-stable.git] / Rules
blobc2b3f790163c352639301f52205d909e3753febe
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
17 # 02111-1307 USA.
20 #       Rules for making a subdirectory in the GNU C library.
21 #       Each subdirectory Makefile defines some variables and includes this.
23 ifneq (,)
24 This makefile requires GNU Make.
25 endif
27 all: # Don't let the default goal come from Makeconfig.
29 include ../Makeconfig
31 ifndef  subdir
32 Each subdirectory makefile must define the `subdir' variable.
33 endif
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.
39 .PHONY: all
40 all: objs lib others
42 ifeq ($(build-programs),yes)
43 others: $(addprefix $(objpfx),$(extra-objs) \
44                               $(install-lib) \
45                               $(install-bin) $(install-bin-script) \
46                               $(install-rootsbin) $(install-sbin))
47 else
48 others: $(addprefix $(objpfx),$(extra-objs) \
49                               $(install-lib))
50 endif
52 ifneq   "$(findstring env,$(origin headers))" ""
53 headers :=
54 endif
56 ifneq   "$(findstring env,$(origin generated))" ""
57 generated :=
58 endif
60 ifneq   "$(findstring env,$(origin common-generated))" ""
61 common-generated :=
62 endif
64 # See below.  This must be set before Makerules processes it.
65 before-compile += $(common-objpfx)bits/stdio_lim.h
67 include ../Makerules
69 .PHONY: subdir_lib
70 subdir_lib: lib-noranlib
72 # Some subdirs need to install a dummy library.
73 # They can use "$(objpfx)libfnord.a: $(dep-dummy-lib); $(make-dummy-lib)".
74 dep-dummy-lib = $(common-objpfx)dummy.o
75 define make-dummy-lib
76 $(AR) cr$(verbose) $@ $<
77 endef
79 $(common-objpfx)dummy.c:
80         rm -f $@
81         (echo 'extern void __dummy__ (void);'; \
82          echo 'void __dummy__ (void) { }') > $@
83 common-generated += dummy.o dummy.c
85 # This makes all the auxiliary and test programs.
87 .PHONY: others tests
88 ifeq ($(build-programs),yes)
89 others: $(addprefix $(objpfx),$(others) $(sysdep-others) $(extra-objs))
90 else
91 others: $(addprefix $(objpfx),$(extra-objs))
92 endif
93 ifeq ($(cross-compiling),yes)
94 tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
95 xtests: tests
96 else
97 ifeq ($(build-bounded),yes)
98 tests-bp.out = $(tests:%=$(objpfx)%-bp.out)
99 xtests-bp.out = $(tests:%=$(objpfx)%-bp.out) $(xtests:%=$(objpfx)%-bp.out)
100 endif
101 tests: $(tests:%=$(objpfx)%.out) $(tests-bp.out)
102 xtests: $(tests:%=$(objpfx)%.out) $(xtests:%=$(objpfx)%.out) $(xtests-bp.out)
103 endif
105 ifeq ($(build-programs),yes)
106 binaries-all = $(others) $(sysdep-others) $(tests) $(xtests) $(test-srcs)
107 binaries-static = $(others-static) $(tests-static)
108 else
109 binaries-all = $(tests) $(xtests) $(test-srcs)
110 binaries-static =
111 endif
113 binaries-shared = $(filter-out $(binaries-static), $(binaries-all))
115 ifneq "$(strip $(binaries-shared))" ""
116 $(addprefix $(objpfx),$(binaries-shared)): %: %.o \
117   $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
118   $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
119         $(+link)
120 endif
122 ifneq "$(strip $(binaries-static))" ""
123 $(addprefix $(objpfx),$(binaries-static)): %: %.o \
124   $(sort $(filter $(common-objpfx)lib%,$(link-libc-static))) \
125   $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
126         $(+link-static)
127 endif
129 ifeq ($(build-bounded),yes)
130 binaries-bounded = $(addsuffix -bp,$(tests) $(xtests) $(test-srcs))
131 $(addprefix $(objpfx),$(binaries-bounded)): %-bp: %.ob \
132   $(sort $(filter $(common-objpfx)lib%,$(link-libc-bounded))) \
133   $(addprefix $(csu-objpfx),start.ob) $(+preinit) $(+postinit)
134         $(+link-bounded)
135 endif
137 ifneq "$(strip $(tests) $(xtests) $(test-srcs))" ""
138 # These are the implicit rules for making test outputs
139 # from the test programs and whatever input files are present.
141 make-test-out = GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
142                 $($*-ENV) $(built-program-cmd) $($*-ARGS)
143 $(objpfx)%-bp.out: %.input $(objpfx)%-bp
144         $(make-test-out) > $@ < $(word 1,$^)
145 $(objpfx)%.out: %.input $(objpfx)%
146         $(make-test-out) > $@ < $(word 1,$^)
147 $(objpfx)%.out: /dev/null $(objpfx)%    # Make it 2nd arg for canned sequence.
148         $(make-test-out) > $@
150 endif   # tests
152 .PHONY: distclean realclean subdir_distclean subdir_realclean \
153         subdir_clean subdir_mostlyclean subdir_testclean
154 subdir_mostlyclean: mostlyclean
155 subdir_clean: clean
156 subdir_distclean: distclean
157 subdir_realclean: realclean
158 subdir_testclean: do-tests-clean
159 realclean: distclean
160 distclean: clean
162 .PHONY: subdir_echo-headers
163 subdir_echo-headers: echo-headers
165 .PHONY: subdir_echo-distinfo
166 subdir_echo-distinfo:
167         @echo $(addprefix +header+,$(headers) $(filter %.h,$(distribute))) \
168               $(addprefix +nodist+,$(generated) $(common-generated) $(dont_distribute))
170 # We want to install everything except the library itself, but update all
171 # our portions of the library because the parent make will install it later
172 # (likewise the stubs file).
173 .PHONY: subdir_install
174 subdir_install: install-no-libc.a lib-noranlib stubs
176 .PHONY: subdir_TAGS subdir_dist
177 subdir_TAGS: TAGS
178 subdir_dist: dist
180 # Target required by the Hurd to ensure that all the MiG-generated
181 # headers are in place before building a subdirectory.
182 .PHONY: before-compile
183 before-compile: $(before-compile)
185 $(common-objpfx)dummy.o: $(common-objpfx)dummy.c $(before-compile);
186         $(compile-command.c)
188 # There's no good place to put this - here will do.
189 # The dependencies are wrong if it's run from the top level.
190 ifeq ($(filter %posix, $(sysdirs)),)
191 L_tmpnam  = 1
192 TMP_MAX   = 0
193 L_ctermid = 1
194 L_cuserid = 1
195 else
196 L_tmpnam  = 20
197 TMP_MAX   = 238328
198 L_ctermid = 9
199 L_cuserid = 9
200 endif
201 stdio_lim = $(common-objpfx)bits/stdio_lim.h
203 $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
204 $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
205                    $(common-objpfx)config.make
206         $(make-target-directory)
207         echo '#include "$(..)posix/bits/posix1_lim.h"' |                \
208         SUNPRO_DEPENDENCIES='$(@:st=dT) $@'                             \
209         $(CC) $(+includes) -E -dM -xc - -o $(@:st=hT)
210         echo '#include "$(..)misc/sys/uio.h"' |                         \
211         SUNPRO_DEPENDENCIES='$(@:st=dT) $@'                             \
212         $(CC) -D_LIBC=1 $(+includes) -E -dM -xc - | cat - >> $(@:st=hT)
213 ifdef sed-remove-objpfx
214         sed $(sed-remove-objpfx) $(@:st=dT) > $(@:st=dt)
215         cat $(@:st=dt) >> $(@:st=d)
216 else
217         cat $(@:st=dT) >> $(@:st=d)
218 endif
219         fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`;       \
220         filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`;    \
221         iov_max=`sed -n 's/^#define UIO_MAXIOV //p' $(@:st=hT)`;        \
222         fopen_max=$${fopen_max:-16};                                    \
223         filename_max=$${filename_max:-1024};                            \
224         if [ -z $$iov_max ]; then                                       \
225           define_iov_max="# undef IOV_MAX";                             \
226         else                                                            \
227           define_iov_max="# define IOV_MAX $$iov_max";                  \
228         fi;                                                             \
229         sed -e "s/@FOPEN_MAX@/$$fopen_max/"                             \
230             -e "s/@FILENAME_MAX@/$$filename_max/"                       \
231             -e "s/@L_tmpnam@/$(L_tmpnam)/"                              \
232             -e "s/@TMP_MAX@/$(TMP_MAX)/"                                \
233             -e "s/@L_ctermid@/$(L_ctermid)/"                            \
234             -e "s/@L_cuserid@/$(L_cuserid)/"                            \
235             -e "s/@define_IOV_MAX@/$$define_iov_max/"                   \
236             $< > $(@:st=h.new)
237         $(move-if-change) $(@:st=h.new) $(@:st=h)
238 # Remove these last so that they can be examined if something went wrong.
239         rm -f $(@:st=hT) $(@:st=dT) $(@:st=dt)
240         touch $@
241 # Get dependencies.
242 ifndef no_deps
243 -include $(stdio_lim:h=d)
244 endif
245 common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st
247 # Local Variables:
248 # mode: makefile
249 # End: