1 # Copyright (C) 1991, 1992, 1993, 1994 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 ifneq "$(findstring env,$(origin headers))" ""
45 ifneq "$(findstring env,$(origin generated))" ""
49 ifeq "$(strip $(headers))" ""
50 ifneq "$(wildcard $(subdir).h)" ""
51 override headers := $(subdir).h
58 subdir_lib: lib-noranlib
60 # This makes all the auxilliary and test programs.
63 others: $(addprefix $(objpfx),$(others))
64 tests: $(tests:%=$(objpfx)%.out)
66 ifneq "$(strip $(others) $(tests))" ""
67 $(addprefix $(objpfx),$(others) $(tests)): %: %.o $(libc.a)
71 ifneq "$(strip $(tests))" ""
72 # These are the implicit rules for making test outputs
73 # from the test programs and whatever input files are present.
74 $(objpfx)%.out: $(objpfx)% %.args %.input
75 $(dir $<)$(notdir $<) `cat $(word 2,$^)` < $(word 3,$^) > $@
76 $(objpfx)%.out: $(objpfx)% %.args
77 $(dir $<)$(notdir $<) `cat $(word 2,$^)` > $@
78 $(objpfx)%.out: $(objpfx)% %.input
79 $(dir $<)$(notdir $<) < $(word 2,$^) > $@
80 $(objpfx)%.out: $(objpfx)%
81 $(dir $<)$(notdir $<) > $@
84 # Because the link above depends on libc.a, which I don't want built
85 # automatically, this is necessary. -mib
90 export others := $(others)
91 export tests := $(tests)
93 # This removes everything that can be regenerated
94 # except for the object files and the object-file library members.
97 -rm -f $(addprefix $(objpfx),$(tests) $(others) \
98 $(addsuffix .o,$(tests) $(others)))
99 -rm -f core TAGS $(objpfx)depend-$(subdir)
101 # This removes absolutely everything that can be regenerated.
102 .PHONY: subdir_clean clean realclean
103 subdir_clean realclean: clean
105 -rm -f $(objects) $(addprefix $(objpfx),$(extra-objs)) \
106 $(+depfiles) $(generated)
108 .PHONY: subdir_echo-headers
109 subdir_echo-headers: echo-headers
111 .PHONY: subdir_echo-distinfo
112 subdir_echo-distinfo:
113 @echo $(addprefix +header+,$(headers)) \
114 $(addprefix +nodist+,$(generated) $(dont_distribute))
116 # We want to install everything except the library itself, but update all
117 # our portions of the library because the parent make will install it later
118 # (likewise the stubs file).
119 .PHONY: subdir_install
120 subdir_install: install-no-libc.a lib-noranlib stubs
125 # Make the distribution tarfile for the parent makefile.
126 export distribute := $(distribute)
127 export dont_distribute := $(dont_distribute)
128 export generated := $(generated)
129 .PHONY: subdir_dist dist
132 $(MAKE) -f $< $(Make-dist-args)
134 # Convenient target to update all the generated source files.
136 generated: $(generated)