1 # Copyright (C) 1991, 1992, 1993, 1994, 1995 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 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)))
47 # Makefiles can define `source_dirs' to list nonstandard directories
48 # where source files might be found.
51 all-headers = $(headers)
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))
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)/, \
82 $(+sysdep-names:.c=.s) \
83 $(+sysdep-names:.c=.S) \
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)) \
95 #foo:=$(shell echo '+out=$(+out)' >&2; echo foofoo >&2)
96 +tsrcs := $(filter-out $(+out) $(addprefix %/,$(+out)), \
97 $(sources) $(all-headers) $(distribute)) \
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)
108 rel+vers := $(shell sed -n -e 's/^.*libc_release.*\"\([^"]*\)";$$/\1/p' \
109 -e 's/^.*libc_version.*\"\([^"]*\)";$$/\1/p' \
111 release := $(word 1,$(rel+vers))
112 version := $(word 2,$(rel+vers))
113 export tardir := glibc-$(version)
116 $(..)glibc-$(version):
119 +tsrcs := $(+tsrcs) \
123 $(MAKE) -f $< $@ -o subdir_TAGS
127 foo:=$(shell echo subdir foo >&2)
129 +tsrcs := Makefile $(+tsrcs) \
130 $(addsuffix .c,$(others) $(tests)) \
131 $(wildcard $(addsuffix .input,$(tests)) \
132 $(addsuffix .args,$(tests)))
133 +tardeps := $(strip $(+tsrcs))
134 +tsrcs := $(addprefix $(tardir)/$(subdir)/,$(+tardeps))
139 dist: $(..)$(tardir) $(+tardeps)
140 @cd ..; if test -f dist.tar; then c=u; else c=c; fi; \
141 $(+cmdecho) "cd ..; tar $${c}h$(verbose)f dist.tar ..."; \
142 tar $${c}h$(verbose)f dist.tar $(+tsrcs)
144 else # Parent makefile.
146 # Find what other things sysdep directories want to distribute.
148 foo:=$(shell echo parent foobie>&2)
149 +sysdep-distfiles := $(wildcard $(addsuffix /Dist,$(sysdep_dirs)))
150 foo:=$(shell echo +sysdep-distfiles='$(+sysdep-distfiles)'>&2)
151 +sysdep-dist := $(foreach file,$(+sysdep-distfiles),\
152 $(addprefix $(dir $(file)), \
153 $(shell sed -e 's/\#.*$$//' $(file)))) \
154 $(+sysdep-distfiles) \
155 $(sysdep-Subdir-files)
156 foo:=$(shell echo '+sysdep-dist=$(+sysdep-dist)' >&2)
158 subdirs := $(filter-out crypt,$(subdirs))
160 +sysdep-tsrcs := $(wildcard $(foreach file,Makefile Implies \
161 configure configure.in,\
162 $(addsuffix /$(file),$(sysdep_dirs)))) \
165 +tsrcs := $(+tsrcs) $(+sysdep-tsrcs)
168 autoconf $(ACFLAGS) $< > $@.new
170 test ! -d CVS || cvs commit -m'Regenerated: autoconf $(ACFLAGS) $<' $@
173 configure: configure.in; $(autoconf-it)
174 %/configure: %/configure.in; $(autoconf-it)
177 dist: $(tardir).tar.gz $(tardir)-crypt.tar.gz
179 $(tardir)-crypt.tar.gz: crypt/crypt.tar.gz
182 $(MAKE) -C $(@D) $(@F)
185 subdir_dist: dist.tar
186 dist.tar: $(tardir) $(+tsrcs)
187 tar chvf $@ $(addprefix $(tardir)/,$(filter-out $(tardir),$^))
189 $(tardir).tar: dist.tar subdir_dist
190 tar xfv $< -C /tmp | doschk
191 tar covf $@ -C /tmp $(tardir)
192 -rm -fr /tmp/$(tardir) &
198 gzip -9 -v -c $< > $@
200 foo:=$(shell echo subdirs=$(subdirs) >&2)
201 dist-subdirs := $(addprefix dist-,$(subdirs)) # dist-manual
202 .PHONY: subdir_dist $(dist-subdirs)
203 subdir_dist: $(dist-subdirs)
205 $(MAKE) -C $(patsubst dist-%,%,$@) dist
207 # This is here instead of in Makefile so it can use $(release) and $(version).
208 README: README.template version.c
210 sed -e 's/RELEASE/$(release)/' -e 's/VERSION/$(version)/' < $< > $@
211 # Make it unwritable so I won't change it by mistake.
213 test ! -d CVS || commit -m'Remade for $(release)-$(version)' $@
216 endif # Subdirectory vs. parent makefile
218 # Get these things out of the environment because they take up lots of space.
219 unexport distribute generated
222 export inhibit_mach_syscalls=t
224 export inhibit_interface_rules=t