Update.
[glibc.git] / Rules
blob2353cc34a0df5bc86c2ffe122c53ff530dee9714
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.
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) { }' > $@
78 $(common-objpfx)empty.c:
79         cp -f /dev/null $@
80 common-generated += dummy.o dummy.c empty.c \
81                     $(addprefix empty,$(object-suffixes))
83 # This makes all the auxiliary and test programs.
85 .PHONY: others tests
86 ifeq ($(build-programs),yes)
87 others: $(addprefix $(objpfx),$(others) $(sysdep-others) $(extra-objs))
88 else
89 others: $(addprefix $(objpfx),$(extra-objs))
90 endif
91 ifeq ($(cross-compiling),yes)
92 tests: $(addprefix $(objpfx),$(tests) $(tests-static) $(test-srcs))
93 else
94 ifneq (($build-static),yes)
95 tests: $(tests:%=$(objpfx)%.out)
96 else
97 tests: $(tests:%=$(objpfx)%.out) $(tests-static:%=$(objpfx)%.sout)
98 endif
99 endif
101 ifeq ($(build-programs),yes)
102 binaries-all = $(others) $(sysdep-others) $(tests) $(test-srcs)
103 binaries-static = $(others-static) $(tests-static) $(test-srcs-static)
104 else
105 binaries-all = $(tests) $(test-srcs)
106 binaries-static = $(tests-static) $(test-srcs-static)
107 endif
109 binaries-shared = $(filter-out $(binaries-static), $(binaries-all))
111 ifneq "$(strip $(binaries-shared))" ""
112 $(addprefix $(objpfx),$(binaries-shared)): %: %.o \
113   $(sort $(filter $(common-objpfx)libc%,$(link-libc))) \
114   $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
115         $(+link)
116 endif
118 ifneq "$(strip $(binaries-static))" ""
119 $(addprefix $(objpfx),$(binaries-static)): %: %.o \
120   $(sort $(filter $(common-objpfx)libc%,$(link-libc-static))) \
121   $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
122         $(+link-static)
123 endif
125 ifneq "$(strip $(tests) $(test-srcs))" ""
126 # These are the implicit rules for making test outputs
127 # from the test programs and whatever input files are present.
128 $(objpfx)%.out: %.args $(objpfx)% %.input
129         $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` < $(word 3,$^) > $@
130 $(objpfx)%.out: %.args $(objpfx)%
131         $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` > $@
132 $(objpfx)%.out: %.input $(objpfx)%
133         $($*-ENV) $(built-program-cmd) < $(word 1,$^) > $@
134 $(objpfx)%.out: /dev/null $(objpfx)%    # Make it 2nd arg for canned sequence.
135         $($*-ENV) $(built-program-cmd) > $@
136 endif   # tests
138 ifneq "$(strip $(tests-static) $(test-static-srcs))" ""
139 # These are the implicit rules for making test outputs
140 # from the test programs and whatever input files are present.
141 $(objpfx)%.sout: %.args $(objpfx)% %.input
142         $($*-ENV) $(built-program-file) `cat $(word 1,$^)` < $(word 3,$^) > $@
143 $(objpfx)%.sout: %.args $(objpfx)%
144         $($*-ENV) $(built-program-file) `cat $(word 1,$^)` > $@
145 $(objpfx)%.sout: %.input $(objpfx)%
146         $($*-ENV) $(built-program-file) < $(word 1,$^) > $@
147 $(objpfx)%.sout: /dev/null $(objpfx)%   # Make it 2nd arg for canned sequence.
148         $($*-ENV) $(built-program-file) > $@
149 endif   # tests
151 .PHONY: distclean realclean subdir_distclean subdir_realclean \
152         subdir_clean subdir_mostlyclean
153 subdir_mostlyclean: mostlyclean
154 subdir_clean: clean
155 subdir_distclean: distclean
156 subdir_realclean: realclean
157 realclean: distclean
158 distclean: clean
160 .PHONY: subdir_echo-headers
161 subdir_echo-headers: echo-headers
163 .PHONY: subdir_echo-distinfo
164 subdir_echo-distinfo:
165         @echo $(addprefix +header+,$(headers) $(filter %.h,$(distribute))) \
166               $(addprefix +nodist+,$(generated) $(common-generated) $(dont_distribute))
168 # We want to install everything except the library itself, but update all
169 # our portions of the library because the parent make will install it later
170 # (likewise the stubs file).
171 .PHONY: subdir_install
172 subdir_install: install-no-libc.a lib-noranlib stubs
174 .PHONY: subdir_TAGS subdir_dist
175 subdir_TAGS: TAGS
176 subdir_dist: dist
178 # Convenient target to update all the generated source files.
179 .PHONY: generated
180 generated: $(addprefix $(common-objpfx),$(common-generated)) \
181         $(addprefix $(objpfx),$(generated))
183 # Target required by the Hurd to ensure that all the MiG-generated
184 # headers are in place before building a subdirectory.
185 .PHONY: before-compile
186 before-compile: $(before-compile)
188 define o-iterator-doit
189 $(common-objpfx)empty$o: $(common-objpfx)empty.c $(before-compile);
190         $$(compile-command.c)
191 endef
192 object-suffixes-left := $(object-suffixes)
193 include $(o-iterator)
195 define o-iterator-doit
196 $(common-objpfx)dummy$o: $(common-objpfx)dummy.c $(before-compile);
197         $$(compile-command.c)
198 endef
199 object-suffixes-left := $(object-suffixes)
200 include $(o-iterator)