1 # Copyright (C) 1991, 1992, 1993 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 first generated='$(generated)' >&2)
31 generated := $(foreach file,$(filter $(objpfx)%,$(generated)),\
32 $(file:$(objpfx)%=%) $(file)) \
33 $(filter-out $(objpfx)%,$(generated))
34 foo:=$(shell echo generated='$(generated)' >&2)
37 foo:=$(shell echo 'distribute=$(distribute)'>&2)
38 foo:=$(shell echo 'foobar=$(filter %.c %.S %.s %.h,$(distribute))'>&2)
41 # Find all sysdep directories.
42 export sysdep_dirs := $(shell find $(..)sysdeps -type d -print)
44 # Defined by the parent.
45 sysdep_dirs := $(addprefix $(..),$(sysdep_dirs))
48 # Makefiles can define `source_dirs' to list nonstandard directories
49 # where source files might be found.
52 all-headers = $(headers)
54 +distinfo := $(shell MAKEFLAGS= MFLAGS= $(MAKE) -s no_deps=t echo-distinfo \
56 all-headers := $(patsubst +header+%,%,$(filter +header+%,$(+distinfo)))
57 +subdir-nodist := $(patsubst +nodist+%,%,$(filter +nodist+%,$(+distinfo)))
58 +subdir-headers := $(filter-out $(headers),$(all-headers))
60 foo:=$(shell echo 'IS THIS WORKING??? all-headers=$(all-headers)' >&2)
62 # Find all sysdep sources and headers.
63 +maybe-sysdeps := $(sources) $(sources:.c=.s) $(sources:.c=.S) $(all-headers) \
64 $(filter %.c %.S %.s %.h,$(distribute))
65 foo:=$(shell echo '+maybe-sysdeps=$(+maybe-sysdeps)'>&2)
66 # Find all the files that have a stub or generic version.
67 try-sysdeps := $(foreach dir,$(..)sysdeps/stub $(..)sysdeps/generic,\
68 $(addprefix $(dir)/,$(+maybe-sysdeps)))
69 foo:=$(shell echo 'try-sysdeps=$(try-sysdeps)'>&2)
70 +sysdeps := $(wildcard $(try-sysdeps))
71 foo:=$(shell echo 'stub/generic +sysdeps=$(+sysdeps)'>&2)
72 +sysdep-names := $(sort $(notdir $(+sysdeps)))
73 foo:=$(shell echo '+sysdep-names=$(+sysdep-names)' >&2)
75 # Now find all the sysdep versions of those files.
76 +sysdeps := $(wildcard $(foreach dir,$(sysdep_dirs) $(source_dirs),\
77 $(addprefix $(dir)/, \
79 $(+sysdep-names:.c=.s) \
80 $(+sysdep-names:.c=.S) \
84 # Source and header files to go in the distribution tar file.
86 .S.s := $(wildcard $(sources:.c=.S) $(sources:.c=.s))
87 sources := $(filter-out $(addsuffix .c,$(basename $(.S.s))),$(sources)) $(.S.s)
89 +out := $(patsubst %.S,%.c,$(+sysdep-names:.s=.c)) \
90 $(addsuffix .c,$(sysdep_routines)) \
92 #foo:=$(shell echo '+out=$(+out)' >&2; echo foofoo >&2)
93 +tsrcs := $(filter-out $(+out) $(addprefix %/,$(+out)), \
94 $(sources) $(all-headers) $(distribute)) \
96 foo:=$(shell echo made +tsrcs >&2)
97 foo:=$(shell echo generated='$(generated)' >&2)
98 +tsrcs := $(sort $(filter-out $(generated),$(+tsrcs)))
99 foo:=$(shell echo '+tsrcs=$(+tsrcs)'>&2)
100 foo:=$(shell echo foobie, dammit! >&2)
103 rel+vers := $(shell sed -n -e 's/^.*libc_release.*\"\([^"]*\)";$$/\1/p' \
104 -e 's/^.*libc_version.*\"\([^"]*\)";$$/\1/p' \
106 release := $(word 1,$(rel+vers))
107 version := $(word 2,$(rel+vers))
108 export tardir := glibc-$(version)
114 +tsrcs := $(+tsrcs) \
118 $(MAKE) -f $< $@ -o subdir_TAGS
122 foo:=$(shell echo subdir foo >&2)
124 +tsrcs := Makefile $(+tsrcs) \
125 $(addsuffix .c,$(others) $(tests)) \
126 $(wildcard $(addsuffix .input,$(tests)) \
127 $(addsuffix .args,$(tests)))
128 +tardeps := $(strip $(+tsrcs))
129 +tsrcs := $(addprefix $(tardir)/$(subdir)/,$(+tardeps))
134 dist: $(..)$(tardir) $(+tardeps)
135 @cd ..; if test -f dist.tar; then c=u; else c=c; fi; \
136 $(+cmdecho) "cd ..; tar $${c}h$(verbose)f dist.tar ..."; \
137 tar $${c}h$(verbose)f dist.tar $(+tsrcs)
139 else # Parent makefile.
141 # Find what other things sysdep directories want to distribute.
143 foo:=$(shell echo parent foobie>&2)
144 +sysdep-distfiles := $(wildcard $(addsuffix /Dist,$(sysdep_dirs)))
145 foo:=$(shell echo +sysdep-distfiles='$(+sysdep-distfiles)'>&2)
146 sysdep-Subdir-files := $(wildcard $(addsuffix /Subdirs,$(sysdep_dirs)))
147 ifdef sysdep-Subdir-files
148 subdirs := $(sort $(subdirs) $(shell cat $(sysdep-Subdir-files)))
150 +sysdep-dist := $(foreach file,$(+sysdep-distfiles),\
151 $(addprefix $(dir $(file)),$(shell cat $(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)))) \
163 +tsrcs := $(+tsrcs) $(+sysdep-tsrcs)
165 %/configure: %/configure.in
166 autoconf $(ACFLAGS) $< > $@.new
170 dist: $(tardir).tar.z $(tardir)-crypt.tar.z
172 $(tardir)-crypt.tar.z: crypt/crypt.tar.z
175 $(MAKE) -C $(@D) $(@F)
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
184 tar covf $@ -C /tmp $(tardir)
185 -rm -fr /tmp/$(tardir) &
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)
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
203 sed -e 's/RELEASE/$(release)/' -e 's/VERSION/$(version)/' < $< > $@
204 # Make it unwritable so I won't change it by mistake.
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