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