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