Update.
[platform/upstream/glibc.git] / Rules
1 # Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
3
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.
8
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.
13
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 not,
16 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 # Boston, MA 02111-1307, USA.
18
19 #
20 #       Rules for making a subdirectory in the GNU C library.
21 #       Each subdirectory Makefile defines some variables and includes this.
22 #
23 ifneq (,)
24 This makefile requires GNU Make.
25 endif
26
27 all: # Don't let the default goal come from Makeconfig.
28
29 include ../Makeconfig
30
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)
36 \f
37 # This is the default target; it makes the library and auxiliary programs.
38 .PHONY: all
39 all: objs lib others
40
41 ifeq ($(build-programs),yes)
42 others: $(addprefix $(objpfx),$(extra-objs) \
43                               $(install-lib) $(install-bin) \
44                               $(install-rootsbin) $(install-sbin))
45 else
46 others: $(addprefix $(objpfx),$(extra-objs) \
47                               $(install-lib))
48 endif
49
50 ifneq   "$(findstring env,$(origin headers))" ""
51 headers :=
52 endif
53
54 ifneq   "$(findstring env,$(origin generated))" ""
55 generated :=
56 endif
57
58 ifneq   "$(findstring env,$(origin common-generated))" ""
59 common-generated :=
60 endif
61
62 ifeq "$(strip $(headers))" ""
63 ifneq "$(wildcard $(subdir).h)" ""
64 override headers := $(subdir).h
65 endif
66 endif
67
68 include ../Makerules
69
70 .PHONY: subdir_lib
71 subdir_lib: lib-noranlib
72
73 # Some subdirs need to install a dummy library.
74 # They can use "$(objpfx)libfnord.a: $(dep-dummy-lib); $(make-dummy-lib)".
75 dep-dummy-lib = $(common-objpfx)dummy.o
76 define make-dummy-lib
77 $(AR) cr$(verbose) $@ $<
78 endef
79 $(common-objpfx)dummy.c:
80         rm -f $@
81         echo 'void __dummy__ (void) { }' > $@
82 $(common-objpfx)empty.c:
83         cp -f /dev/null $@
84 common-generated := $(common-generated) dummy.o dummy.c empty.c empty.o
85 \f
86 # This makes all the auxiliary and test programs.
87
88 .PHONY: others tests
89 ifeq ($(build-programs),yes)
90 others: $(addprefix $(objpfx),$(others) $(extra-objs))
91 else
92 others: $(addprefix $(objpfx),$(extra-objs))
93 endif
94 ifeq ($(cross-compiling),yes)
95 tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
96 else
97 tests: $(tests:%=$(objpfx)%.out)
98 endif
99
100 ifeq ($(build-programs),yes)
101 ifneq "$(strip $(others) $(tests) $(test-srcs))" ""
102 $(addprefix $(objpfx),$(others) $(tests) $(test-srcs)): %: %.o \
103   $(sort $(filter $(common-objpfx)libc%,$(link-libc))) \
104   $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
105         $(+link)
106 endif
107 else
108 ifneq "$(strip $(tests) $(test-srcs))" ""
109 $(addprefix $(objpfx),$(tests) $(test-srcs)): %: %.o \
110   $(sort $(filter $(common-objpfx)libc%,$(link-libc))) \
111   $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
112         $(+link)
113 endif
114 endif
115
116 ifneq "$(strip $(tests) $(test-srcs))" ""
117 # These are the implicit rules for making test outputs
118 # from the test programs and whatever input files are present.
119 $(objpfx)%.out: %.args $(objpfx)% %.input
120         $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` < $(word 3,$^) > $@
121 $(objpfx)%.out: %.args $(objpfx)%
122         $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` > $@
123 $(objpfx)%.out: %.input $(objpfx)%
124         $($*-ENV) $(built-program-cmd) < $(word 1,$^) > $@
125 $(objpfx)%.out: /dev/null $(objpfx)%    # Make it 2nd arg for canned sequence.
126         $($*-ENV) $(built-program-cmd) > $@
127 endif   # tests
128 \f
129 .PHONY: distclean realclean subdir_distclean subdir_realclean \
130         subdir_clean subdir_mostlyclean
131 subdir_mostlyclean: mostlyclean
132 subdir_clean: clean
133 subdir_distclean: distclean
134 subdir_realclean: realclean
135 realclean: distclean
136 distclean: clean
137
138 .PHONY: subdir_echo-headers
139 subdir_echo-headers: echo-headers
140
141 .PHONY: subdir_echo-distinfo
142 subdir_echo-distinfo:
143         @echo $(addprefix +header+,$(headers) $(filter %.h,$(distribute))) \
144               $(addprefix +nodist+,$(generated) $(common-generated) $(dont_distribute))
145
146 # We want to install everything except the library itself, but update all
147 # our portions of the library because the parent make will install it later
148 # (likewise the stubs file).
149 .PHONY: subdir_install
150 subdir_install: install-no-libc.a lib-noranlib stubs
151
152 .PHONY: subdir_TAGS subdir_dist
153 subdir_TAGS: TAGS
154 subdir_dist: dist
155
156 # Convenient target to update all the generated source files.
157 .PHONY: generated
158 generated: $(addprefix $(common-objpfx),$(common-generated)) \
159         $(addprefix $(objpfx),$(generated))
160
161 ifndef libc.so-version
162 # Undefine this because it can't work when we libc.so is unversioned.
163 static-only-routines =
164 endif
165
166 ifdef static-only-routines
167 # These routines are to be omitted from the shared library object,
168 # so we replace the PIC objects for them with the empty object file.
169 $(static-only-routines:%=$(objpfx)%.so): %.so: $(common-objpfx)empty.o
170         rm -f $@
171         ln $< $@
172 endif