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 # Rules for making a subdirectory in the GNU C library.
21 # Each subdirectory Makefile defines some variables and includes this.
24 This makefile requires GNU Make.
27 all: # Don't let the default goal come from Makeconfig.
32 Each subdirectory makefile must define the `subdir' variable.
34 # This is benign and useless in GNU make before 3.63.
35 export subdir := $(subdir)
37 # This is the default target; it makes the library and auxiliary programs.
41 others: $(addprefix $(objpfx),$(extra-objs) \
42 $(install-lib) $(install-bin) $(install-sbin))
44 ifneq "$(findstring env,$(origin headers))" ""
48 ifneq "$(findstring env,$(origin generated))" ""
52 ifeq "$(strip $(headers))" ""
53 ifneq "$(wildcard $(subdir).h)" ""
54 override headers := $(subdir).h
61 subdir_lib: lib-noranlib
63 # Some subdirs need to install a dummy library.
64 # They can use "$(objpfx)libfnord.a: $(dep-dummy-lib); $(make-dummy-lib)".
65 dep-dummy-lib = $(objpfx)dummy.o
67 $(AR) cr$(verbose) $@ $<
71 echo 'void __dummy__ () { }' > $(@:.o=.c)
72 $(CC) -c $(@:.o=.c) -o $@
76 $(CC) -c $(@:.o=.c) -o $@
77 generated := $(generated) dummy.o dummy.c empty.c empty.o
79 # This makes all the auxilliary and test programs.
82 others: $(addprefix $(objpfx),$(others) $(extra-objs))
83 ifeq ($(cross-compiling),yes)
84 tests: $(addprefix $(objpfx),$(tests))
86 tests: $(tests:%=$(objpfx)%.out)
89 ifneq "$(strip $(others) $(tests))" ""
90 $(addprefix $(objpfx),$(others) $(tests)): %: %.o \
91 $(sort $(filter $(common-objpfx)libc%,$(link-libc)))
95 ifneq "$(strip $(tests))" ""
96 # These are the implicit rules for making test outputs
97 # from the test programs and whatever input files are present.
98 $(objpfx)%.out: %.args $(objpfx)% %.input
99 $(built-program-cmd) `cat $(word 1,$^)` < $(word 3,$^) > $@
100 $(objpfx)%.out: %.args $(objpfx)%
101 $(built-program-cmd) `cat $(word 1,$^)` > $@
102 $(objpfx)%.out: %.input $(objpfx)%
103 $(built-program-cmd) < $(word 1,$^) > $@
104 $(objpfx)%.out: /dev/null $(objpfx)% # Make it 2nd arg for canned sequence.
105 $(built-program-cmd) > $@
108 .PHONY: distclean realclean subdir_distclean subdir_realclean \
109 subdir_clean subdir_mostlyclean
110 subdir_mostlyclean: mostlyclean
112 subdir_distclean: distclean
113 subdir_realclean: realclean
117 .PHONY: subdir_echo-headers
118 subdir_echo-headers: echo-headers
120 .PHONY: subdir_echo-distinfo
121 subdir_echo-distinfo:
122 @echo $(addprefix +header+,$(headers)) \
123 $(addprefix +nodist+,$(generated) $(dont_distribute))
125 # We want to install everything except the library itself, but update all
126 # our portions of the library because the parent make will install it later
127 # (likewise the stubs file).
128 .PHONY: subdir_install
129 subdir_install: install-no-libc.a lib-noranlib stubs \
130 $(common-objpfx)sor-$(subdir)
133 sor-objpfx = $(objpfx:../%=%)
135 sor-objpfx = $(subdir)
138 ifndef libc.so-version
139 # Undefine this because it can't work when we libc.so is unversioned.
140 static-only-routines =
143 # This communicates to the parent during install the set of routines that
144 # need to be put into the special libc.so archive.
145 $(common-objpfx)sor-$(subdir): Makefile
146 echo $(static-only-routines:%=$(sor-objpfx)%.o) > $@T
149 ifdef static-only-routines
150 # These routines are to be omitted from the shared library object,
151 # so we replace the PIC objects for them with the empty object file.
152 $(static-only-routines:%=$(objpfx)%.so): %.so: $(objpfx)empty.o
157 .PHONY: subdir_TAGS subdir_dist
161 # Convenient target to update all the generated source files.
163 generated: $(addprefix $(objpfx),$(generated))