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