Thu Jun 6 02:00:42 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[glibc.git] / Make-dist
blobbba703cb26248f95328400551c72ab48917c5539
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 ! -name RCS -print)
35 else
36 # Defined by the parent.
37 sysdep_dirs := $(addprefix $(..),$(sysdep_dirs))
38 endif
40 sysdep-Subdir-files := $(wildcard $(addsuffix /Subdirs,$(sysdep_dirs)))
41 ifdef sysdep-Subdir-files
42 subdirs := $(sort $(subdirs) \
43                   $(shell sed -e 's/\#.*$$//' $(sysdep-Subdir-files)))
44 endif
47 # Makefiles can define `source_dirs' to list nonstandard directories
48 # where source files might be found.
50 ifdef   subdir
51 all-headers = $(filter-out $(sysdep_headers),$(headers))
52 else
53 +distinfo := $(shell MAKEFLAGS= MFLAGS= $(MAKE) -s no_deps=t \
54                      inhibit_interface_rules=t inhibit_mach_syscalls=t \
55                      subdirs='$(subdirs)' echo-distinfo | grep -v '^make')
56 foo:=$(shell echo>&2 '+distinfo=$(+distinfo)')
57 all-headers := $(patsubst +header+%,%,$(filter +header+%,$(+distinfo)))
58 # Ignore subdir headers without top-level indirections.
59 all-headers := $(sort $(headers) $(wildcard $(all-headers)))
60 +subdir-nodist := $(patsubst +nodist+%,%,$(filter +nodist+%,$(+distinfo)))
61 +subdir-headers := $(filter-out $(headers),$(all-headers))
62 endif
63 foo:=$(shell echo 'IS THIS WORKING??? all-headers=$(all-headers)' >&2)
65 sources += $(addsuffix .c,$(elided-routines) \
66                           $(foreach l,$(extra-libs),$($l-routines)))
68 # Find all sysdep sources and headers.
69 +maybe-sysdeps := $(sources) $(sources:.c=.s) $(sources:.c=.S) $(all-headers) \
70                   $(filter %.c %.S %.s %.h %.sub,$(distribute))
71 foo:=$(shell echo '+maybe-sysdeps=$(+maybe-sysdeps)'>&2)
72 # Find all the files that have a stub or generic version.
73 try-sysdeps := $(foreach dir,$(..)sysdeps/stub $(..)sysdeps/generic \
74                              $(..)sysdeps/libm-ieee754,\
75                              $(addprefix $(dir)/,$(+maybe-sysdeps)))
76 foo:=$(shell echo 'try-sysdeps=$(try-sysdeps)'>&2)
77 +sysdeps := $(wildcard $(try-sysdeps))
78 foo:=$(shell echo 'stub/generic +sysdeps=$(+sysdeps)'>&2)
79 +sysdep-names := $(sort $(patsubst $(..)sysdeps/generic/%,%,\
80                                    $(patsubst $(..)sysdeps/stub/%,%,\
81                                    $(patsubst $(..)sysdeps/libm-ieee754/%,%,\
82                                               $(+sysdeps)))))
83 foo:=$(shell echo '+sysdep-names=$(+sysdep-names)' >&2)
85 ifdef subdir-dirs
86 vpath % $(subdir-dirs)
87 endif
89 # Now find all the sysdep versions of those files.
90 +sysdeps := $(wildcard $(foreach dir,$(sysdep_dirs) $(source_dirs),\
91                                  $(addprefix $(dir)/, \
92                                              $(+sysdep-names) \
93                                              $(+sysdep-names:.c=.s) \
94                                              $(+sysdep-names:.c=.S) \
95                                   )))
98 # Source and header files to go in the distribution tar file.
100 .S.s := $(wildcard $(sources:.c=.S) $(sources:.c=.s))
101 sources := $(filter-out $(addsuffix .c,$(basename $(.S.s))),$(sources)) $(.S.s)
103 +out := $(patsubst %.S,%.c,$(+sysdep-names:.s=.c)) \
104         $(addsuffix .c,$(sysdep_routines)) \
105         $(+subdir-nodist)
106 #foo:=$(shell echo '+out=$(+out)' >&2; echo foofoo >&2)
107 +tsrcs  := $(filter-out $(+out) $(addprefix %/,$(+out)), \
108                         $(sources) $(all-headers) $(distribute)) \
109            $(+sysdeps)
110 foo:=$(shell echo made +tsrcs >&2)
111 foo:=$(shell echo generated='$(generated)' >&2)
112 generated := $(sort $(generated) $(generated:.S=.c) $(generated:.s=.c))
113 foo:=$(shell echo now generated='$(generated)' >&2)
114 +tsrcs := $(sort $(filter-out $(generated),$(+tsrcs)))
115 foo:=$(shell echo '+tsrcs=$(+tsrcs)'>&2)
116 foo:=$(shell echo foobie, dammit! >&2)
118 ifndef tardir
119 -include $(common-objpfx)version.mk
120 export tardir := glibc-$(version)
121 endif
123 $(..)glibc-$(version):
124         ln -s . $@
126 +tsrcs := $(+tsrcs) \
127           TAGS
128 .PHONY: TAGS
129 TAGS: $(..)MakeTAGS
130         $(MAKE) -f $< $@ -o subdir_TAGS
132 ifdef      subdir
134 foo:=$(shell echo subdir foo >&2)
136 +tsrcs := Makefile $(+tsrcs)                            \
137           $(addsuffix .c,$(others) $(tests))            \
138           $(wildcard $(addsuffix .input,$(tests))       \
139           $(addsuffix .args,$(tests)))
140 +tardeps := $(strip $(+tsrcs))
142 verbose = v
144 .PHONY: dist
145 dist: $(..)$(tardir) $(+tardeps)
146         @cd ..; if test -f dist.tar; then c=u; else c=c; fi;    \
147         $(+cmdecho) "cd ..; tar $${c}h$(verbose)f dist.tar ...";        \
148         tar $${c}h$(verbose)f dist.tar \
149             $(addprefix $(tardir)/$(subdir)/,$(filter-out $<,$^))
151 else    # Parent makefile.
153 # Find what other things sysdep directories want to distribute.
155 foo:=$(shell echo parent foobie>&2)
156 +sysdep-distfiles := $(wildcard $(addsuffix /Dist,$(sysdep_dirs)))
157 foo:=$(shell echo +sysdep-distfiles='$(+sysdep-distfiles)'>&2)
158 +sysdep-dist := $(foreach file,$(+sysdep-distfiles),\
159                           $(addprefix $(dir $(file)), \
160                                       $(shell sed -e 's/\#.*$$//' $(file)))) \
161                 $(+sysdep-distfiles) \
162                 $(sysdep-Subdir-files)
163 foo:=$(shell echo '+sysdep-dist=$(+sysdep-dist)' >&2)
165 subdirs := $(filter-out crypt,$(subdirs))
167 +sysdep-tsrcs := $(wildcard $(foreach file,Makefile Implies \
168                                            configure configure.in,\
169                                       $(addsuffix /$(file),$(sysdep_dirs)))) \
170                  $(+sysdep-dist)
172 +tsrcs := $(+tsrcs) $(+sysdep-tsrcs)
174 define autoconf-it
175 autoconf $(ACFLAGS) $< > $@.new
176 mv -f $@.new $@
177 test ! -d CVS || cvs commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
178 endef
180 configure: configure.in aclocal.m4; $(autoconf-it)
181 %/configure: %/configure.in aclocal.m4; $(autoconf-it)
183 .PHONY: dist
184 dist: $(tardir).tar.gz $(tardir)-crypt.tar.gz
186 $(tardir)-crypt.tar.gz: crypt/crypt.tar.gz
187         ln $< $@
188 crypt/%: FORCE
189         $(MAKE) -C $(@D) $(@F)
190 FORCE:
192 subdir_dist: dist.tar
193 dist.tar: $(tardir) $(+tsrcs)
194         tar chvf $@ $(addprefix $(tardir)/,$(filter-out $(tardir),$^))
196 $(tardir).tar: dist.tar subdir_dist
197         tar xfv $< -C /tmp | doschk
198         tar covf $@ -C /tmp $(tardir)
199         -rm -fr /tmp/$(tardir) &
201 %.Z: %
202         compress -c $< > $@
204 %.gz: %
205         gzip -9 -v -c $< > $@
207 foo:=$(shell echo subdirs=$(subdirs) >&2)
208 dist-subdirs := $(addprefix dist-,$(subdirs)) # dist-manual
209 .PHONY: subdir_dist $(dist-subdirs)
210 subdir_dist: $(dist-subdirs)
211 $(dist-subdirs):
212         $(MAKE) -C $(patsubst dist-%,%,$@) dist
214 # This is here instead of in Makefile so it can use $(release) and $(version).
215 README: README.template version.c
216         -rm -f $@
217         sed -e 's/RELEASE/$(release)/' -e 's/VERSION/$(version)/' < $< > $@
218 # Make it unwritable so I won't change it by mistake.
219         chmod 444 $@
220         test ! -d CVS || cvs commit -m'Remade for $(release)-$(version)' $@
223 endif   # Subdirectory vs. parent makefile
225 # Get these things out of the environment because they take up lots of space.
226 unexport distribute generated
228 # Fnord.
229 export inhibit_mach_syscalls=t
230 export no_deps=t
231 export inhibit_interface_rules=t