1 # Copyright (C) 1991-2001, 2002 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 Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the 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 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, write to the Free
16 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 # Make the value empty so ifdef fails if it's $(-subdir).
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)
36 # Find all sysdep directories.
37 export sysdep_dirs := $(shell find $(..)sysdeps -type d ! -name bits \
38 ! -name CVS ! -name RCS \
41 # Defined by the parent.
42 sysdep_dirs := $(addprefix $(..),$(sysdep_dirs))
45 # Don't distribute add-on subdirs.
46 subdirs := $(filter-out $(add-ons),$(subdirs))
48 # Make sure both aout and elf get in, whichever is in use.
51 sysdep-Subdir-files := $(wildcard $(addsuffix /Subdirs,$(sysdep_dirs)))
52 ifdef sysdep-Subdir-files
53 subdirs := $(sort $(subdirs) \
54 $(shell sed -e 's/\#.*$$//' $(sysdep-Subdir-files)))
58 # Makefiles can define `source_dirs' to list nonstandard directories
59 # where source files might be found.
62 all-headers = $(filter-out $(sysdep_headers),$(headers))
64 +distinfo := $(shell MAKEFLAGS= MFLAGS= $(MAKE) -s no_deps=t \
65 inhibit_interface_rules=t inhibit_mach_syscalls=t \
66 inhibit_timezone_rules=t \
67 subdirs='$(subdirs)' echo-distinfo | grep -v '^make')
68 foo:=$(shell echo>&2 '+distinfo=$(+distinfo)')
69 all-headers := $(patsubst +header+%,%,$(filter +header+%,$(+distinfo)))
70 # Ignore subdir headers without top-level indirections.
71 all-headers := $(sort $(headers) \
72 $(patsubst include/%,%,\
73 $(wildcard $(addprefix include/,\
75 # Filter out names like ../conf/portability.h that would point outside
76 # the source directory.
77 all-headers := $(filter-out ../%,$(all-headers))
78 +subdir-nodist := $(patsubst +nodist+%,%,$(filter +nodist+%,$(+distinfo)))
80 foo:=$(shell echo 'IS THIS WORKING??? all-headers=$(all-headers)' >&2)
82 sources += $(addsuffix .c,$(elided-routines) \
83 $(foreach l,$(extra-libs),$($l-routines)))
85 sources += $(addsuffix .c, $(filter-out $(elided-routines), $(tests)))
87 # Find all sysdep sources and headers.
88 +maybe-sysdeps := $(sources) $(sources:.c=.s) $(sources:.c=.S) $(all-headers) \
89 $(filter %.c %.S %.s %.h %.sub,$(distribute))
90 foo:=$(shell echo '+maybe-sysdeps=$(+maybe-sysdeps)'>&2)
91 # Find all the files that have a generic version.
92 generic-dirs = $(..)sysdeps/generic $(..)sysdeps/ieee754 \
93 $(..)sysdeps/ieee754/flt-32 $(..)sysdeps/ieee754/dbl-64 \
94 $(..)sysdeps/ieee754/ldbl-96 $(..)sysdeps/ieee754/ldbl-128
95 try-sysdeps := $(foreach dir,$(generic-dirs),\
96 $(addprefix $(dir)/,$(+maybe-sysdeps)))
97 foo:=$(shell echo 'try-sysdeps=$(try-sysdeps)'>&2)
98 +sysdeps := $(wildcard $(try-sysdeps))
99 foo:=$(shell echo 'generic +sysdeps=$(+sysdeps)'>&2)
100 +sysdep-names := $(sort $(foreach dir, $(generic-dirs),\
101 $(patsubst $(dir)/%,%,\
102 $(filter $(dir)/%,$(+sysdeps)))))
103 foo:=$(shell echo '+sysdep-names=$(+sysdep-names)' >&2)
106 vpath % $(subdir-dirs)
109 # Now find all the sysdep versions of those files.
110 +sysdeps := $(foreach dir,$(sysdep_dirs) $(source_dirs),\
111 $(wildcard $(addprefix $(dir)/, \
113 $(+sysdep-names:.c=.s) \
114 $(+sysdep-names:.c=.S) \
118 # Source and header files to go in the distribution tar file.
120 .S.s := $(wildcard $(sources:.c=.S) $(sources:.c=.s))
121 sources := $(filter-out $(addsuffix .c,$(basename $(.S.s))),$(sources)) $(.S.s)
123 +out := $(patsubst %.S,%.c,$(+sysdep-names:.s=.c)) \
124 $(addsuffix .c,$(sysdep_routines)) \
125 $(+subdir-nodist) $(dont_distribute)
126 foo:=$(shell echo '+out=$(+out)' >&2; echo foofoo >&2)
127 +tsrcs := $(filter-out $(+out), $(sources) $(all-headers)) $(+sysdeps)
128 foo:=$(shell echo 'made +tsrcs=$(+tsrcs)'>&2)
129 foo:=$(shell echo generated='$(generated)' >&2)
130 #generated := $(sort $(generated) $(generated:.S=.c) $(generated:.s=.c))
131 #foo:=$(shell echo now generated='$(generated)' >&2)
132 +tsrcs := $(filter-out $(generated),$(+tsrcs))
133 +tsrcs := $(sort $(filter-out $(+out),$(+tsrcs) $(distribute)))
134 foo:=$(shell echo '+tsrcs=$(+tsrcs)'>&2)
135 foo:=$(shell echo foobie, dammit! >&2)
138 export tardir := glibc-$(version)
141 $(..)glibc-$(version):
144 #+tsrcs := $(+tsrcs) \
148 $(MAKE) -f $< $@ -o subdir_TAGS
152 foo:=$(shell echo subdir foo >&2)
154 +tsrcs := Makefile $(wildcard Versions) $(wildcard Depend) $(+tsrcs) \
155 $(addsuffix .c,$(others) $(test-srcs)) \
156 $(wildcard $(addsuffix .input,$(tests) $(test-srcs)))
157 +tardeps := $(strip $(+tsrcs))
162 dist: $(..)$(tardir) $(+tardeps)
163 @cd ..; if test -f dist.tar; then c=u; else c=c; fi; \
164 $(+cmdecho) "cd ..; tar $${c}h$(verbose)f dist.tar ..."; \
165 tar $${c}h$(verbose)f dist.tar \
166 $(addprefix $(tardir)/$(subdir)/,$(filter-out $< ../%,$^)) \
167 $(addprefix $(tardir)/,\
168 $(patsubst ../%,%,$(filter-out $<,$(filter ../%,$^))))
170 else # Parent makefile.
172 # Find what other things sysdep directories want to distribute.
174 foo:=$(shell echo parent foobie>&2)
175 +sysdep-distfiles := $(wildcard $(addsuffix /Dist,$(sysdep_dirs)))
176 foo:=$(shell echo +sysdep-distfiles='$(+sysdep-distfiles)'>&2)
177 +sysdep-dist := $(foreach file,$(+sysdep-distfiles),\
178 $(addprefix $(dir $(file)), \
179 $(shell sed -e 's/\#.*$$//' $(file)))) \
180 $(+sysdep-distfiles) \
181 $(sysdep-Subdir-files)
182 foo:=$(shell echo '+sysdep-dist=$(+sysdep-dist)' >&2)
184 +sysdep-tsrcs := $(wildcard $(foreach file,Makefile Makeconfig Implies \
185 configure configure.in Versions\
186 syscalls.list libm-test-ulps,\
187 $(addsuffix /$(file),$(sysdep_dirs)))) \
190 +tsrcs := $(+tsrcs) $(+sysdep-tsrcs) $(wildcard $(+sysdep-names:%=include/%))
192 ifeq ($(with-cvs),yes)
194 autoconf $(ACFLAGS) $< > $@.new
196 test ! -d CVS || cvs $(CVSOPTS) commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
200 autoconf $(ACFLAGS) $< > $@.new
205 configure: configure.in aclocal.m4; $(autoconf-it)
206 %/configure: %/configure.in aclocal.m4; $(autoconf-it)
208 dist: $(tardir).tar.gz
210 subdir_dist: dist.tar
211 dist.tar: README $(tardir) $(+tsrcs)
212 tar chvf $@ $(addprefix $(tardir)/,$(filter-out $(tardir),$^))
214 $(tardir).tar: dist.tar subdir_dist
215 @echo Files listed here have names exceeding 14 chars.
216 tar xfv $< -C $${TMPDIR-/tmp} | sed -n '/[^/]\{15,\}/p'
217 tar covf $@ -C $${TMPDIR-/tmp} $(tardir)
218 -rm -fr $${TMPDIR-/tmp}/$(tardir) dist.tar &
224 gzip -9 -v -c $< > $@
226 foo:=$(shell echo subdirs=$(subdirs) >&2)
227 dist-subdirs := $(addprefix dist-,$(subdirs)) # dist-manual
228 .PHONY: subdir_dist $(dist-subdirs)
229 subdir_dist: $(dist-subdirs)
231 $(MAKE) -C $(patsubst dist-%,%,$@) dist
233 # This is here instead of in Makefile so it can use $(release) and $(version).
234 README: README.template version.h
236 sed -e 's/RELEASE/$(release)/' -e 's/VERSION/$(version)/' < $< > $@
237 # Make it unwritable so I won't change it by mistake.
239 ifeq ($(with-cvs),yes)
240 test ! -d CVS || cvs $(CVSOPTS) commit -m'Remade for $(release)-$(version)' $@
244 endif # Subdirectory vs. parent makefile
246 # Get these things out of the environment because they take up lots of space.
247 unexport distribute generated
250 export inhibit_mach_syscalls=t
252 export inhibit_interface_rules=t