1 # Copyright (C) 1991, 1992 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 -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 echo-distinfo \
48 all-headers := $(patsubst +header+%,%,$(filter +header+%,$(+distinfo)))
49 +subdir-nodist := $(patsubst +nodist+%,%,$(filter +nodist+%,$(+distinfo)))
50 +subdir-headers := $(filter-out $(headers),$(all-headers))
52 foo:=$(shell echo 'IS THIS WORKING??? all-headers=$(all-headers)' >&2)
54 # Find all sysdep sources and headers.
55 +maybe-sysdeps := $(sources) $(sources:.c=.s) $(sources:.c=.S) $(all-headers) \
56 $(filter %.c %.S %.s %.h,$(distribute))
57 foo:=$(shell echo '+maybe-sysdeps=$(+maybe-sysdeps)'>&2)
58 # Find all the files that have a stub or generic version.
59 try-sysdeps := $(foreach dir,$(..)sysdeps/stub $(..)sysdeps/generic,\
60 $(addprefix $(dir)/,$(+maybe-sysdeps)))
61 foo:=$(shell echo 'try-sysdeps=$(try-sysdeps)'>&2)
62 +sysdeps := $(wildcard $(try-sysdeps))
63 foo:=$(shell echo 'stub/generic +sysdeps=$(+sysdeps)'>&2)
64 +sysdep-names := $(sort $(notdir $(+sysdeps)))
65 foo:=$(shell echo '+sysdep-names=$(+sysdep-names)' >&2)
67 # Now find all the sysdep versions of those files.
68 +sysdeps := $(wildcard $(foreach dir,$(sysdep_dirs) $(source_dirs),\
69 $(addprefix $(dir)/, \
71 $(+sysdep-names:.c=.s) \
72 $(+sysdep-names:.c=.S) \
76 # Source and header files to go in the distribution tar file.
78 .S.s := $(wildcard $(sources:.c=.S) $(sources:.c=.s))
79 sources := $(filter-out $(addsuffix .c,$(basename $(.S.s))),$(sources)) $(.S.s)
81 +out := $(patsubst %.S,%.c,$(+sysdep-names:.s=.c)) \
82 $(addsuffix .c,$(sysdep_routines)) \
84 foo:=$(shell echo '+out=$(+out)' >&2; echo foofoo >&2)
85 +tsrcs := $(filter-out $(+out) $(addprefix %/,$(+out)), \
86 $(sources) $(all-headers) $(distribute)) \
88 foo:=$(shell echo made +tsrcs >&2)
89 +tsrcs := $(sort $(filter-out $(dont_distribute),$(+tsrcs)))
90 foo:=$(shell echo '+tsrcs=$(+tsrcs)'>&2)
91 foo:=$(shell echo foobie, dammit! >&2)
94 rel+vers := $(shell sed -n -e 's/^.*libc_release.*\"\([^"]*\)";$$/\1/p' \
95 -e 's/^.*libc_version.*\"\([^"]*\)";$$/\1/p' \
97 release := $(word 1,$(rel+vers))
98 version := $(word 2,$(rel+vers))
99 tardir := glibc-$(version)
105 +tsrcs := $(+tsrcs) \
109 $(MAKE) -f $< $@ -o subdir_TAGS
113 foo:=$(shell echo subdir foo >&2)
115 +tsrcs := Makefile $(+tsrcs) \
116 $(addsuffix .c,$(others) $(tests)) \
117 $(wildcard $(addsuffix .input,$(tests)) \
118 $(addsuffix .args,$(tests)))
119 +tardeps := $(strip $(+tsrcs))
120 +tsrcs := $(addprefix $(tardir)/$(subdir)/,$(+tardeps))
125 dist: $(..)$(tardir) $(+tardeps)
126 @cd ..; if test -f dist.tar; then c=u; else c=c; fi; \
127 $(+cmdecho) "cd ..; tar $${c}h$(verbose)f dist.tar ..."; \
128 tar $${c}h$(verbose)f dist.tar $(+tsrcs)
130 else # Parent makefile.
132 # Find what other things sysdep directories want to distribute.
134 foo:=$(shell echo parent foobie>&2)
135 +sysdep-distfiles := $(wildcard $(addsuffix /Dist,$(sysdep_dirs)))
136 foo:=$(shell echo +sysdep-distfiles='$(+sysdep-distfiles)'>&2)
137 sysdep-Subdir-files := $(wildcard $(addsuffix /Subdirs,$(sysdep_dirs)))
138 ifdef sysdep-Subdir-files
139 subdirs := $(sort $(subdirs) $(shell cat $(sysdep-Subdir-files)))
141 +sysdep-dist := $(foreach file,$(+sysdep-distfiles),\
142 $(addprefix $(dir $(file)),$(shell cat $(file)))) \
143 $(+sysdep-distfiles) \
144 $(sysdep-Subdir-files)
145 foo:=$(shell echo '+sysdep-dist=$(+sysdep-dist)' >&2)
147 subdirs := $(filter-out crypt,$(subdirs))
149 +sysdep-tsrcs := $(wildcard $(foreach file,Makefile Implies,\
150 $(addsuffix /$(file),$(sysdep_dirs)))) \
153 +tsrcs := $(+tsrcs) $(+sysdep-tsrcs)
156 # N.B.: The order in which these are done matters (so don't use -j).
157 MAKEFLAGS = -j1 # I wonder if that works.
158 dist: dist.tar subdir_dist de-.. dist.tar.Z \
159 $(tardir).tar.Z $(tardir)-crypt.tar.Z
161 $(tardir).tar.Z: dist.tar.Z
164 $(tardir)-crypt.tar.Z: crypt/crypt.tar.Z
167 $(MAKE) -C $(@D) $(@F)
170 dist.tar: $(tardir) $(+tsrcs)
171 tar ch$(verbose)f $@ $(addprefix $(tardir)/,$(filter-out $(tardir),$^))
175 tar cf $< -C /tmp $(tardir)
176 -rm -fr /tmp/$(tardir) &
181 foo:=$(shell echo 'subdirs=$(subdirs)' >&2)
182 dist-subdirs := $(addprefix dist-,$(subdirs)) # dist-manual
183 .PHONY: subdir_dist $(dist-subdirs)
184 subdir_dist: $(dist-subdirs)
186 $(MAKE) -C $(patsubst dist-%,%,$@) dist
188 endif # Subdirectory vs. parent makefile
190 # Get these things out of the environment because they take up lots of space.
191 unexport distribute sources