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