Mon Dec 18 13:40:37 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
[glibc.git] / Rules
blob2bab3bfdfb4bee43c0a2d304fb689d0423907899
1 # Copyright (C) 1991, 1992, 1993, 1994, 1995 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.
23 ifneq (,)
24 This makefile requires GNU Make.
25 endif
27 all: # Don't let the default goal come from Makeconfig.
29 include ../Makeconfig
31 ifndef  subdir
32 Each subdirectory makefile must define the `subdir' variable.
33 endif
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.
38 .PHONY: all
39 all: objs lib others
41 ifneq   "$(findstring env,$(origin headers))" ""
42 headers :=
43 endif
45 ifneq   "$(findstring env,$(origin generated))" ""
46 generated :=
47 endif
49 ifeq "$(strip $(headers))" ""
50 ifneq "$(wildcard $(subdir).h)" ""
51 override headers := $(subdir).h
52 endif
53 endif
55 include ../Makerules
57 .PHONY: subdir_lib
58 subdir_lib: lib-noranlib
60 # Some subdirs need to install a dummy library.
61 # They can use "$(objpfx)libfnord.a: $(dep-dummy-lib); $(make-dummy-lib)".
62 dep-dummy-lib = $(objpfx)dummy.o
63 define make-dummy-lib
64 $(AR) cr$(verbose) $@ $<
65 endef
66 $(objpfx)dummy.o:
67         @rm -f $(@:.o=.c)
68         echo 'void __dummy__ () { }' > $(@:.o=.c)
69         $(CC) -c $(@:.o=.c) -o $@
70 generated := $(generated) dummy.o dummy.c
72 # This makes all the auxilliary and test programs.
74 .PHONY: others tests
75 others: $(addprefix $(objpfx),$(others) $(extra-objs))
76 ifeq ($(cross-compiling),yes)
77 tests: $(addprefix $(objpfx),$(tests))
78 else
79 tests: $(tests:%=$(objpfx)%.out)
80 endif
82 ifneq "$(strip $(others) $(tests))" ""
83 $(addprefix $(objpfx),$(others) $(tests)): %: %.o \
84   $(sort $(filter $(common-objpfx)libc%,$(link-libc)))
85         $(+link)
86 endif
88 ifneq "$(strip $(tests))" ""
89 # These are the implicit rules for making test outputs
90 # from the test programs and whatever input files are present.
91 $(objpfx)%.out: %.args $(objpfx)% %.input
92         $(built-program-cmd) `cat $(word 1,$^)` < $(word 3,$^) > $@
93 $(objpfx)%.out: %.args $(objpfx)%
94         $(built-program-cmd) `cat $(word 1,$^)` > $@
95 $(objpfx)%.out: %.input $(objpfx)%
96         $(built-program-cmd) < $(word 1,$^) > $@
97 $(objpfx)%.out: /dev/null $(objpfx)%    # Make it 2nd arg for canned sequence.
98         $(built-program-cmd) > $@
99 endif   # tests
101 .PHONY: distclean realclean subdir_distclean subdir_realclean \
102         subdir_clean subdir_mostlyclean
103 subdir_mostlyclean: mostlyclean
104 subdir_clean: clean
105 subdir_distclean: distclean
106 subdir_realclean: realclean
107 realclean: distclean
108 distclean: clean
110 .PHONY: subdir_echo-headers
111 subdir_echo-headers: echo-headers
113 .PHONY: subdir_echo-distinfo
114 subdir_echo-distinfo:
115         @echo $(addprefix +header+,$(headers)) \
116               $(addprefix +nodist+,$(generated) $(dont_distribute))
118 # We want to install everything except the library itself, but update all
119 # our portions of the library because the parent make will install it later
120 # (likewise the stubs file).
121 .PHONY: subdir_install
122 subdir_install: install-no-libc.a lib-noranlib stubs
124 .PHONY: subdir_TAGS subdir_dist
125 subdir_TAGS: TAGS
126 subdir_dist: dist
128 # Convenient target to update all the generated source files.
129 .PHONY: generated
130 generated: $(addprefix $(objpfx),$(generated))