Mon May 27 10:10:00 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[glibc.git] / Make-dist
blobd3881429dff51ce200d36fffe766e30809db3544
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 = $(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 # Find all sysdep sources and headers.
66 +maybe-sysdeps := $(sources) $(sources:.c=.s) $(sources:.c=.S) $(all-headers) \
67                   $(filter %.c %.S %.s %.h %.sub,$(distribute))
68 foo:=$(shell echo '+maybe-sysdeps=$(+maybe-sysdeps)'>&2)
69 # Find all the files that have a stub or generic version.
70 try-sysdeps := $(foreach dir,$(..)sysdeps/stub $(..)sysdeps/generic,\
71                              $(addprefix $(dir)/,$(+maybe-sysdeps)))
72 foo:=$(shell echo 'try-sysdeps=$(try-sysdeps)'>&2)
73 +sysdeps := $(wildcard $(try-sysdeps))
74 foo:=$(shell echo 'stub/generic +sysdeps=$(+sysdeps)'>&2)
75 +sysdep-names := $(sort $(notdir $(+sysdeps)))
76 foo:=$(shell echo '+sysdep-names=$(+sysdep-names)' >&2)
78 # Now find all the sysdep versions of those files.
79 +sysdeps := $(wildcard $(foreach dir,$(sysdep_dirs) $(source_dirs),\
80                                  $(addprefix $(dir)/, \
81                                              $(+sysdep-names) \
82                                              $(+sysdep-names:.c=.s) \
83                                              $(+sysdep-names:.c=.S) \
84                                   )))
87 # Source and header files to go in the distribution tar file.
89 .S.s := $(wildcard $(sources:.c=.S) $(sources:.c=.s))
90 sources := $(filter-out $(addsuffix .c,$(basename $(.S.s))),$(sources)) $(.S.s)
92 +out := $(patsubst %.S,%.c,$(+sysdep-names:.s=.c)) \
93         $(addsuffix .c,$(sysdep_routines)) \
94         $(+subdir-nodist)
95 #foo:=$(shell echo '+out=$(+out)' >&2; echo foofoo >&2)
96 +tsrcs  := $(filter-out $(+out) $(addprefix %/,$(+out)), \
97                         $(sources) $(all-headers) $(distribute)) \
98            $(+sysdeps)
99 foo:=$(shell echo made +tsrcs >&2)
100 foo:=$(shell echo generated='$(generated)' >&2)
101 generated := $(sort $(generated) $(generated:.S=.c) $(generated:.s=.c))
102 foo:=$(shell echo now generated='$(generated)' >&2)
103 +tsrcs := $(sort $(filter-out $(generated),$(+tsrcs)))
104 foo:=$(shell echo '+tsrcs=$(+tsrcs)'>&2)
105 foo:=$(shell echo foobie, dammit! >&2)
107 ifndef tardir
108 -include $(common-objpfx)version.mk
109 export tardir := glibc-$(version)
110 endif
112 $(..)glibc-$(version):
113         ln -s . $@
115 +tsrcs := $(+tsrcs) \
116           TAGS
117 .PHONY: TAGS
118 TAGS: $(..)MakeTAGS
119         $(MAKE) -f $< $@ -o subdir_TAGS
121 ifdef      subdir
123 foo:=$(shell echo subdir foo >&2)
125 +tsrcs := Makefile $(+tsrcs)                            \
126           $(addsuffix .c,$(others) $(tests))            \
127           $(wildcard $(addsuffix .input,$(tests))       \
128           $(addsuffix .args,$(tests)))
129 +tardeps := $(strip $(+tsrcs))
130 +tsrcs := $(addprefix $(tardir)/$(subdir)/,$(+tardeps))
132 verbose = v
134 .PHONY: dist
135 dist: $(..)$(tardir) $(+tardeps)
136         @cd ..; if test -f dist.tar; then c=u; else c=c; fi;    \
137         $(+cmdecho) "cd ..; tar $${c}h$(verbose)f dist.tar ...";        \
138         tar $${c}h$(verbose)f dist.tar $(+tsrcs)
140 else    # Parent makefile.
142 # Find what other things sysdep directories want to distribute.
144 foo:=$(shell echo parent foobie>&2)
145 +sysdep-distfiles := $(wildcard $(addsuffix /Dist,$(sysdep_dirs)))
146 foo:=$(shell echo +sysdep-distfiles='$(+sysdep-distfiles)'>&2)
147 +sysdep-dist := $(foreach file,$(+sysdep-distfiles),\
148                           $(addprefix $(dir $(file)), \
149                                       $(shell sed -e 's/\#.*$$//' $(file)))) \
150                 $(+sysdep-distfiles) \
151                 $(sysdep-Subdir-files)
152 foo:=$(shell echo '+sysdep-dist=$(+sysdep-dist)' >&2)
154 subdirs := $(filter-out crypt,$(subdirs))
156 +sysdep-tsrcs := $(wildcard $(foreach file,Makefile Implies \
157                                            configure configure.in,\
158                                       $(addsuffix /$(file),$(sysdep_dirs)))) \
159                  $(+sysdep-dist)
161 +tsrcs := $(+tsrcs) $(+sysdep-tsrcs)
163 define autoconf-it
164 autoconf $(ACFLAGS) $< > $@.new
165 mv -f $@.new $@
166 test ! -d CVS || cvs commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
167 endef
169 configure: configure.in aclocal.m4; $(autoconf-it)
170 %/configure: %/configure.in aclocal.m4; $(autoconf-it)
172 .PHONY: dist
173 dist: $(tardir).tar.gz $(tardir)-crypt.tar.gz
175 $(tardir)-crypt.tar.gz: crypt/crypt.tar.gz
176         ln $< $@
177 crypt/%: FORCE
178         $(MAKE) -C $(@D) $(@F)
179 FORCE:
181 subdir_dist: dist.tar
182 dist.tar: $(tardir) $(+tsrcs)
183         tar chvf $@ $(addprefix $(tardir)/,$(filter-out $(tardir),$^))
185 $(tardir).tar: dist.tar subdir_dist
186         tar xfv $< -C /tmp | doschk
187         tar covf $@ -C /tmp $(tardir)
188         -rm -fr /tmp/$(tardir) &
190 %.Z: %
191         compress -c $< > $@
193 %.gz: %
194         gzip -9 -v -c $< > $@
196 foo:=$(shell echo subdirs=$(subdirs) >&2)
197 dist-subdirs := $(addprefix dist-,$(subdirs)) # dist-manual
198 .PHONY: subdir_dist $(dist-subdirs)
199 subdir_dist: $(dist-subdirs)
200 $(dist-subdirs):
201         $(MAKE) -C $(patsubst dist-%,%,$@) dist
203 # This is here instead of in Makefile so it can use $(release) and $(version).
204 README: README.template version.c
205         -rm -f $@
206         sed -e 's/RELEASE/$(release)/' -e 's/VERSION/$(version)/' < $< > $@
207 # Make it unwritable so I won't change it by mistake.
208         chmod 444 $@
209         test ! -d CVS || commit -m'Remade for $(release)-$(version)' $@
212 endif   # Subdirectory vs. parent makefile
214 # Get these things out of the environment because they take up lots of space.
215 unexport distribute generated
217 # Fnord.
218 export inhibit_mach_syscalls=t
219 export no_deps=t
220 export inhibit_interface_rules=t