]> git.ipfire.org Git - thirdparty/glibc.git/blame - MakeTAGS
[BZ #715]
[thirdparty/glibc.git] / MakeTAGS
CommitLineData
a334319f
UD
1# Make the TAGS files.
2# Copyright (C) 1992,1994,1995,1996,1998,2002,2003
3# Free Software Foundation, Inc.
4# This file is part of the GNU C Library.
5
6# The GNU C Library is free software; you can redistribute it and/or
7# modify it under the terms of the GNU Lesser General Public
8# License as published by the Free Software Foundation; either
9# version 2.1 of the License, or (at your option) any later version.
10
11# The GNU C Library is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14# Lesser General Public License for more details.
15
16# You should have received a copy of the GNU Lesser General Public
17# License along with the GNU C Library; if not, write to the Free
18# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19# 02111-1307 USA.
20
21# Make this the default goal.
22TAGS:
23
24ifdef subdir
25.. := ../
26endif
27
28include $(..)Makeconfig
29
30# Pass these to $(MAKE) calls to avoid source generation and such.
31sub-make-vars = generating=t no_deps=t
32
33ifndef tags_sources
34ifeq ($(subdir),ctype)
35# In most cases, we want the C source files to come before
36# the header files so tags for optimizing #define's in the
37# headers won't be put in the tags files, but for ctype,
38# the functions are just backup for the #define's in the header.
39tags_sources = $(all-headers) $(all-sources) $(all-dist)
40else # Not ctype.
41tags_sources = $(all-sources) $(all-headers) $(all-dist)
42endif # ctype
43endif # No tags_sources
44
45sysdep-dirs := $(full_config_sysdirs)
46
47ifndef sysdep_dirs
48# Find all sysdep directories.
49sysdep_dirs := $(shell find $(..)sysdeps \
50 $(wildcard \
51 $(patsubst %,$(..)%/sysdeps,$(add-ons))) \
52 -type d ! -name RCS ! -name CVS \
53 ! -name SCCS -print)
54endif
55
56# Find all sysdep dirs there are, but putting the ones
57# we are configured to use first and preserving their order.
58all-dirs := $(subdir-dirs) \
59 $(objdir) \
60 $(sysdep-dirs) \
61 $(source_dirs) \
62 $(filter-out $(sysdep-dirs),$(sysdep_dirs))
63
64# Find all the subdirs there are, but putting the ones
65# we are configured to use first and preserving their order.
66ifndef subdir
67subdirs := $(subdirs) \
68 $(filter-out $(subdirs),\
69 $(sort \
70 $(shell sed -e 's/\#.*$$//' \
71 $(wildcard $(addsuffix /Subdirs,\
72 $(all-dirs)))\
73 /dev/null)))
74all-dist = $(foreach Dist,$(wildcard $(all-dirs:%=%/Dist)),\
75 $(addprefix $(Dist:%/Dist=%)/,\
76 $(filter %.c %.h %.S %.s,\
77 $(shell cat $(Dist)))))
78tags_sources = $(all-sources) $(all-headers) $(all-dist)
79else
80all-dist = $(distribute)
81endif
82
83# sources and headers must be simply expanded variables
84sources := $(sources) $(filter %.c %.s %.S,$(all-dist))
85headers := $(headers) $(filter %.h,$(all-dist))
86all-dist := $(filter-out %.h %.c %.s %.S,$(all-dist))
87
88sources += $(foreach lib,$(extra-libs),$($(lib)-routines:=.c))
89
90# All different versions of $(sources), preserving the configured sysdep
91# directory order.
92# Files that are found in the current directory cannot occur in
93# sysdep directories, so don't bother searching them.
94sysdep-sources := $(filter-out $(wildcard $(sources)), $(sources))
95all-sources = $(wildcard $(sort $(sources) $(sources:.c=.S) $(sources:.c=.s) \
96 $(others:=.c) $(tests:=.c) $(xtests:=.c) \
97 $(test-srcs:=.c))) \
98 $(foreach dir,$(all-dirs),\
99 $(wildcard \
100 $(addprefix $(dir)/,\
101 $(sort $(sysdep-sources) \
102 $(sysdep-sources:.c=.S) \
103 $(sysdep-sources:.c=.s)))))
104
105sysdep-headers := $(filter-out $(wildcard $(headers)), $(headers))
106all-headers = $(wildcard $(headers)) \
107 $(foreach dir,$(all-dirs),\
108 $(wildcard $(addprefix $(dir)/,$(sysdep-headers))))
109
110tags_sources := $(strip $(tags_sources))
111
112TAGS: $(tags_sources)
113ifdef subdir
114ifdef tags_sources
115 $(ETAGS) -o $@ $^
116else
117# No sources. Create a dummy file.
118 touch $@
119endif # tags_sources
120else # parent
121TAGS: subdir_TAGS
122# Note that this uses the -i switch, and thus requires v19 etags.
123 $(ETAGS) -o $@ \
124 $(subdirs:%=-i %/TAGS) \
125 $(filter-out subdir_TAGS,$^)
126
127.PHONY: subdir_TAGS $(subdirs:%=%/TAGS)
128subdir_TAGS: $(subdirs:%=%/TAGS)
129$(subdirs:%=%/TAGS):
130 $(MAKE) -C $(@D) $(sub-make-vars) $(@F)
131
132endif # subdir
133\f
134ifndef XGETTEXT
135XGETTEXT = xgettext
136endif
137
138P = $(..)po
139
140ifdef subdir
141domain = $(subdir)
142else
143domain = libc-top
144endif
145
146define extract
147@rm -f $@.new
148$(XGETTEXT) --keyword=_ --keyword=N_ --add-comments=TRANS --sort-by-file \
149 --omit-header -E -n -d - $(XGETTEXTFLAGS-$(@F)) > $@.new $^
150mv -f $@.new $@
151endef
152
153text-srcs := $(filter %.c %.h %.cc %.C,$(tags_sources))
154$P/$(domain).pot: $(text-srcs)
155ifeq (,$(text-srcs))
156 cp /dev/null $@
157else
158 $(extract)
159endif
160
161all-pot = $P/libc-top.pot $P/subdirs.pot
162
163ifndef subdir
164# Collect all the subdir messages, massaging the file names in comments
165# to include the subdir name.
166$P/subdirs.pot: $(subdirs:%=$P/%.pot)
167 @rm -f $@.new
168 (for d in $(subdirs); \
169 do sed "/^#:/s% % $$d/%g" $P/$$d.pot; done) > $@.new
170 mv -f $@.new $@
171
172# Combine all the messages into the final sorted template translation file.
173# The following code requires GNU date.
174$P/libc.pot: $(all-pot)
175 @rm -f $@.new
176 set `date -R`; disp="$$6"; \
177 sed -e 's/VERSION/$(version)/' \
178 -e "s/DATE/`date +'%Y-%m-%d %H:%M'$$disp`/" \
179 po/header.pot > $@.new
180 $(XGETTEXT) -d - --omit-header -E -n $^ >> $@.new
181 mv -f $@.new $@
182ifeq ($(with-cvs),yes)
183 test ! -d CVS || cvs $(CVSOPTS) ci -m'Regenerated from source files' $@
184endif
185
186$(subdirs:%=$P/%.pot): $P/%.pot: FORCE
187 $(MAKE) -C $* $(sub-make-vars) ../$@
188FORCE:
189endif