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.
27 include $(..)Makeconfig
29 foo:=$(shell echo 'distribute=$(distribute)'>&2)
30 foo:=$(shell echo 'foobar=$(filter %.c %.S %.s %.h,$(distribute))'>&2)
33 # Find all sysdep directories.
34 export sysdep_dirs := $(shell find $(..)sysdeps -type d ! -name RCS -print)
36 # Defined by the parent.
37 sysdep_dirs := $(addprefix $(..),$(sysdep_dirs))
40 # Makefiles can define `source_dirs' to list nonstandard directories
41 # where source files might be found.
44 all-headers = $(headers)
46 +distinfo := $(shell MAKEFLAGS= MFLAGS= $(MAKE) -s no_deps=t no_ir=t \
47 echo-distinfo | grep -v '^make')
48 all-headers := $(patsubst +header+%,%,$(filter +header+%,$(+distinfo)))
49 # Ignore subdir headers without top-level indirections.
50 all-headers := $(sort $(headers) $(wildcard $(all-headers)))
51 +subdir-nodist := $(patsubst +nodist+%,%,$(filter +nodist+%,$(+distinfo)))
52 +subdir-headers := $(filter-out $(headers),$(all-headers))
54 foo:=$(shell echo 'IS THIS WORKING??? all-headers=$(all-headers)' >&2)
56 # Find all sysdep sources and headers.
57 +maybe-sysdeps := $(sources) $(sources:.c=.s) $(sources:.c=.S) $(all-headers) \
58 $(filter %.c %.S %.s %.h %.sub,$(distribute))
59 foo:=$(shell echo '+maybe-sysdeps=$(+maybe-sysdeps)'>&2)
60 # Find all the files that have a stub or generic version.
61 try-sysdeps := $(foreach dir,$(..)sysdeps/stub $(..)sysdeps/generic,\
62 $(addprefix $(dir)/,$(+maybe-sysdeps)))
63 foo:=$(shell echo 'try-sysdeps=$(try-sysdeps)'>&2)
64 +sysdeps := $(wildcard $(try-sysdeps))
65 foo:=$(shell echo 'stub/generic +sysdeps=$(+sysdeps)'>&2)
66 +sysdep-names := $(sort $(notdir $(+sysdeps)))
67 foo:=$(shell echo '+sysdep-names=$(+sysdep-names)' >&2)
69 # Now find all the sysdep versions of those files.
70 +sysdeps := $(wildcard $(foreach dir,$(sysdep_dirs) $(source_dirs),\
71 $(addprefix $(dir)/, \
73 $(+sysdep-names:.c=.s) \
74 $(+sysdep-names:.c=.S) \
78 # Source and header files to go in the distribution tar file.
80 .S.s := $(wildcard $(sources:.c=.S) $(sources:.c=.s))
81 sources := $(filter-out $(addsuffix .c,$(basename $(.S.s))),$(sources)) $(.S.s)
83 +out := $(patsubst %.S,%.c,$(+sysdep-names:.s=.c)) \
84 $(addsuffix .c,$(sysdep_routines)) \
86 #foo:=$(shell echo '+out=$(+out)' >&2; echo foofoo >&2)
87 +tsrcs := $(filter-out $(+out) $(addprefix %/,$(+out)), \
88 $(sources) $(all-headers) $(distribute)) \
90 foo:=$(shell echo made +tsrcs >&2)
91 foo:=$(shell echo generated='$(generated)' >&2)
92 +tsrcs := $(sort $(filter-out $(generated),$(+tsrcs)))
93 foo:=$(shell echo '+tsrcs=$(+tsrcs)'>&2)
94 foo:=$(shell echo foobie, dammit! >&2)
97 rel+vers := $(shell sed -n -e 's/^.*libc_release.*\"\([^"]*\)";$$/\1/p' \
98 -e 's/^.*libc_version.*\"\([^"]*\)";$$/\1/p' \
100 release := $(word 1,$(rel+vers))
101 version := $(word 2,$(rel+vers))
102 export tardir := glibc-$(version)
105 $(..)glibc-$(version):
108 +tsrcs := $(+tsrcs) \
112 $(MAKE) -f $< $@ -o subdir_TAGS
116 foo:=$(shell echo subdir foo >&2)
118 +tsrcs := Makefile $(+tsrcs) \
119 $(addsuffix .c,$(others) $(tests)) \
120 $(wildcard $(addsuffix .input,$(tests)) \
121 $(addsuffix .args,$(tests)))
122 +tardeps := $(strip $(+tsrcs))
123 +tsrcs := $(addprefix $(tardir)/$(subdir)/,$(+tardeps))
128 dist: $(..)$(tardir) $(+tardeps)
129 @cd ..; if test -f dist.tar; then c=u; else c=c; fi; \
130 $(+cmdecho) "cd ..; tar $${c}h$(verbose)f dist.tar ..."; \
131 tar $${c}h$(verbose)f dist.tar $(+tsrcs)
133 else # Parent makefile.
135 # Find what other things sysdep directories want to distribute.
137 foo:=$(shell echo parent foobie>&2)
138 +sysdep-distfiles := $(wildcard $(addsuffix /Dist,$(sysdep_dirs)))
139 foo:=$(shell echo +sysdep-distfiles='$(+sysdep-distfiles)'>&2)
140 sysdep-Subdir-files := $(wildcard $(addsuffix /Subdirs,$(sysdep_dirs)))
141 ifdef sysdep-Subdir-files
142 subdirs := $(sort $(subdirs) $(shell cat $(sysdep-Subdir-files)))
144 +sysdep-dist := $(foreach file,$(+sysdep-distfiles),\
145 $(addprefix $(dir $(file)),$(shell cat $(file)))) \
146 $(+sysdep-distfiles) \
147 $(sysdep-Subdir-files)
148 foo:=$(shell echo '+sysdep-dist=$(+sysdep-dist)' >&2)
150 subdirs := $(filter-out crypt,$(subdirs))
152 +sysdep-tsrcs := $(wildcard $(foreach file,Makefile Implies \
153 configure configure.in,\
154 $(addsuffix /$(file),$(sysdep_dirs)))) \
157 +tsrcs := $(+tsrcs) $(+sysdep-tsrcs)
159 %/configure: %/configure.in
160 autoconf $(ACFLAGS) $< > $@.new
164 dist: $(tardir).tar.gz $(tardir)-crypt.tar.gz
166 $(tardir)-crypt.tar.gz: crypt/crypt.tar.gz
169 $(MAKE) -C $(@D) $(@F)
172 subdir_dist: dist.tar
173 dist.tar: $(tardir) $(+tsrcs)
174 tar chvf $@ $(addprefix $(tardir)/,$(filter-out $(tardir),$^))
176 $(tardir).tar: dist.tar subdir_dist
177 tar xfv $< -C /tmp | doschk
178 tar covf $@ -C /tmp $(tardir)
179 -rm -fr /tmp/$(tardir) &
185 gzip -9 -v -c $< > $@
187 foo:=$(shell echo 'subdirs=$(subdirs)' >&2)
188 dist-subdirs := $(addprefix dist-,$(subdirs)) # dist-manual
189 .PHONY: subdir_dist $(dist-subdirs)
190 subdir_dist: $(dist-subdirs)
192 $(MAKE) -C $(patsubst dist-%,%,$@) dist
194 # This is here instead of in Makefile so it can use $(release) and $(version).
195 README: README.template version.c
197 sed -e 's/RELEASE/$(release)/' -e 's/VERSION/$(version)/' < $< > $@
198 # Make it unwritable so I won't change it by mistake.
202 endif # Subdirectory vs. parent makefile
204 # Get these things out of the environment because they take up lots of space.
205 unexport distribute generated
208 export inhibit_mach_syscalls=t
210 export inhibit_interface_rules=t