(Dynamic Allocation and C): Say global variables are like static.
[glibc.git] / Make-dist
bloba63fd3fa6d2bf900ef3bd89da8e774824bdcabf6
1 # Copyright (C) 1991, 1992, 1993, 1994 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 +tsrcs := $(sort $(filter-out $(generated),$(+tsrcs)))
102 foo:=$(shell echo '+tsrcs=$(+tsrcs)'>&2)
103 foo:=$(shell echo foobie, dammit! >&2)
105 ifndef tardir
106 rel+vers := $(shell sed -n -e 's/^.*libc_release.*\"\([^"]*\)";$$/\1/p' \
107                            -e 's/^.*libc_version.*\"\([^"]*\)";$$/\1/p' \
108                     < $(..)version.c)
109 release := $(word 1,$(rel+vers))
110 version := $(word 2,$(rel+vers))
111 export tardir := glibc-$(version)
112 endif
114 $(..)glibc-$(version):
115         ln -s . $@
117 +tsrcs := $(+tsrcs) \
118           TAGS
119 .PHONY: TAGS
120 TAGS: $(..)MakeTAGS
121         $(MAKE) -f $< $@ -o subdir_TAGS
123 ifdef      subdir
125 foo:=$(shell echo subdir foo >&2)
127 +tsrcs := Makefile $(+tsrcs)                            \
128           $(addsuffix .c,$(others) $(tests))            \
129           $(wildcard $(addsuffix .input,$(tests))       \
130           $(addsuffix .args,$(tests)))
131 +tardeps := $(strip $(+tsrcs))
132 +tsrcs := $(addprefix $(tardir)/$(subdir)/,$(+tardeps))
134 verbose = v
136 .PHONY: dist
137 dist: $(..)$(tardir) $(+tardeps)
138         @cd ..; if test -f dist.tar; then c=u; else c=c; fi;    \
139         $(+cmdecho) "cd ..; tar $${c}h$(verbose)f dist.tar ...";        \
140         tar $${c}h$(verbose)f dist.tar $(+tsrcs)
142 else    # Parent makefile.
144 # Find what other things sysdep directories want to distribute.
146 foo:=$(shell echo parent foobie>&2)
147 +sysdep-distfiles := $(wildcard $(addsuffix /Dist,$(sysdep_dirs)))
148 foo:=$(shell echo +sysdep-distfiles='$(+sysdep-distfiles)'>&2)
149 +sysdep-dist := $(foreach file,$(+sysdep-distfiles),\
150                           $(addprefix $(dir $(file)), \
151                                       $(shell sed -e 's/\#.*$$//' $(file)))) \
152                 $(+sysdep-distfiles) \
153                 $(sysdep-Subdir-files)
154 foo:=$(shell echo '+sysdep-dist=$(+sysdep-dist)' >&2)
156 subdirs := $(filter-out crypt,$(subdirs))
158 +sysdep-tsrcs := $(wildcard $(foreach file,Makefile Implies \
159                                            configure configure.in,\
160                                       $(addsuffix /$(file),$(sysdep_dirs)))) \
161                  $(+sysdep-dist)
163 +tsrcs := $(+tsrcs) $(+sysdep-tsrcs)
165 %/configure: %/configure.in
166         autoconf $(ACFLAGS) $< > $@.new
167         mv -f $@.new $@
169 .PHONY: dist
170 dist: $(tardir).tar.gz $(tardir)-crypt.tar.gz
172 $(tardir)-crypt.tar.gz: crypt/crypt.tar.gz
173         ln $< $@
174 crypt/%: FORCE
175         $(MAKE) -C $(@D) $(@F)
176 FORCE:
178 subdir_dist: dist.tar
179 dist.tar: $(tardir) $(+tsrcs)
180         tar chvf $@ $(addprefix $(tardir)/,$(filter-out $(tardir),$^))
182 $(tardir).tar: dist.tar subdir_dist
183         tar xfv $< -C /tmp | doschk
184         tar covf $@ -C /tmp $(tardir)
185         -rm -fr /tmp/$(tardir) &
187 %.Z: %
188         compress -c $< > $@
190 %.gz: %
191         gzip -9 -v -c $< > $@
193 foo:=$(shell echo subdirs=$(subdirs) >&2)
194 dist-subdirs := $(addprefix dist-,$(subdirs)) # dist-manual
195 .PHONY: subdir_dist $(dist-subdirs)
196 subdir_dist: $(dist-subdirs)
197 $(dist-subdirs):
198         $(MAKE) -C $(patsubst dist-%,%,$@) dist
200 # This is here instead of in Makefile so it can use $(release) and $(version).
201 README: README.template version.c
202         -rm -f $@
203         sed -e 's/RELEASE/$(release)/' -e 's/VERSION/$(version)/' < $< > $@
204 # Make it unwritable so I won't change it by mistake.
205         chmod 444 $@
208 endif   # Subdirectory vs. parent makefile
210 # Get these things out of the environment because they take up lots of space.
211 unexport distribute generated
213 # Fnord.
214 export inhibit_mach_syscalls=t
215 export no_deps=t
216 export inhibit_interface_rules=t