1 # Copyright (C) 1991, 1992 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 # Propagated rules for making the GNU C library
23 This makefile requires GNU Make.
29 Each subdirectory makefile must define the `subdir' variable.
32 # This is the default target; it makes the library.
36 ifneq "$(findstring env,$(origin headers))" ""
40 ifeq "$(strip $(headers))" ""
41 ifneq "$(wildcard $(subdir).h)" ""
42 override headers := $(subdir).h
49 subdir_lib: lib-noranlib
51 .PHONY: subdir_headers
52 subdir_headers: headers
54 # This makes all the auxilliary and test programs.
57 others: $(addprefix $(objpfx),$(others))
58 tests: $(tests:%=$(objpfx)%.out)
60 ifneq "$(strip $(others) $(tests))" ""
61 $(addprefix $(objpfx),$(others) $(tests)): %: %.o lib
65 ifneq "$(strip $(tests))" ""
66 # These are the implicit rules for making test outputs
67 # from the test programs and whatever input files are present.
68 $(objpfx)%.out: $(objpfx)% %.args %.input
69 $(dir $<)$(notdir $<) `cat $(word 2,$^)` < $(word 3,$^) > $@
70 $(objpfx)%.out: $(objpfx)% %.args
71 $(dir $<)$(notdir $<) `cat $(word 2,$^)` > $@
72 $(objpfx)%.out: $(objpfx)% %.input
73 $(dir $<)$(notdir $<) < $(word 2,$^) > $@
74 $(objpfx)%.out: $(objpfx)%
75 $(dir $<)$(notdir $<) > $@
78 # This removes everything that can be regenerated
79 # except for the object files and the object-file library members.
82 rm -f $(addprefix $(objpfx),$(tests) $(others))
83 rm -f core TAGS depend
85 # This removes absolutely everything that can be regenerated.
86 .PHONY: subdir_clean clean realclean
87 subdir_clean realclean: clean
90 rm -f $(+objs) $(+depfiles)
92 .PHONY: subdir_echo-headers
93 subdir_echo-headers: echo-headers
95 .PHONY: subdir_echo-distinfo
97 @echo $(addprefix +header+,$(headers)) \
98 $(addprefix +nodist+,$(dont_distribute))
100 .PHONY: subdir_install
101 subdir_install: install
103 # In most cases, we want the C source files to come before
104 # the header files so tags for optimizing #define's in the
105 # headers won't be put in the tags files, but for ctype,
106 # the functions are just backup for the #define's in the header.
107 ifeq "$(subdir)" "ctype"
108 +tags_sources := *.h $(sources)
110 +tags_sources := $(sources) *.h
113 # This makes the tags file.
114 TAGS: $(+tags_sources)
115 @$(cmdecho) '$(ctags) -f $@ ...'
120 # Make the distribution tarfile for the parent makefile.
122 ifneq "$(findstring env,$(origin distribute))" ""
123 override distribute :=
126 .PHONY: subdir_dist dist
129 $(MAKE) -f $< $(Make-dist-args)
131 # Keep these out of the environment so it doesn't get too big.