1 # Copyright (C) 1991, 1992, 1993, 1994, 1995 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 # Master Makefile for the GNU C library
23 This makefile requires GNU Make.
27 # This is the default target; it makes everything except the tests.
32 autoconf
$(ACFLAGS
) $< > $@.new
34 test -d CVS
&& cvs commit
-m
'Regenerated: autoconf $(ACFLAGS) $<' $@
37 configure
: configure.in
; $(autoconf-it
)
38 %/configure
: %/configure.in
; $(autoconf-it
)
42 ifndef avoid-generated
43 include $(objpfx
)sysd-dirs
48 sysdep-subdirs
:= $(subst $(\n), ,$(sysdep-subdirs
))
51 # These are the subdirectories containing the library source.
52 subdirs
:= elf csu assert ctype locale math setjmp signal stdio stdlib \
53 malloc string time dirent grp pwd posix io termios resource \
54 socket misc gnulib
$(wildcard crypt
) manual \
56 export subdirs
:= $(subdirs
) # Benign, useless in GNU make before 3.63.
58 # The mach and hurd subdirectories have many generated header files which
59 # the much of rest of the library depends on, so it is best to build them
60 # first (and mach before hurd, at that). The before-compile additions in
61 # sysdeps/{mach,hurd}/Makefile should make it reliably work for these files
62 # not to exist when making in other directories, but it will be slower that
63 # way with more somewhat expensive `make' invocations.
64 subdirs
:= $(filter mach
,$(subdirs
)) $(filter hurd
,$(subdirs
)) \
65 $(filter-out mach hurd
,$(subdirs
))
67 # All initialization source files.
68 +subdir_inits
:= $(wildcard $(foreach dir,$(subdirs
),$(dir)/init-
$(dir).c
))
69 # All subdirectories containing initialization source files.
70 +init_subdirs
:= $(patsubst %/,%,$(dir $(+subdir_inits
)))
73 # These are the targets that are made by making them in each subdirectory.
74 +subdir_targets
:= subdir_lib objects objs others subdir_mostlyclean \
75 subdir_clean subdir_distclean subdir_realclean \
76 tests subdir_lint.out \
77 subdir_echo-headers subdir_echo-distinfo \
78 subdir_install
$(addprefix install-
, \
82 headers
:= features.h errno.h sys
/errno.h errnos.h limits.h
83 aux
= sysdep
$(libc-init
) version
85 echo-headers
: subdir_echo-headers
88 install-others
= $(includedir)/stubs.h
93 libc-init
= munch-init
94 $(objpfx
)munch-init.c
: munch.awk munch-tmpl.c
$(+subdir_inits
)
95 awk
-f
$< subdirs
='$(+init_subdirs)' $(word 2,$^
) > $@
-t
97 generated
:= $(generated
) munch-init.c
103 # Install from subdirectories too.
104 install: subdir_install
106 lib-noranlib
$(libc.a
)(__.SYMDEF
): subdir_lib
109 $(objpfx
)sysd-dirs
: $(+sysdir_pfx
)config.make
110 (echo
define sysdep-subdirs
; \
111 for
dir in
$(sysdirs
); do \
112 if
[ -r
$(sysdep_dir
)/$$dir/Subdirs
]; then \
113 sed
's/#.*$$//' $(sysdep_dir
)/$$dir/Subdirs
; \
120 # Makerules creates a file `stub-$(subdir)' for each subdirectory, which
121 # contains `#define __stub_FUNCTION' for each function which is a stub.
122 # Here we paste all of these together into <stubs.h>.
124 subdir-stubs
:= $(foreach dir,$(subdirs
),$(common-objpfx
)stub-
$(dir))
126 # Since stubs.h is never needed when building the library, we simplify the
127 # hairy installation process by producing it in place only as the last part
128 # of the top-level `make install'. It depends on subdir_install, which
129 # iterates over all the subdirs; subdir_install in each subdir depends on
130 # the subdir's stubs file. Having more direct dependencies would result in
131 # extra iterations over the list for subdirs and many recursive makes.
132 $(includedir)/stubs.h
: subdir_install
133 @
rm -f
$(objpfx
)stubs.h
134 (echo
'/* This file is automatically generated.';\
135 echo
' It defines a symbol `__stub_FUNCTION'\'' for each function';\
136 echo
' in the C library which is a stub, meaning it will fail';\
137 echo
' every time called, usually setting errno to ENOSYS. */';\
138 sort $(subdir-stubs
)) > $(objpfx
)stubs.h
139 $(INSTALL_DATA
) $(objpfx
)stubs.h
$@
140 rm -f
$(objpfx
)stubs.h
142 # This makes the Info or DVI file of the documentation from the Texinfo source.
147 # This makes all the subdirectory targets.
149 # For each target, make it depend on DIR/target for each subdirectory DIR.
150 $(+subdir_targets
): %: $(addsuffix /%,$(subdirs
))
152 # Compute a list of all those targets.
153 all-subdirs-targets
:= $(foreach dir,$(subdirs
),\
154 $(addprefix $(dir)/,$(+subdir_targets
)))
156 # The action for each of those is to cd into the directory and make the
158 $(all-subdirs-targets
):
159 $(MAKE
) -C
$(@D
) $(@F
)
161 .PHONY
: $(+subdir_targets
) $(all-subdirs-targets
)
163 # Targets to clean things up to various degrees.
165 .PHONY
: clean realclean distclean distclean-1 parent-clean parent-mostlyclean
167 # Subroutines of all cleaning targets.
168 parent-mostlyclean
: common-mostlyclean
# common-mostlyclean is in Makerules.
169 -rm -f
$(libc.a
) $(addprefix $(objpfx
),$(install-lib
))
170 parent-clean
: parent-mostlyclean common-clean
171 -rm -f
$(addprefix $(common-objpfx
),$(common-generated
))
172 -rm -f
$(addprefix $(+sysdir_pfx
),sysd-Makefile sysd-dirs sysd-rules
)
175 # This is done this way rather than having `subdir_clean' be a
176 # dependency of this target so that libc.a will be removed before the
177 # subdirectories are dealt with and so they won't try to remove object
178 # files from it when it's going to be removed anyway.
179 @
$(MAKE
) subdir_clean no_deps
=t
180 mostlyclean: parent-mostlyclean
181 @
$(MAKE
) subdir_mostlyclean no_deps
=t
183 # The realclean target is just like distclean for the parent, but we want
184 # the subdirs to know the difference in case they care.
185 realclean distclean: parent-clean
186 # This is done this way rather than having `subdir_distclean' be a
187 # dependency of this target so that libc.a will be removed before the
188 # subdirectories are dealt with and so they won't try to remove object
189 # files from it when it's going to be removed anyway.
190 @
$(MAKE
) distclean-1 no_deps
=t distclean-1
=$@ avoid-generated
=yes
192 # Subroutine of distclean and realclean.
193 distclean-1
: subdir_
$(distclean-1
)
194 -rm -f
$(config-generated
)
195 -rm -f
$(addprefix $(objpfx
),config.status cache.cache
)
196 -rm -f
$(addprefix $(objpfx
),config.make config-name.h
)
198 -rm -f
$(objpfx
)Makefile
200 -rm -f
$(sysdep-
$(distclean-1
))
203 echo_subdirs
:;@echo
'$(subdirs)'
205 .PHONY
: echo-distinfo parent_echo-distinfo
206 echo-distinfo
: parent_echo-distinfo subdir_echo-distinfo
207 parent_echo-distinfo
:
208 @echo
$(addprefix +header
+,$(headers
)) \
209 $(addprefix +nodist
+,$(generated
))
211 # Make the distribution tarfile.
213 distribute
:= README INSTALL NOTES COPYING.LIB COPYING ChangeLog NEWS \
214 Makefile Makeconfig Makerules Rules Make-dist MakeTAGS \
215 ansidecl.h mkinstalldirs move-if-change install-sh \
216 configure configure.in aclocal.m4 config.sub config.guess\
217 config.make.in config-name.in Makefile.in \
218 munch-tmpl.c munch.awk sysdep.h set-hooks.h libc-symbols.h
220 distribute
:= $(strip $(distribute
))
221 generated
:= $(generated
) stubs.h
223 README
: README.template version.c
; # Make-dist should update README.
227 makeinfo --no-validate
--no-warn
--no-headers
$< -o
$@
230 INSTALL
: manual
/maint.texi
; $(format-me
)
231 NOTES
: manual
/creature.texi
; $(format-me
)