Update.
[glibc.git] / Make-dist
blobab11c3d453cd66f5697506b9ddc795087d2a4dd2
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 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
57 # Makefiles can define `source_dirs' to list nonstandard directories
58 # where source files might be found.
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) $(wildcard $(all-headers)))
70 +subdir-nodist := $(patsubst +nodist+%,%,$(filter +nodist+%,$(+distinfo)))
71 +subdir-headers := $(filter-out $(headers),$(all-headers))
72 endif
73 foo:=$(shell echo 'IS THIS WORKING??? all-headers=$(all-headers)' >&2)
75 sources += $(addsuffix .c,$(elided-routines) \
76                           $(foreach l,$(extra-libs),$($l-routines)))
78 # Find all sysdep sources and headers.
79 +maybe-sysdeps := $(sources) $(sources:.c=.s) $(sources:.c=.S) $(all-headers) \
80                   $(filter %.c %.S %.s %.h %.sub,$(distribute))
81 foo:=$(shell echo '+maybe-sysdeps=$(+maybe-sysdeps)'>&2)
82 # Find all the files that have a stub or generic version.
83 try-sysdeps := $(foreach dir,$(..)sysdeps/stub $(..)sysdeps/generic \
84                              $(..)sysdeps/libm-ieee754,\
85                              $(addprefix $(dir)/,$(+maybe-sysdeps)))
86 foo:=$(shell echo 'try-sysdeps=$(try-sysdeps)'>&2)
87 +sysdeps := $(wildcard $(try-sysdeps))
88 foo:=$(shell echo 'stub/generic +sysdeps=$(+sysdeps)'>&2)
89 +sysdep-names := $(sort $(patsubst $(..)sysdeps/generic/%,%,\
90                                    $(patsubst $(..)sysdeps/stub/%,%,\
91                                    $(patsubst $(..)sysdeps/libm-ieee754/%,%,\
92                                               $(+sysdeps)))))
93 foo:=$(shell echo '+sysdep-names=$(+sysdep-names)' >&2)
95 ifdef subdir-dirs
96 vpath % $(subdir-dirs)
97 endif
99 # Now find all the sysdep versions of those files.
100 +sysdeps := $(foreach dir,$(sysdep_dirs) $(source_dirs),\
101                       $(wildcard $(addprefix $(dir)/, \
102                                              $(+sysdep-names) \
103                                              $(+sysdep-names:.c=.s) \
104                                              $(+sysdep-names:.c=.S) \
105                                   )))
108 # Source and header files to go in the distribution tar file.
110 .S.s := $(wildcard $(sources:.c=.S) $(sources:.c=.s))
111 sources := $(filter-out $(addsuffix .c,$(basename $(.S.s))),$(sources)) $(.S.s)
113 +out := $(patsubst %.S,%.c,$(+sysdep-names:.s=.c)) \
114         $(addsuffix .c,$(sysdep_routines)) \
115         $(+subdir-nodist) $(dont_distribute)
116 foo:=$(shell echo '+out=$(+out)' >&2; echo foofoo >&2)
117 +tsrcs  := $(filter-out $(+out), $(sources) $(all-headers) $(distribute)) \
118            $(+sysdeps)
119 foo:=$(shell echo 'made +tsrcs=$(+tsrcs)'>&2)
120 foo:=$(shell echo generated='$(generated)' >&2)
121 #generated := $(sort $(generated) $(generated:.S=.c) $(generated:.s=.c))
122 #foo:=$(shell echo now generated='$(generated)' >&2)
123 +tsrcs := $(sort $(filter-out $(generated),$(+tsrcs)))
124 foo:=$(shell echo '+tsrcs=$(+tsrcs)'>&2)
125 foo:=$(shell echo foobie, dammit! >&2)
127 ifndef tardir
128 -include $(common-objpfx)version.mk
129 export tardir := glibc-$(version)
130 endif
132 $(..)glibc-$(version):
133         ln -s . $@
135 #+tsrcs := $(+tsrcs) \
136 #         TAGS
137 .PHONY: TAGS
138 TAGS: $(..)MakeTAGS
139         $(MAKE) -f $< $@ -o subdir_TAGS
141 ifdef      subdir
143 foo:=$(shell echo subdir foo >&2)
145 +tsrcs := Makefile $(+tsrcs)                                    \
146           $(addsuffix .c,$(others) $(tests) $(test-srcs))       \
147           $(wildcard $(addsuffix .input,$(tests) $(test-srcs))  \
148           $(addsuffix .args,$(tests) $(test-srcs)))
149 +tardeps := $(strip $(+tsrcs))
151 verbose = v
153 .PHONY: dist
154 dist: $(..)$(tardir) $(+tardeps)
155         @cd ..; if test -f dist.tar; then c=u; else c=c; fi;    \
156         $(+cmdecho) "cd ..; tar $${c}h$(verbose)f dist.tar ...";        \
157         tar $${c}h$(verbose)f dist.tar \
158             $(addprefix $(tardir)/$(subdir)/,$(filter-out $<,$^))
160 else    # Parent makefile.
162 # Find what other things sysdep directories want to distribute.
164 foo:=$(shell echo parent foobie>&2)
165 +sysdep-distfiles := $(wildcard $(addsuffix /Dist,$(sysdep_dirs)))
166 foo:=$(shell echo +sysdep-distfiles='$(+sysdep-distfiles)'>&2)
167 +sysdep-dist := $(foreach file,$(+sysdep-distfiles),\
168                           $(addprefix $(dir $(file)), \
169                                       $(shell sed -e 's/\#.*$$//' $(file)))) \
170                 $(+sysdep-distfiles) \
171                 $(sysdep-Subdir-files)
172 foo:=$(shell echo '+sysdep-dist=$(+sysdep-dist)' >&2)
174 +sysdep-tsrcs := $(wildcard $(foreach file,Makefile Implies syscalls.list\
175                                            configure configure.in,\
176                                       $(addsuffix /$(file),$(sysdep_dirs)))) \
177                  $(+sysdep-dist)
179 +tsrcs := $(+tsrcs) $(+sysdep-tsrcs)
181 define autoconf-it
182 autoconf $(ACFLAGS) $< > $@.new
183 mv -f $@.new $@
184 test ! -d CVS || cvs commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
185 endef
187 configure: configure.in aclocal.m4; $(autoconf-it)
188 %/configure: %/configure.in aclocal.m4; $(autoconf-it)
190 dist: $(tardir).tar.gz
192 subdir_dist: dist.tar
193 dist.tar: README $(tardir) $(+tsrcs)
194         tar chvf $@ $(addprefix $(tardir)/,$(filter-out $(tardir),$^))
196 $(tardir).tar: dist.tar subdir_dist
197         @echo Files listed here have names exceeding 14 chars.
198         tar xfv $< -C $${TMPDIR-/tmp} | sed -n '/[^/]\{15,\}/p'
199         tar covf $@ -C $${TMPDIR-/tmp} $(tardir)
200         -rm -fr $${TMPDIR-/tmp}/$(tardir) dist.tar &
202 %.Z: %
203         compress -c $< > $@
205 %.gz: %
206         gzip -9 -v -c $< > $@
208 foo:=$(shell echo subdirs=$(subdirs) >&2)
209 dist-subdirs := $(addprefix dist-,$(subdirs)) # dist-manual
210 .PHONY: subdir_dist $(dist-subdirs)
211 subdir_dist: $(dist-subdirs)
212 $(dist-subdirs):
213         $(MAKE) -C $(patsubst dist-%,%,$@) dist
215 # This is here instead of in Makefile so it can use $(release) and $(version).
216 README: README.template version.h
217         -rm -f $@
218         sed -e 's/RELEASE/$(release)/' -e 's/VERSION/$(version)/' < $< > $@
219 # Make it unwritable so I won't change it by mistake.
220         chmod 444 $@
221         test ! -d CVS || cvs commit -m'Remade for $(release)-$(version)' $@
224 endif   # Subdirectory vs. parent makefile
226 # Get these things out of the environment because they take up lots of space.
227 unexport distribute generated
229 # Fnord.
230 export inhibit_mach_syscalls=t
231 export no_deps=t
232 export inhibit_interface_rules=t