initial import
[platform/upstream/glibc.git] / Makefile
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 #
22 ifneq (,)
23 This makefile requires GNU Make.
24 endif
25
26
27 # This is the default target; it makes everything except the tests.
28 .PHONY: all
29 all: lib others
30 \f
31 define autoconf-it
32 autoconf $(ACFLAGS) $< > $@.new
33 mv -f $@.new $@
34 test -d CVS && cvs commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
35 endef
36
37 configure: configure.in; $(autoconf-it)
38 %/configure: %/configure.in; $(autoconf-it)
39
40 include Makeconfig
41
42 ifndef avoid-generated
43 include $(objpfx)sysd-dirs
44 define \n
45
46
47 endef
48 sysdep-subdirs := $(subst $(\n), ,$(sysdep-subdirs))
49 endif
50
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.
59
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))
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
84 headers := features.h errno.h sys/errno.h errnos.h limits.h $(stddef.h)
85 aux      = sysdep $(libc-init) version
86
87 echo-headers: subdir_echo-headers
88
89 # What to install.
90 install-others = $(includedir)/stubs.h
91
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
101
102
103 include Makerules
104
105 # Install from subdirectories too.
106 install: subdir_install
107
108 lib-noranlib $(libc.a)(__.SYMDEF): subdir_lib
109
110
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 $@
121 \f
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>.
125
126 subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)stub-$(dir))
127
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
143 \f
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 $@
148 \f
149 # This makes all the subdirectory targets.
150
151 # For each target, make it depend on DIR/target for each subdirectory DIR.
152 $(+subdir_targets): %: $(addsuffix /%,$(subdirs))
153
154 # Compute a list of all those targets.
155 all-subdirs-targets := $(foreach dir,$(subdirs),\
156                                  $(addprefix $(dir)/,$(+subdir_targets)))
157
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)
162
163 .PHONY: $(+subdir_targets) $(all-subdirs-targets)
164 \f
165 # Targets to clean things up to various degrees.
166
167 .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean
168
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)
175
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
184
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
193
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))
203 \f
204 .PHONY: echo_subdirs
205 echo_subdirs:;@echo '$(subdirs)'
206
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))
212 \f
213 # Make the distribution tarfile.
214
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
221
222 distribute := $(strip $(distribute))
223 generated := $(generated) stubs.h
224
225 README: README.template version.c ; # Make-dist should update README.
226
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)