Update.
[glibc.git] / Rules
blob3748bb09d05bfb6cea6b66bd746a29ca6f18e31b
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.
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) $(install-bin) \
45                               $(install-rootsbin) $(install-sbin))
46 else
47 others: $(addprefix $(objpfx),$(extra-objs) \
48                               $(install-lib))
49 endif
51 ifneq   "$(findstring env,$(origin headers))" ""
52 headers :=
53 endif
55 ifneq   "$(findstring env,$(origin generated))" ""
56 generated :=
57 endif
59 ifneq   "$(findstring env,$(origin common-generated))" ""
60 common-generated :=
61 endif
63 include ../Makerules
65 .PHONY: subdir_lib
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
71 define make-dummy-lib
72 $(AR) cr$(verbose) $@ $<
73 endef
75 $(common-objpfx)dummy.c:
76         rm -f $@
77         echo 'void __dummy__ (void) { }' > $@
79 # This makes all the auxiliary and test programs.
81 .PHONY: others tests
82 ifeq ($(build-programs),yes)
83 others: $(addprefix $(objpfx),$(others) $(sysdep-others) $(extra-objs))
84 else
85 others: $(addprefix $(objpfx),$(extra-objs))
86 endif
87 ifeq ($(cross-compiling),yes)
88 tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
89 else
90 tests: $(tests:%=$(objpfx)%.out)
91 endif
93 ifeq ($(build-programs),yes)
94 binaries-all = $(others) $(sysdep-others) $(tests) $(test-srcs)
95 binaries-static = $(others-static)
96 else
97 binaries-all = $(tests) $(test-srcs)
98 binaries-static =
99 endif
101 binaries-shared = $(filter-out $(binaries-static), $(binaries-all))
103 ifneq "$(strip $(binaries-shared))" ""
104 $(addprefix $(objpfx),$(binaries-shared)): %: %.o \
105   $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \
106   $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
107         $(+link)
108 endif
110 ifneq "$(strip $(binaries-static))" ""
111 $(addprefix $(objpfx),$(binaries-static)): %: %.o \
112   $(sort $(filter $(common-objpfx)lib%,$(link-libc-static))) \
113   $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
114         $(+link-static)
115 endif
117 ifneq "$(strip $(tests) $(test-srcs))" ""
118 # These are the implicit rules for making test outputs
119 # from the test programs and whatever input files are present.
120 $(objpfx)%.out: %.args $(objpfx)% %.input
121         $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` < $(word 3,$^) > $@
122 $(objpfx)%.out: %.args $(objpfx)%
123         $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` > $@
124 $(objpfx)%.out: %.input $(objpfx)%
125         $($*-ENV) $(built-program-cmd) < $(word 1,$^) > $@
126 $(objpfx)%.out: /dev/null $(objpfx)%    # Make it 2nd arg for canned sequence.
127         $($*-ENV) $(built-program-cmd) > $@
128 endif   # tests
130 .PHONY: distclean realclean subdir_distclean subdir_realclean \
131         subdir_clean subdir_mostlyclean subdir_testclean
132 subdir_mostlyclean: mostlyclean
133 subdir_clean: clean
134 subdir_distclean: distclean
135 subdir_realclean: realclean
136 subdir_testclean: do-tests-clean
137 realclean: distclean
138 distclean: clean
140 .PHONY: subdir_echo-headers
141 subdir_echo-headers: echo-headers
143 .PHONY: subdir_echo-distinfo
144 subdir_echo-distinfo:
145         @echo $(addprefix +header+,$(headers) $(filter %.h,$(distribute))) \
146               $(addprefix +nodist+,$(generated) $(common-generated) $(dont_distribute))
148 # We want to install everything except the library itself, but update all
149 # our portions of the library because the parent make will install it later
150 # (likewise the stubs file).
151 .PHONY: subdir_install
152 subdir_install: install-no-libc.a lib-noranlib stubs
154 .PHONY: subdir_TAGS subdir_dist
155 subdir_TAGS: TAGS
156 subdir_dist: dist
158 # Convenient target to update all the generated source files.
159 .PHONY: generated
160 generated: $(addprefix $(common-objpfx),$(common-generated)) \
161         $(addprefix $(objpfx),$(generated))
163 # Target required by the Hurd to ensure that all the MiG-generated
164 # headers are in place before building a subdirectory.
165 .PHONY: before-compile
166 before-compile: $(before-compile)
168 $(common-objpfx)dummy.o: $(common-objpfx)dummy.c $(before-compile);
169         $(compile-command.c)
171 # There's no good place to put this - here will do.
172 # The dependencies are wrong if it's run from the top level.
173 ifeq ($(filter %posix, $(sysdirs)),)
174 L_tmpnam  = 1
175 TMP_MAX   = 0
176 L_ctermid = 1
177 L_cuserid = 1
178 else
179 L_tmpnam  = 20
180 TMP_MAX   = 238328
181 L_ctermid = 9
182 L_cuserid = 9
183 endif
184 stdio_lim = $(common-objpfx)bits/stdio_lim.h
186 $(stdio_lim:lim.h=%.h) $(stdio_lim:lim.h=%.d): $(stdio_lim:lim.h=%.st); @:
187 $(stdio_lim:h=st): $(..)stdio-common/stdio_lim.h.in $(..)Rules \
188                    $(common-objpfx)config.make
189         $(make-target-directory)
190         echo '#include "$(..)posix/bits/posix1_lim.h"' |                \
191         SUNPRO_DEPENDENCIES='$(@:st=dT) $@'                             \
192         $(CC) $(+includes) -E -dM -xc - -o $(@:st=hT)
193 ifdef sed-remove-objpfx
194         sed $(sed-remove-objpfx) $(@:st=dT) > $(@:st=dt)
195         mv -f $(@:st=dt) $(@:st=d)
196 else
197         mv -f $(@:st=dT) $(@:st=d)
198 endif
199         fopen_max=`sed -n 's/^#define OPEN_MAX //p' $(@:st=hT)`;        \
200         filename_max=`sed -n 's/^#define PATH_MAX //p' $(@:st=hT)`;     \
201         fopen_max=$${fopen_max:-16};                                    \
202         filename_max=$${filename_max:-1024};                            \
203         sed -e "s/@FOPEN_MAX@/$$fopen_max/"                             \
204             -e "s/@FILENAME_MAX@/$$filename_max/"                       \
205             -e "s/@L_tmpnam@/$(L_tmpnam)/"                              \
206             -e "s/@TMP_MAX@/$(TMP_MAX)/"                                \
207             -e "s/@L_ctermid@/$(L_ctermid)/"                            \
208             -e "s/@L_cuserid@/$(L_cuserid)/"                            \
209             $< > $(@:st=h.new)
210         $(move-if-change) $(@:st=h.new) $(@:st=h)
211 # Remove these last so that they can be examined if something went wrong.
212         rm -f $(@:st=hT) $(@:st=dT)
213         touch $@
214 # Get dependencies.
215 ifndef no_deps
216 -include $(stdio_lim:h=d)
217 endif
218 common-generated += bits/stdio_lim.h bits/stdio_lim.d bits/stdio_lim.st