Linux specific version is enough
[glibc/history.git] / Makefile
blobceaf5b0b62ceea5bedeccaa4cb7c310caa33c67e
1 # Copyright (C) 1991, 92, 93, 94, 95, 96 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 @-rm -f $@.new
33 autoconf $(ACFLAGS) $< > $@.new
34 chmod a-w,a+x $@.new
35 mv -f $@.new $@
36 test ! -d CVS || cvs commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
37 endef
39 configure: configure.in aclocal.m4; $(autoconf-it)
40 %/configure: %/configure.in aclocal.m4; $(autoconf-it)
42 include Makeconfig
44 ifndef avoid-generated
45 -include $(objpfx)sysd-dirs
46 define \n
49 endef
50 sysdep-subdirs := $(subst $(\n), ,$(sysdep-subdirs))
51 endif
53 # These are the subdirectories containing the library source.
54 subdirs = csu assert ctype db locale intl catgets math setjmp signal stdlib \
55 stdio-common $(stdio) malloc string wcsmbs time dirent grp pwd\
56 posix io termios resource misc login socket sysvipc gmon gnulib \
57 wctype manual shadow crypt $(sysdep-subdirs) nss elf po $(add-ons)
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 # much of the 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_distinfo \
80 subdir_echo-headers subdir_echo-distinfo \
81 subdir_install \
82 $(addprefix install-, no-libc.a bin lib data headers others)
84 headers := errno.h sys/errno.h errnos.h limits.h values.h \
85 features.h gnu-versions.h libc-lock.h
86 aux = sysdep $(libc-init) version
87 before-compile = $(objpfx)version-info.h
89 echo-headers: subdir_echo-headers
91 # What to install.
92 install-others = $(includedir)/stubs.h $(includedir)/gnu/lib-names.h
94 ifeq (yes,$(gnu-ld))
95 libc-init = set-init
96 else
97 libc-init = munch-init
98 $(objpfx)munch-init.c: munch.awk munch-tmpl.c $(+subdir_inits)
99 awk -f $< subdirs='$(+init_subdirs)' $(word 2,$^) > $@-t
100 mv -f $@-t $@
101 generated := $(generated) munch-init.c
102 endif
105 include Makerules
107 # Install from subdirectories too.
108 install: subdir_install
110 # Build subdirectory lib objects.
111 lib-noranlib: subdir_lib
113 ifeq (yes,$(build-shared))
114 # Build the shared object from the PIC object library.
115 lib: $(common-objpfx)libc.so
116 endif
118 all-Subdirs-files = $(wildcard $(addsuffix /Subdirs, $(config-sysdirs)))
119 $(objpfx)sysd-dirs: $(+sysdir_pfx)config.make $(all-Subdirs-files)
120 (echo define sysdep-subdirs; \
121 sed 's/#.*$$//' $(all-Subdirs-files) /dev/null; \
122 echo endef) > $@-tmp
123 mv -f $@-tmp $@
125 all-Banner-files = $(wildcard $(addsuffix /Banner, $(subdirs)))
126 $(objpfx)version-info.h: $(+sysdir_pfx)config.make $(all-Banner-files)
127 (case $(config-os) in \
128 linux*) version=`(echo -e "#include <linux/version.h>\nUTS_RELEASE"\
129 | $(CC) -E -P - | \
130 sed -e 's/"\([^"]*\)".*/\1/p' -e d) 2>/dev/null`;\
131 if [ -z "$$version" ]; then \
132 if [ -r /proc/version ]; then \
133 version=`sed 's/.*version \([^ ]*\) .*/>>\1<</' \
134 < /proc/version`; \
135 else \
136 version=`uname -r`; \
137 fi; \
138 fi; \
139 echo -n "\"Compiled on a Linux $$version system "; \
140 echo "on `date +%Y/%m/%d`.\\n\"" ;; \
141 *) ;; \
142 esac; \
143 files="$(all-Banner-files)"; \
144 if test -n "$$files"; then \
145 echo "\"Available extensions:"; \
146 sed -e '/^#/d' -e 's/^[[:space:]]*/ /' $$files; \
147 echo "\""; \
148 fi) > $@T
149 mv -f $@T $@
150 generated += version-info.h
152 version.c-objects := $(addprefix $(objpfx)version,$(object-suffixes))
153 $(version.c-objects): $(objpfx)version-info.h
155 # Makerules creates a file `stub-$(subdir)' for each subdirectory, which
156 # contains `#define __stub_FUNCTION' for each function which is a stub.
157 # Here we paste all of these together into <stubs.h>.
159 subdir-stubs := $(foreach dir,$(subdirs),$(common-objpfx)stub-$(dir))
161 # Since stubs.h is never needed when building the library, we simplify the
162 # hairy installation process by producing it in place only as the last part
163 # of the top-level `make install'. It depends on subdir_install, which
164 # iterates over all the subdirs; subdir_install in each subdir depends on
165 # the subdir's stubs file. Having more direct dependencies would result in
166 # extra iterations over the list for subdirs and many recursive makes.
167 $(includedir)/stubs.h: subdir_install
168 @rm -f $(objpfx)stubs.h
169 (echo '/* This file is automatically generated.';\
170 echo ' It defines a symbol `__stub_FUNCTION'\'' for each function';\
171 echo ' in the C library which is a stub, meaning it will fail';\
172 echo ' every time called, usually setting errno to ENOSYS. */';\
173 sort $(subdir-stubs)) > $(objpfx)stubs.h
174 if test -r $@ && cmp -s $(objpfx)stubs.h $@; \
175 then echo 'stubs.h unchanged'; \
176 else $(INSTALL_DATA) $(objpfx)stubs.h $@; fi
177 rm -f $(objpfx)stubs.h
179 # Like stubs.h the gnu/lib-names.h header is not used while building the
180 # libc itself. So we generate it while installing.
181 $(includedir)/gnu/lib-names.h: $(common-objpfx)soversions.mk
182 @rm -f $(objpfx)lib-names.h
183 (echo '/* This file is automatically generated.';\
184 echo ' It defines macros to allow user program to find the shared';\
185 echo ' library files which come as part of GNU libc. */';\
186 echo '#ifndef __GNU_LIB_NAMES_H'; \
187 echo '#define __GNU_LIB_NAMES_H 1'; \
188 echo; \
189 (libs='$(all-sonames)';\
190 for l in $$libs; do \
191 upname=`echo $$l | sed 's/[.]so.*//' | tr [:lower:]- [:upper:]_`; \
192 echo "#define $${upname}_SO $$l"; \
193 done;) | sort; \
194 echo; \
195 echo '#endif /* gnu/lib-names.h */';) > $(objpfx)lib-names.h
196 if test -r $@ && cmp -s $(objpfx)lib-names.h $@; \
197 then echo 'gnu/lib-names.h unchanged'; \
198 else $(INSTALL_DATA) $(objpfx)lib-names.h $@; fi
199 rm -f $(objpfx)lib-names.h
201 # This makes the Info or DVI file of the documentation from the Texinfo source.
202 .PHONY: info dvi
203 info dvi:
204 $(MAKE) -C manual $@
206 # This makes all the subdirectory targets.
208 # For each target, make it depend on DIR/target for each subdirectory DIR.
209 $(+subdir_targets): %: $(addsuffix /%,$(subdirs))
211 # Compute a list of all those targets.
212 all-subdirs-targets := $(foreach dir,$(subdirs),\
213 $(addprefix $(dir)/,$(+subdir_targets)))
215 # The action for each of those is to cd into the directory and make the
216 # target there.
217 $(all-subdirs-targets):
218 $(MAKE) -C $(@D) $(@F)
220 .PHONY: $(+subdir_targets) $(all-subdirs-targets)
222 # Targets to clean things up to various degrees.
224 .PHONY: clean realclean distclean distclean-1 parent-clean parent-mostlyclean
226 # Subroutines of all cleaning targets.
227 parent-mostlyclean: common-mostlyclean # common-mostlyclean is in Makerules.
228 -rm -f $(foreach o,$(object-suffixes),\
229 $(common-objpfx)$(patsubst %,$(libtype$o),c)) \
230 $(addprefix $(objpfx),$(install-lib))
231 parent-clean: parent-mostlyclean common-clean
232 -rm -f $(addprefix $(common-objpfx),$(common-generated))
233 -rm -f $(addprefix $(objpfx),sysd-Makefile sysd-dirs sysd-rules)
235 clean: parent-clean
236 # This is done this way rather than having `subdir_clean' be a
237 # dependency of this target so that libc.a will be removed before the
238 # subdirectories are dealt with and so they won't try to remove object
239 # files from it when it's going to be removed anyway.
240 @$(MAKE) subdir_clean no_deps=t
241 mostlyclean: parent-mostlyclean
242 @$(MAKE) subdir_mostlyclean no_deps=t
244 # The realclean target is just like distclean for the parent, but we want
245 # the subdirs to know the difference in case they care.
246 realclean distclean: parent-clean
247 # This is done this way rather than having `subdir_distclean' be a
248 # dependency of this target so that libc.a will be removed before the
249 # subdirectories are dealt with and so they won't try to remove object
250 # files from it when it's going to be removed anyway.
251 @$(MAKE) distclean-1 no_deps=t distclean-1=$@ avoid-generated=yes
253 # Subroutine of distclean and realclean.
254 distclean-1: subdir_$(distclean-1)
255 -rm -f $(config-generated)
256 -rm -f $(addprefix $(objpfx),config.status config.cache config.log)
257 -rm -f $(addprefix $(objpfx),config.make config-name.h config.h)
258 ifdef objdir
259 -rm -f $(objpfx)Makefile
260 endif
261 -rm -f $(sysdep-$(distclean-1))
263 .PHONY: echo_subdirs
264 echo_subdirs:;@echo '$(subdirs)'
266 .PHONY: echo-distinfo parent_echo-distinfo
267 echo-distinfo: parent_echo-distinfo subdir_echo-distinfo
268 parent_echo-distinfo:
269 @echo $(addprefix +header+,$(headers)) \
270 $(addprefix +nodist+,$(generated))
273 # Make the distribution tarfile.
275 distribute := README INSTALL FAQ NOTES NEWS PROJECTS \
276 COPYING.LIB COPYING ChangeLog ChangeLog.[0-9] \
277 Makefile Makeconfig Makerules Rules Make-dist MakeTAGS \
278 extra-lib.mk o-iterator.mk \
279 ansidecl.h mkinstalldirs move-if-change install-sh \
280 configure configure.in aclocal.m4 config.sub config.guess\
281 config.h.in config.make.in config-name.in Makefile.in \
282 autolock.sh munch-tmpl.c munch.awk interp.c \
283 sysdep.h set-hooks.h libc-symbols.h version.h shlib-versions \
284 rpm/Makefile rpm/template rpm/rpmrc nsswitch.h netgroup.h
286 distribute := $(strip $(distribute))
287 generated := $(generated) stubs.h version-info.h
289 README: README.template version.c ; # Make-dist should update README.
291 define format-me
292 @rm -f $@
293 makeinfo --no-validate --no-warn --no-headers $< -o $@
294 -chmod a-w $@
295 endef
296 INSTALL: manual/maint.texi; $(format-me)
297 NOTES: manual/creature.texi; $(format-me)
299 rpm/%: subdir_distinfo
300 $(MAKE) -C $(@D) subdirs='$(subdirs)' $(@F)