Update.
[platform/upstream/glibc.git] / Make-dist
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 dist:
20
21 # Make the value empty so ifdef fails if it's $(-subdir).
22 subdir := $(subdir)
23 ifdef subdir
24 .. := ../
25 else
26 .. :=
27 endif
28
29 include $(..)Makeconfig
30
31 foo:=$(shell echo 'distribute=$(distribute)'>&2)
32 foo:=$(shell echo 'dont_distribute=$(dont_distribute)'>&2)
33 foo:=$(shell echo 'foobar=$(filter %.c %.S %.s %.h,$(distribute))'>&2)
34
35 ifndef sysdep_dirs
36 # Find all sysdep directories.
37 export sysdep_dirs := $(shell find $(..)sysdeps -type d \
38                                    ! -name CVS ! -name RCS -print)
39 else
40 # Defined by the parent.
41 sysdep_dirs := $(addprefix $(..),$(sysdep_dirs))
42 endif
43
44 # Don't distribute add-on subdirs.
45 subdirs := $(filter-out $(add-ons),$(subdirs))
46
47 # Make sure both stdio and libio get in, whichever is in use.
48 subdirs += stdio libio
49
50 sysdep-Subdir-files := $(wildcard $(addsuffix /Subdirs,$(sysdep_dirs)))
51 ifdef sysdep-Subdir-files
52 subdirs := $(sort $(subdirs) \
53                   $(shell sed -e 's/\#.*$$//' $(sysdep-Subdir-files)))
54 endif
55
56
57 # Makefiles can define `source_dirs' to list nonstandard directories
58 # where source files might be found.
59
60 ifdef   subdir
61 all-headers = $(filter-out $(sysdep_headers),$(headers))
62 else
63 +distinfo := $(shell MAKEFLAGS= MFLAGS= $(MAKE) -s no_deps=t \
64                      inhibit_interface_rules=t inhibit_mach_syscalls=t \
65                      subdirs='$(subdirs)' echo-distinfo | grep -v '^make')
66 foo:=$(shell echo>&2 '+distinfo=$(+distinfo)')
67 all-headers := $(patsubst +header+%,%,$(filter +header+%,$(+distinfo)))
68 # Ignore subdir headers without top-level indirections.
69 all-headers := $(sort $(headers) \
70                       $(patsubst include/%,%,\
71                                  $(wildcard $(addprefix include/,\
72                                                         $(all-headers)))))
73 # Filter out names like ../conf/portability.h that would point outside
74 # the source directory.
75 all-headers := $(filter-out ../%,$(all-headers))
76 +subdir-nodist := $(patsubst +nodist+%,%,$(filter +nodist+%,$(+distinfo)))
77 +subdir-headers := $(filter-out $(headers),$(all-headers))
78 endif
79 foo:=$(shell echo 'IS THIS WORKING??? all-headers=$(all-headers)' >&2)
80
81 sources += $(addsuffix .c,$(elided-routines) \
82                           $(foreach l,$(extra-libs),$($l-routines)))
83
84 # Find all sysdep sources and headers.
85 +maybe-sysdeps := $(sources) $(sources:.c=.s) $(sources:.c=.S) $(all-headers) \
86                   $(filter %.c %.S %.s %.h %.sub,$(distribute))
87 foo:=$(shell echo '+maybe-sysdeps=$(+maybe-sysdeps)'>&2)
88 # Find all the files that have a stub or generic version.
89 try-sysdeps := $(foreach dir,$(..)sysdeps/stub $(..)sysdeps/generic \
90                              $(..)sysdeps/libm-ieee754,\
91                              $(addprefix $(dir)/,$(+maybe-sysdeps)))
92 foo:=$(shell echo 'try-sysdeps=$(try-sysdeps)'>&2)
93 +sysdeps := $(wildcard $(try-sysdeps))
94 foo:=$(shell echo 'stub/generic +sysdeps=$(+sysdeps)'>&2)
95 +sysdep-names := $(sort $(patsubst $(..)sysdeps/generic/%,%,\
96                                    $(patsubst $(..)sysdeps/stub/%,%,\
97                                    $(patsubst $(..)sysdeps/libm-ieee754/%,%,\
98                                               $(+sysdeps)))))
99 foo:=$(shell echo '+sysdep-names=$(+sysdep-names)' >&2)
100
101 ifdef subdir-dirs
102 vpath % $(subdir-dirs)
103 endif
104
105 # Now find all the sysdep versions of those files.
106 +sysdeps := $(foreach dir,$(sysdep_dirs) $(source_dirs),\
107                       $(wildcard $(addprefix $(dir)/, \
108                                              $(+sysdep-names) \
109                                              $(+sysdep-names:.c=.s) \
110                                              $(+sysdep-names:.c=.S) \
111                                   )))
112
113
114 # Source and header files to go in the distribution tar file.
115
116 .S.s := $(wildcard $(sources:.c=.S) $(sources:.c=.s))
117 sources := $(filter-out $(addsuffix .c,$(basename $(.S.s))),$(sources)) $(.S.s)
118
119 +out := $(patsubst %.S,%.c,$(+sysdep-names:.s=.c)) \
120         $(addsuffix .c,$(sysdep_routines)) \
121         $(+subdir-nodist) $(dont_distribute)
122 foo:=$(shell echo '+out=$(+out)' >&2; echo foofoo >&2)
123 +tsrcs  := $(filter-out $(+out), $(sources) $(all-headers) $(distribute)) \
124            $(foreach l,$(extra-libs),$($l-map)) $(+sysdeps)
125 foo:=$(shell echo 'made +tsrcs=$(+tsrcs)'>&2)
126 foo:=$(shell echo generated='$(generated)' >&2)
127 #generated := $(sort $(generated) $(generated:.S=.c) $(generated:.s=.c))
128 #foo:=$(shell echo now generated='$(generated)' >&2)
129 +tsrcs := $(sort $(filter-out $(generated),$(+tsrcs)))
130 foo:=$(shell echo '+tsrcs=$(+tsrcs)'>&2)
131 foo:=$(shell echo foobie, dammit! >&2)
132
133 ifndef tardir
134 -include $(common-objpfx)version.mk
135 export tardir := glibc-$(version)
136 endif
137
138 $(..)glibc-$(version):
139         ln -s . $@
140
141 #+tsrcs := $(+tsrcs) \
142 #         TAGS
143 .PHONY: TAGS
144 TAGS: $(..)MakeTAGS
145         $(MAKE) -f $< $@ -o subdir_TAGS
146
147 ifdef      subdir
148
149 foo:=$(shell echo subdir foo >&2)
150
151 +tsrcs := Makefile $(+tsrcs)                                    \
152           $(addsuffix .c,$(others) $(tests) $(test-srcs))       \
153           $(wildcard $(addsuffix .input,$(tests) $(test-srcs))  \
154           $(addsuffix .args,$(tests) $(test-srcs)))
155 +tardeps := $(strip $(+tsrcs))
156
157 verbose = v
158
159 .PHONY: dist
160 dist: $(..)$(tardir) $(+tardeps)
161         @cd ..; if test -f dist.tar; then c=u; else c=c; fi;    \
162         $(+cmdecho) "cd ..; tar $${c}h$(verbose)f dist.tar ...";        \
163         tar $${c}h$(verbose)f dist.tar \
164             $(addprefix $(tardir)/$(subdir)/,$(filter-out $<,$^))
165
166 else    # Parent makefile.
167
168 # Find what other things sysdep directories want to distribute.
169
170 foo:=$(shell echo parent foobie>&2)
171 +sysdep-distfiles := $(wildcard $(addsuffix /Dist,$(sysdep_dirs)))
172 foo:=$(shell echo +sysdep-distfiles='$(+sysdep-distfiles)'>&2)
173 +sysdep-dist := $(foreach file,$(+sysdep-distfiles),\
174                           $(addprefix $(dir $(file)), \
175                                       $(shell sed -e 's/\#.*$$//' $(file)))) \
176                 $(+sysdep-distfiles) \
177                 $(sysdep-Subdir-files)
178 foo:=$(shell echo '+sysdep-dist=$(+sysdep-dist)' >&2)
179
180 +sysdep-tsrcs := $(wildcard $(foreach file,Makefile Implies syscalls.list\
181                                            configure configure.in,\
182                                       $(addsuffix /$(file),$(sysdep_dirs)))) \
183                  $(+sysdep-dist)
184
185 +tsrcs := $(+tsrcs) $(+sysdep-tsrcs)
186
187 define autoconf-it
188 autoconf $(ACFLAGS) $< > $@.new
189 mv -f $@.new $@
190 test ! -d CVS || cvs commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
191 endef
192
193 configure: configure.in aclocal.m4; $(autoconf-it)
194 %/configure: %/configure.in aclocal.m4; $(autoconf-it)
195
196 dist: $(tardir).tar.gz
197
198 subdir_dist: dist.tar
199 dist.tar: README $(tardir) $(+tsrcs)
200         tar chvf $@ $(addprefix $(tardir)/,$(filter-out $(tardir),$^))
201
202 $(tardir).tar: dist.tar subdir_dist
203         @echo Files listed here have names exceeding 14 chars.
204         tar xfv $< -C $${TMPDIR-/tmp} | sed -n '/[^/]\{15,\}/p'
205         tar covf $@ -C $${TMPDIR-/tmp} $(tardir)
206         -rm -fr $${TMPDIR-/tmp}/$(tardir) dist.tar &
207
208 %.Z: %
209         compress -c $< > $@
210
211 %.gz: %
212         gzip -9 -v -c $< > $@
213
214 foo:=$(shell echo subdirs=$(subdirs) >&2)
215 dist-subdirs := $(addprefix dist-,$(subdirs)) # dist-manual
216 .PHONY: subdir_dist $(dist-subdirs)
217 subdir_dist: $(dist-subdirs)
218 $(dist-subdirs):
219         $(MAKE) -C $(patsubst dist-%,%,$@) dist
220
221 # This is here instead of in Makefile so it can use $(release) and $(version).
222 README: README.template version.h
223         -rm -f $@
224         sed -e 's/RELEASE/$(release)/' -e 's/VERSION/$(version)/' < $< > $@
225 # Make it unwritable so I won't change it by mistake.
226         chmod 444 $@
227         test ! -d CVS || cvs commit -m'Remade for $(release)-$(version)' $@
228
229
230 endif   # Subdirectory vs. parent makefile
231 \f
232 # Get these things out of the environment because they take up lots of space.
233 unexport distribute generated
234
235 # Fnord.
236 export inhibit_mach_syscalls=t
237 export no_deps=t
238 export inhibit_interface_rules=t