]> git.ipfire.org Git - thirdparty/glibc.git/blame - Makefile
Wed May 17 16:50:21 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
[thirdparty/glibc.git] / Makefile
CommitLineData
28f540f4
RM
1# Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
2# This file is part of the GNU C Library.
3
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.
8
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.
13
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.
18
19#
20# Master Makefile for the GNU C library
21#
22ifneq (,)
23This makefile requires GNU Make.
24endif
25
26
27# This is the default target; it makes everything except the tests.
28.PHONY: all
29all: lib others
30\f
31define autoconf-it
32autoconf $(ACFLAGS) $< > $@.new
33mv -f $@.new $@
34test -d CVS && cvs commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
35endef
36
37configure: configure.in; $(autoconf-it)
38%/configure: %/configure.in; $(autoconf-it)
39
40include Makeconfig
41
42ifndef avoid-generated
43include $(objpfx)sysd-dirs
44define \n
45
46
47endef
48sysdep-subdirs := $(subst $(\n), ,$(sysdep-subdirs))
49endif
50
51# These are the subdirectories containing the library source.
a38f13ba 52subdirs := csu assert ctype locale math setjmp signal stdio stdlib \
41d43dbc
RM
53 malloc string time dirent grp pwd posix io termios resource \
54 socket misc gnulib $(wildcard crypt) manual \
a38f13ba 55 $(sysdep-subdirs) elf
28f540f4
RM
56export subdirs := $(subdirs) # Benign, useless in GNU make before 3.63.
57
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.
64subdirs := $(filter mach,$(subdirs)) $(filter hurd,$(subdirs)) \
65 $(filter-out mach hurd,$(subdirs))
66
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)))
71
72
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-, \
79 no-libc.a bin lib \
80 data headers others)
81\f
37f91d33 82headers := features.h errno.h sys/errno.h errnos.h limits.h
28f540f4
RM
83aux = sysdep $(libc-init) version
84
85echo-headers: subdir_echo-headers
86
87# What to install.
88install-others = $(includedir)/stubs.h
89
90ifeq (yes,$(gnu-ld))
91libc-init = set-init
92else
93libc-init = munch-init
94$(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits)
95 awk -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t
96 mv -f $@-t $@
97generated := $(generated) munch-init.c
98endif
99
100
101include Makerules
102
103# Install from subdirectories too.
104install: subdir_install
105
01a36ad3
RM
106# Build subdirectory lib objects.
107lib-noranlib: subdir_lib
28f540f4 108
01a36ad3
RM
109ifeq (yes,$(build-shared))
110# Build the shared object from the PIC object library.
111lib: $(common-objpfx)libc.so
112endif
28f540f4
RM
113
114$(objpfx)sysd-dirs: $(+sysdir_pfx)config.make
115 (echo define sysdep-subdirs; \
116 for dir in $(sysdirs); do \
117 if [ -r $(sysdep_dir)/$$dir/Subdirs ]; then \
118 sed 's/#.*$$//' $(sysdep_dir)/$$dir/Subdirs; \
119 else true; \
120 fi; \
121 done; \
122 echo endef) > $@-tmp
123 mv -f $@-tmp $@
124\f
125# Makerules creates a file `stub-$(subdir)' for each subdirectory, which
126# contains `#define __stub_FUNCTION' for each function which is a stub.
127# Here we paste all of these together into <stubs.h>.
128
129subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)stub-$(dir))
130
131# Since stubs.h is never needed when building the library, we simplify the
132# hairy installation process by producing it in place only as the last part
133# of the top-level `make install'. It depends on subdir_install, which
134# iterates over all the subdirs; subdir_install in each subdir depends on
135# the subdir's stubs file. Having more direct dependencies would result in
136# extra iterations over the list for subdirs and many recursive makes.
137$(includedir)/stubs.h: subdir_install
138 @rm -f $(objpfx)stubs.h
139 (echo '/* This file is automatically generated.';\
140 echo ' It defines a symbol `__stub_FUNCTION'\'' for each function';\
141 echo ' in the C library which is a stub, meaning it will fail';\
142 echo ' every time called, usually setting errno to ENOSYS. */';\
143 sort $(subdir-stubs)) > $(objpfx)stubs.h
144 $(INSTALL_DATA) $(objpfx)stubs.h $@
145 rm -f $(objpfx)stubs.h
146\f
147# This makes the Info or DVI file of the documentation from the Texinfo source.
148.PHONY: info dvi
149info dvi:
150 $(MAKE) -C manual $@
151\f
152# This makes all the subdirectory targets.
153
154# For each target, make it depend on DIR/target for each subdirectory DIR.
155$(+subdir_targets): %: $(addsuffix /%,$(subdirs))
156
157# Compute a list of all those targets.
158all-subdirs-targets := $(foreach dir,$(subdirs),\
159 $(addprefix $(dir)/,$(+subdir_targets)))
160
161# The action for each of those is to cd into the directory and make the
162# target there.
163$(all-subdirs-targets):
164 $(MAKE) -C $(@D) $(@F)
165
166.PHONY: $(+subdir_targets) $(all-subdirs-targets)
167\f
168# Targets to clean things up to various degrees.
169
170.PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean
171
172# Subroutines of all cleaning targets.
173parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
6bf02878 174 -rm -f $(common-objpfx)libc.a $(addprefix $(objpfx),$(install-lib))
28f540f4
RM
175parent-clean: parent-mostlyclean common-clean
176 -rm -f $(addprefix $(common-objpfx),$(common-generated))
6bf02878 177 -rm -f $(addprefix $(objpfx),sysd-Makefile sysd-dirs sysd-rules)
28f540f4
RM
178
179clean: parent-clean
180# This is done this way rather than having `subdir_clean' be a
181# dependency of this target so that libc.a will be removed before the
182# subdirectories are dealt with and so they won't try to remove object
183# files from it when it's going to be removed anyway.
184 @$(MAKE) subdir_clean no_deps=t
185mostlyclean: parent-mostlyclean
186 @$(MAKE) subdir_mostlyclean no_deps=t
187
188# The realclean target is just like distclean for the parent, but we want
189# the subdirs to know the difference in case they care.
190realclean distclean: parent-clean
191# This is done this way rather than having `subdir_distclean' be a
192# dependency of this target so that libc.a will be removed before the
193# subdirectories are dealt with and so they won't try to remove object
194# files from it when it's going to be removed anyway.
195 @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes
196
197# Subroutine of distclean and realclean.
198distclean-1: subdir_$(distclean-1)
199 -rm -f $(config-generated)
200 -rm -f $(addprefix $(objpfx),config.status cache.cache)
201 -rm -f $(addprefix $(objpfx),config.make config-name.h)
202ifdef objdir
203 -rm -f $(objpfx)Makefile
204endif
205 -rm -f $(sysdep-$(distclean-1))
206\f
207.PHONY: echo_subdirs
208echo_subdirs:;@echo '$(subdirs)'
209
210.PHONY: echo-distinfo parent_echo-distinfo
211echo-distinfo: parent_echo-distinfo subdir_echo-distinfo
212parent_echo-distinfo:
213 @echo $(addprefix +header+,$(headers)) \
214 $(addprefix +nodist+,$(generated))
215\f
216# Make the distribution tarfile.
217
e215c478
RM
218distribute := README INSTALL NOTES COPYING.LIB COPYING NEWS \
219 ChangeLog ChangeLog.[0-9] \
28f540f4 220 Makefile Makeconfig Makerules Rules Make-dist MakeTAGS \
693e7b96 221 extra-lib.mk o-iterator.mk \
28f540f4
RM
222 ansidecl.h mkinstalldirs move-if-change install-sh \
223 configure configure.in aclocal.m4 config.sub config.guess\
e215c478 224 config.make.in config-name.in Makefile.in \
28f540f4
RM
225 munch-tmpl.c munch.awk sysdep.h set-hooks.h libc-symbols.h
226
227distribute := $(strip $(distribute))
228generated := $(generated) stubs.h
229
230README: README.template version.c ; # Make-dist should update README.
231
232define format-me
233@rm -f $@
234makeinfo --no-validate --no-warn --no-headers $< -o $@
235-chmod a-w $@
236endef
237INSTALL: manual/maint.texi; $(format-me)
238NOTES: manual/creature.texi; $(format-me)