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.
20 You must use the parent or subdirectory Makefile, not this one directly.
31 include $(..)Makeconfig
33 foo:=$(shell echo 'distribute=$(distribute)'>&2)
34 foo:=$(shell echo 'foobar=$(filter %.c %.S %.s %.h,$(distribute))'>&2)
37 # Find all sysdep directories.
38 export sysdep_dirs := $(shell find $(..)sysdeps -type d -print)
40 # Defined by the parent.
41 sysdep_dirs := $(addprefix $(..),$(sysdep_dirs))
44 # Makefiles can define `source_dirs' to list nonstandard directories
45 # where source files might be found.
48 all-headers = $(headers)
50 +distinfo := $(shell MAKEFLAGS= MFLAGS= $(MAKE) -s no_deps=t echo-distinfo)
51 all-headers := $(patsubst +header+%,%,$(filter +header+%,$(+distinfo)))
52 +subdir-nodist := $(patsubst +nodist+%,%,$(filter +nodist+%,$(+distinfo)))
53 +subdir-headers := $(filter-out $(headers),$(all-headers))
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,$(distribute))
59 foo:=$(shell echo '+maybe-sysdeps=$(+maybe-sysdeps)'>&2)
60 +sysdeps := $(wildcard $(foreach dir,$(sysdep_dirs) $(source_dirs),\
61 $(addprefix $(dir)/,$(+maybe-sysdeps))))
63 # Source and header files to go in the distribution tar file.
65 .S.s := $(wildcard $(sources:.c=.S) $(sources:.c=.s))
66 sources := $(filter-out $(addsuffix .c,$(basename $(.S.s))),$(sources)) $(.S.s)
68 +sysdep-names := $(sort $(notdir $(+sysdeps)))
69 foo:=$(shell echo '+sysdep-names=$(+sysdep-names)' >&2)
70 +out := $(patsubst %.S,%.c,$(+sysdep-names:.s=.c)) \
71 $(addsuffix .c,$(sysdep_routines)) \
73 foo:=$(shell echo '+out=$(+out)' >&2; echo foofoo >&2)
74 +tsrcs := $(filter-out $(+out) $(addprefix %/,$(+out)), \
75 $(sources) $(all-headers) $(distribute)) \
77 foo:=$(shell echo made +tsrcs >&2)
78 +tsrcs := $(sort $(filter-out $(dont_distribute),$(+tsrcs)))
79 foo:=$(shell echo '+tsrcs=$(+tsrcs)'>&2)
80 foo:=$(shell echo foobie, dammit! >&2)
83 rel+vers := $(shell sed -n -e 's/^.*libc_release.*\"\([^"]*\)";$$/\1/p' \
84 -e 's/^.*libc_version.*\"\([^"]*\)";$$/\1/p' \
86 release := $(word 1,$(rel+vers))
87 version := $(word 2,$(rel+vers))
88 tardir := glibc-$(version)
96 foo:=$(shell echo subdir foo >&2)
98 +tsrcs := Makefile $(+tsrcs) \
99 $(addsuffix .c,$(others) $(tests)) \
100 $(wildcard $(addsuffix .input,$(tests)) \
101 $(addsuffix .args,$(tests)))
102 +tardeps := $(strip $(+tsrcs))
103 +tsrcs := $(addprefix $(tardir)/$(subdir)/,$(+tardeps))
106 dist: $(..)$(tardir) $(+tardeps)
107 @cd ..; if test -f dist.tar; then c=u; else c=c; fi; \
108 $(+cmdecho) "cd ..; tar $${c}h$(verbose)f dist.tar ..."; \
109 tar $${c}h$(verbose)f dist.tar $(+tsrcs)
111 else # Parent makefile.
113 # Find what other things sysdep directories want to distribute.
115 foo:=$(shell echo parent foobie>&2)
116 +sysdep-distfiles := $(wildcard $(addsuffix /Dist,$(sysdep_dirs)))
117 foo:=$(shell echo +sysdep-distfiles='$(+sysdep-distfiles)'>&2)
118 sysdep-Subdir-files := $(wildcard $(addsuffix /Subdirs,$(sysdep_dirs)))
119 ifdef sysdep-Subdir-files
120 subdirs := $(sort $(subdirs) $(shell cat $(sysdep-Subdir-files)))
122 +sysdep-dist := $(foreach file,$(+sysdep-distfiles),\
123 $(addprefix $(dir $(file)),$(shell cat $(file)))) \
124 $(+sysdep-distfiles) \
125 $(sysdep-Subdir-files)
126 foo:=$(shell echo '+sysdep-dist=$(+sysdep-dist)' >&2)
128 +sysdep-tsrcs := $(wildcard $(foreach file,Makefile Implies,\
129 $(addsuffix /$(file),$(sysdep_dirs)))) \
132 +tsrcs := $(distribute) $(+tsrcs) $(+sysdep-tsrcs)
135 # N.B.: The order in which these are done matters (so don't use -j).
136 MAKEFLAGS = -j1 # I wonder if that works.
137 dist: dist.tar subdir_dist de-.. dist.tar.Z
139 dist.tar: $(tardir) $(+tsrcs)
140 tar ch$(verbose)f $@ $(addprefix $(tardir)/,$(filter-out $(tardir),$^))
144 tar cf $< -C /tmp $(tardir)
145 -rm -fr /tmp/$(tardir)
147 README: README.template version.c
149 sed -e 's/RELEASE/$(release)/' -e 's/VERSION/$(version)/' < $< > $@
150 # Make it unwritable so I won't change it by mistake.
153 INSTALL: manual/maint.texinfo
154 makeinfo +no-validate +no-warn +no-headers $<
159 foo:=$(shell echo 'subdirs=$(subdirs)' >&2)
160 dist-subdirs := $(addprefix dist-,$(subdirs)) # dist-manual
161 .PHONY: subdir_dist $(dist-subdirs)
162 subdir_dist: $(dist-subdirs)
164 $(MAKE) -C $(patsubst dist-%,%,$@) dist
166 endif # Subdirectory vs. parent makefile
168 # Get these things out of the environment because they take up lots of space.
169 unexport distribute sources