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 override CPPFLAGS := $(strip $(filter-out $(+sysdep-includes),$(CPPFLAGS)) \
105 # Include any system-specific makefiles.
107 ifeq ($(wildcard $(+sysdir_pfx)sysd-Makefile),)
108 # Don't do deps until this exists, because it might change the sources list.
112 include $(+sysdir_pfx)sysd-Makefile
113 $(+sysdir_pfx)sysd-Makefile: $(+sysdir_pfx)sysdirs
114 (for dir in `cat $<`; do \
115 file=sysdeps/$$dir/Makefile; \
116 if [ -r $(..)$$file ]; then \
117 echo include "\$$(..)$$file"; \
123 # Include the generated dependencies of the sources in this directory.
124 include $(objpfx)depend-$(subdir)
127 # Maximize efficiency by minimizing the number of rules.
128 .SUFFIXES: # Clear the suffix list.
129 # Remove the RCS and SCCS rules.
135 # Add the suffixes we use.
136 .SUFFIXES: .a .o .S .s .c .h .dep .m4
138 # Generic rule for making directories.
140 # mkdir isn't smart enough to strip a trailing /.
143 # Make sure that object files are not removed
144 # when they are intermediates between sources and library members.
145 # This can go away with make v4.
148 # Make sure that the parent library archive is never removed.
151 # Use the verbose option of ar and tar when not running silently.
152 ifeq "$(findstring s,$(MAKEFLAGS))" "" # if not -s
158 ARFLAGS := r$(verbose)
160 # Figure out the source filenames in this directory.
162 override sources := $(addsuffix .c,$(routines) $(aux) \
164 export sysdep_routines := $(sysdep_routines)
166 # This is the list of all object files, gotten by
167 # replacing every ".c" in `sources' with a ".o".
168 override objects := $(addprefix $(objpfx),$(sources:.c=.o))
170 # The order of these rules is important.
172 ifndef .S-rule # Bletch.
173 $(objpfx)%.o: %.S $(before-compile)
174 $(compile.S) $(OUTPUT_OPTION)
176 $(objpfx)%.o: %.s $(before-compile)
177 $(COMPILE.s) $< $(OUTPUT_OPTION)
178 $(objpfx)%.o: %.c $(before-compile)
179 $(compile.c) $(OUTPUT_OPTION)
181 ifeq ($(notdir $(firstword $(CC))),gcc)
182 # GCC can grok options after the file name.
183 compile.S = $(CC) $< -c $(CPPFLAGS) $(asm-CPPFLAGS)
184 compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)
186 compile.S = $(COMPILE.S) $(asm-CPPFLAGS) $<
187 compile.c = $(COMPILE.c) $<
192 # We need this for the output to go in the right place. It will default to
193 # empty if make was configured to work with a cc that can't grok -c and -o
194 # together. You can't compile the C library with such a compiler.
195 OUTPUT_OPTION = -o $@
199 # This makes all the object files in the parent library archive.
201 .PHONY: lib libobjs lib-noranlib
206 +libobjs := $(patsubst %,$(libc.a)(%),$(notdir $(objects)))
208 $(+libobjs): $(libc.a)(%): $(objpfx)%;
211 lib-noranlib: libobjs ar-it
213 #$(libc.a): %: $(addprefix %,$(patsubst $(objpfx)%,(%),$(objects)))
214 # $(AR) $(ARFLAGS) $@ $(patsubst $@(%),%,$?)
216 define +libc_lock_open
217 @. $(..)libc-lock-open
219 define +libc_lock_close
220 @rm -f $(..)LOCK-libc.a
223 # Temporary until I get a better solution.
228 cd $(objdir); $(AR) ru$(verbose) libc.a $(patsubst $(objpfx)%,%,$^)
230 $(AR) ru$(verbose) $(..)libc.a $^
232 # $(+libc_lock_close)
236 # This makes all the object files.
238 objects objs: $(objects)
242 # install-lib are installed from the object directory into $(libdir).
243 # install-data are installed as they are into $(datadir). headers are
244 # installed as they are in $(includedir). install-others are absolute path
245 # names of files to install; rules to install them are defined elsewhere.
247 do-install = $(INSTALL_DATA) $< $@
250 $(addprefix $(bindir)/,$(install)): $(bindir)/%: $(objpfx)%
254 $(addprefix $(libdir)/,$(install-lib)): $(libdir)/%: $(objpfx)%;$(do-install)
257 $(addprefix $(datadir)/,$(install-data)): $(datadir)/%: %;$(do-install)
259 +install := $(addprefix $(libdir)/,$(install-lib)) \
260 $(addprefix $(datadir)/,$(install-data)) \
261 $(addprefix $(bindir)/,$(install)) \
263 headers := $(strip $(headers))
265 $(addprefix $(includedir)/,$(headers)): \
266 $(includedir)/%: %;$(do-install)
267 +install := $(+install) $(addprefix $(includedir)/,$(headers))
269 +install := $(filter-out $(addprefix %/,$(no-install)),$(+install))
271 +install-dirs := $(dir $(+install))
272 # Get two levels of directories so $(datadir)/zoneinfo wins.
273 +install-dirs := $(+install-dirs) $(filter-out ./,$(dir $(+install-dirs)))
274 # Sort them so containing dirs are guaranteed to come first.
275 +install-dirs := $(sort $(+install-dirs))
278 install: $(+install-dirs) $(+install)
280 S-CPPFLAGS = $(asm-CPPFLAGS)
281 +make-deps = $(+mkdep) $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) $< | \
282 sed 's,$*\.o,$(@:.dep=.o) $@,' > $@
284 # N.B.: The order of these two rules is important.
285 $(objpfx)%.dep: %.S $(before-compile)
287 $(objpfx)%.dep: %.c $(before-compile)
290 +depfiles := $(strip $(sources:.c=.dep) $(addsuffix .dep,$(others) $(tests)))
291 +depfiles := $(addprefix $(objpfx),$(+depfiles))
292 $(objpfx)depend-$(subdir): Makefile
294 (for file in $(patsubst $(objpfx)%,%,$(+depfiles)); do \
295 echo "include $(objpfx)$$file"; \
301 # Command to compile $< in $(objdir) using the native libraries.
302 native-compile = cwd=`pwd`; cd $(@D); $(CC) $$cwd/$< -o $(@F)
304 # Command to compile $< in $(common-objdir) using the native libraries.
305 define common-objdir-compile
306 cd $(@D); $(CC) $(<:$(common-objpfx)%=%) -o $(@F)
309 # Support the GNU standard name for this target.
323 ifneq (,$(wildcard /home/gd/gnu/lib/ChangeLog))
324 # Snarf from the master source and frob the copying notice.
325 $(gpl2lgpl): %: $(..)gpl2lgpl.sed /home/gd/gnu/lib/%