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