Update.
[glibc.git] / Rules
blob89050bedf1787d28676cf11e2c5caf0479cb385c
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.
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 others: $(addprefix $(objpfx),$(extra-objs) \
42                               $(install-lib) $(install-bin) \
43                               $(install-rootsbin) $(install-sbin))
45 ifneq   "$(findstring env,$(origin headers))" ""
46 headers :=
47 endif
49 ifneq   "$(findstring env,$(origin generated))" ""
50 generated :=
51 endif
53 ifneq   "$(findstring env,$(origin common-generated))" ""
54 common-generated :=
55 endif
57 ifeq "$(strip $(headers))" ""
58 ifneq "$(wildcard $(subdir).h)" ""
59 override headers := $(subdir).h
60 endif
61 endif
63 include ../Makerules
65 .PHONY: subdir_lib
66 subdir_lib: lib-noranlib
68 # Some subdirs need to install a dummy library.
69 # They can use "$(objpfx)libfnord.a: $(dep-dummy-lib); $(make-dummy-lib)".
70 dep-dummy-lib = $(common-objpfx)dummy.o
71 define make-dummy-lib
72 $(AR) cr$(verbose) $@ $<
73 endef
74 $(common-objpfx)dummy.c:
75         rm -f $@
76         echo 'void __dummy__ (void) { }' > $@
77 $(common-objpfx)empty.c:
78         cp -f /dev/null $@
79 common-generated := $(common-generated) dummy.o dummy.c empty.c empty.o
81 # This makes all the auxiliary and test programs.
83 .PHONY: others tests
84 others: $(addprefix $(objpfx),$(others) $(extra-objs))
85 ifeq ($(cross-compiling),yes)
86 tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
87 else
88 tests: $(tests:%=$(objpfx)%.out)
89 endif
91 ifneq "$(strip $(others) $(tests) $(test-srcs))" ""
92 $(addprefix $(objpfx),$(others) $(tests) $(test-srcs)): %: %.o \
93   $(sort $(filter $(common-objpfx)libc%,$(link-libc))) \
94   $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
95         $(+link)
96 endif
98 ifneq "$(strip $(tests) $(test-srcs))" ""
99 # These are the implicit rules for making test outputs
100 # from the test programs and whatever input files are present.
101 $(objpfx)%.out: %.args $(objpfx)% %.input
102         $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` < $(word 3,$^) > $@
103 $(objpfx)%.out: %.args $(objpfx)%
104         $($*-ENV) $(built-program-cmd) `cat $(word 1,$^)` > $@
105 $(objpfx)%.out: %.input $(objpfx)%
106         $($*-ENV) $(built-program-cmd) < $(word 1,$^) > $@
107 $(objpfx)%.out: /dev/null $(objpfx)%    # Make it 2nd arg for canned sequence.
108         $($*-ENV) $(built-program-cmd) > $@
109 endif   # tests
111 .PHONY: distclean realclean subdir_distclean subdir_realclean \
112         subdir_clean subdir_mostlyclean
113 subdir_mostlyclean: mostlyclean
114 subdir_clean: clean
115 subdir_distclean: distclean
116 subdir_realclean: realclean
117 realclean: distclean
118 distclean: clean
120 .PHONY: subdir_echo-headers
121 subdir_echo-headers: echo-headers
123 .PHONY: subdir_echo-distinfo
124 subdir_echo-distinfo:
125         @echo $(addprefix +header+,$(headers) $(filter %.h,$(distribute))) \
126               $(addprefix +nodist+,$(generated) $(common-generated) $(dont_distribute))
128 # We want to install everything except the library itself, but update all
129 # our portions of the library because the parent make will install it later
130 # (likewise the stubs file).
131 .PHONY: subdir_install
132 subdir_install: install-no-libc.a lib-noranlib stubs
134 .PHONY: subdir_TAGS subdir_dist
135 subdir_TAGS: TAGS
136 subdir_dist: dist
138 # Convenient target to update all the generated source files.
139 .PHONY: generated
140 generated: $(addprefix $(common-objpfx),$(common-generated)) \
141         $(addprefix $(objpfx),$(generated))
143 ifndef libc.so-version
144 # Undefine this because it can't work when we libc.so is unversioned.
145 static-only-routines =
146 endif
148 ifdef static-only-routines
149 # These routines are to be omitted from the shared library object,
150 # so we replace the PIC objects for them with the empty object file.
151 $(static-only-routines:%=$(objpfx)%.so): %.so: $(common-objpfx)empty.o
152         rm -f $@
153         ln $< $@
154 endif