1 # Copyright (C) 1991, 1992 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
16 # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 # Cambridge, MA 02139, USA.
20 # Propagated rules for making the GNU C library.
23 This makefile requires GNU Make.
31 # If `sources' was defined by the parent makefile, undefine it so
32 # we will later get it from wildcard search in this directory.
33 ifneq "$(findstring env,$(origin sources))" ""
37 headers := $(headers) $(sysdep_headers)
39 # This is benign and useless in GNU make before version 3.63.
40 export sources := $(sources)
41 export headers := $(headers)
43 ifneq ($(findstring e,$(MAKEFLAGS)),)
44 You must not use the -e flag when building the GNU C library.
47 ifndef +included-Makeconfig
48 include $(..)Makeconfig
51 # In make v4, we'll be able to really do this right (or something like that).
53 up-one = $(patsubst %/,%,$(dir $0))
54 parents-of = $(foreach x,$0,$(notdir $x) \
55 $(ifeq $(dir $x),./,$(parents-of $(up-one $x))))
56 # Finish this someday....
59 +sysdir_pfx = $(common-objpfx)
61 # Right now, however, we do it with shell scripts and lots of strangeness.
62 sysdep_dir := $(..)sysdeps
64 include $(+sysdir_pfx)sysdirs
69 sysdirs := $(subst $(\n), ,$(sysdirs))
71 $(+sysdir_pfx)sysdirs: $(+sysdir_pfx)Sysnames $(..)find-sysdirs
72 (echo define sysdirs; \
73 sysdep_dir=$(sysdep_dir) \
74 $(dir $(word 2,$^))$(notdir $(word 2,$^)) < $<; \
76 $(+sysdir_pfx)Sysnames:
77 @(echo The GNU C Library has not been configured! ;\
78 echo Run \`configure\' to configure it before building.\
80 export sysdirs := $(sysdirs)
81 export sysdep_dir := $(sysdep_dir)
83 # Turn the list of sysdep names into a colon-separated list of directories
84 # under SYSDEP_DIR (the base directory for sysdep files), and tell Make to
85 # search for C and header files in those directories.
86 +sysdep_dirs := $(addprefix $(sysdep_dir)/,$(sysdirs))
88 +sysdep_dirs := $(objdir) $(+sysdep_dirs)
90 sysdep_path := $(subst $+ ,:,$(+sysdep_dirs))
92 override VPATH := $(sysdep_path)
94 vpath %.c $(sysdep_path)
95 vpath %.S $(sysdep_path)
96 vpath %.s $(sysdep_path)
97 vpath %.h $(sysdep_path)
100 # Add -I switches to get the right sysdep directories.
101 +sysdep-includes := $(addprefix -I,$(+sysdep_dirs))
102 +includes := $(+includes) $(+sysdep-includes)
104 # Include any system-specific makefiles.
106 ifeq ($(wildcard $(+sysdir_pfx)sysd-Makefile),)
107 # Don't do deps until this exists, because it might change the sources list.
111 include $(+sysdir_pfx)sysd-Makefile
112 $(+sysdir_pfx)sysd-Makefile: $(+sysdir_pfx)sysdirs
113 (for dir in `cat $<`; do \
114 file=sysdeps/$$dir/Makefile; \
115 if [ -r $(..)$$file ]; then \
116 echo include "\$$(..)$$file"; \
121 # Maximize efficiency by minimizing the number of rules.
122 .SUFFIXES: # Clear the suffix list.
123 # Add the suffixes we use.
124 .SUFFIXES: .a .o .S .s .c .h .dep .m4
126 # Generic rule for making directories.
128 # mkdir isn't smart enough to strip a trailing /.
131 # Make sure that object files are not removed
132 # when they are intermediates between sources and library members.
133 # This can go away with make v4.
136 # Make sure that the parent library archive is never removed.
139 # Use the verbose option of ar and tar when not running silently.
140 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
146 ARFLAGS := r$(verbose)
148 # Figure out the source filenames in this directory.
150 override sources := $(addsuffix .c,$(routines) $(aux) \
152 export sysdep_routines := $(sysdep_routines)
154 # This is the list of all object files, gotten by
155 # replacing every ".c" in `sources' with a ".o".
156 override objects := $(addprefix $(objpfx),$(sources:.c=.o))
158 # The order of these rules is important.
160 ifndef .S-rule # Bletch.
161 $(objpfx)%.o: %.S $(before-compile)
162 $(compile.S) $(OUTPUT_OPTION)
164 $(objpfx)%.o: %.s $(before-compile)
165 $(COMPILE.s) $< $(OUTPUT_OPTION)
166 $(objpfx)%.o: %.c $(before-compile)
167 $(compile.c) $(OUTPUT_OPTION)
169 ifeq ($(notdir $(firstword $(CC))),gcc)
170 # GCC can grok options after the file name.
171 compile.S = $(CC) $< -c $(CPPFLAGS) $(asm-CPPFLAGS)
172 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
174 compile.S = $(COMPILE.S) $(asm-CPPFLAGS) $<
175 compile.c = $(COMPILE.c) $<
180 # We need this for the output to go in the right place. It will default to
181 # empty if make was configured to work with a cc that can't grok -c and -o
182 # together. You can't compile the C library with such a compiler.
183 OUTPUT_OPTION = -o $@
187 # This makes all the object files in the parent library archive.
189 .PHONY: lib libobjs lib-noranlib
194 +libobjs := $(patsubst %,$(libc.a)(%),$(notdir $(objects)))
196 $(+libobjs): $(libc.a)(%): $(objpfx)%;
199 lib-noranlib: libobjs ar-it
201 #$(libc.a): %: $(addprefix %,$(patsubst $(objpfx)%,(%),$(objects)))
202 # $(AR) $(ARFLAGS) $@ $(patsubst $@(%),%,$?)
204 define +libc_lock_open
205 @. $(..)libc-lock-open
207 define +libc_lock_close
208 @rm -f $(..)LOCK-libc.a
211 # Temporary until I get a better solution.
217 cd $(objdir); $(AR) ru$(verbose) libc.a $(patsubst $(objpfx)%,%,$^)
219 $(AR) ru$(verbose) $(..)libc.a $^
221 # $(+libc_lock_close)
226 # This makes all the object files.
228 objects objs: $(objects)
232 # install-lib are installed from the object directory into $(libdir).
233 # install-data are installed as they are into $(datadir). headers are
234 # installed as they are in $(includedir). install-others are absolute path
235 # names of files to install; rules to install them are defined elsewhere.
237 do-install = $(INSTALL_DATA) $< $@
239 # Any directory (parent or subdir) that has any object files to build
240 # should install libc.a; this way "make install" in a subdir is guaranteed
241 # to install everything it changes.
243 install-lib := $(install-lib) libc.a
247 $(addprefix $(bindir)/,$(install)): $(bindir)/%: $(objpfx)%
251 $(addprefix $(libdir)/,$(install-lib)): $(libdir)/%: $(objpfx)%;$(do-install)
254 $(addprefix $(datadir)/,$(install-data)): $(datadir)/%: %;$(do-install)
256 +install := $(addprefix $(libdir)/,$(install-lib)) \
257 $(addprefix $(datadir)/,$(install-data)) \
258 $(addprefix $(bindir)/,$(install)) \
260 headers := $(strip $(headers))
262 $(addprefix $(includedir)/,$(headers)): \
263 $(includedir)/%: %;$(do-install)
264 +install := $(+install) $(addprefix $(includedir)/,$(headers))
266 +install := $(filter-out $(addprefix %/,$(no-install)),$(+install))
268 +install-dirs := $(dir $(+install))
269 # Get two levels of directories so $(datadir)/zoneinfo wins.
270 +install-dirs := $(+install-dirs) $(filter-out ./,$(dir $(+install-dirs)))
271 # Sort them so containing dirs are guaranteed to come first.
272 +install-dirs := $(sort $(+install-dirs))
275 install: $(+install-dirs) $(+install)
277 S-CPPFLAGS = $(asm-CPPFLAGS)
278 +make-deps = $(+mkdep) $< $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | \
279 sed 's,$*\.o,$(@:.dep=.o) $@,' > $@
281 # N.B.: The order of these two rules is important.
282 $(objpfx)%.dep: %.S $(before-compile)
284 $(objpfx)%.dep: %.c $(before-compile)
287 +depfiles := $(strip $(sources:.c=.dep) $(addsuffix .dep,$(others) $(tests)))
288 +depfiles := $(addprefix $(objpfx),$(+depfiles))
290 $(objpfx)depend-$(subdir): Makefile
292 (for file in $(patsubst $(objpfx)%,%,$(+depfiles)); do \
293 echo "include $(objpfx)$$file"; \
300 # Include the generated dependencies of the sources in this directory.
301 ifdef have.make.that.groks.multiple.includes
302 # Avoid the extra file and waiting for it, since we can.
303 +depfiles := $(strip $(+depfiles))
308 include $(objpfx)depend-$(subdir)
312 # Command to compile $< in $(objdir) using the native libraries.
313 native-compile = cwd=`pwd`; cd $(@D); $(CC) $(native-CFLAGS) $$cwd/$< -o $(@F)
315 # Command to compile $< in $(common-objdir) using the native libraries.
316 define common-objdir-compile
317 cd $(@D); $(CC) $(native-CFLAGS) $(<:$(common-objpfx)%=%) -o $(@F)
320 # We always want to use configuration -D switches.
321 native-CFLAGS = $(config-defines)
323 # Support the GNU standard name for this target.
337 ifneq (,$(wildcard /home/gd/gnu/lib/ChangeLog))
338 # Snarf from the master source and frob the copying notice.
339 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%
341 # So I don't edit them my mistake.