update from main archive 961203
[platform/upstream/glibc.git] / MakeTAGS
1 # Make the TAGS files.
2
3 # Copyright (C) 1992, 1994, 1995, 1996 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 Library General Public License
8 # as published by the Free Software Foundation; either version 2 of
9 # 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 # Library General Public License for more details.
15
16 # You should have received a copy of the GNU Library General Public
17 # License along with the GNU C Library; see the file COPYING.LIB.  If not,
18 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA.
20
21 # Make this the default goal.
22 TAGS:
23
24 ifdef subdir
25 .. := ../
26 endif
27
28 include $(..)Makeconfig
29
30 ifndef tags_sources
31 ifeq ($(subdir),ctype)
32 # In most cases, we want the C source files to come before
33 # the header files so tags for optimizing #define's in the
34 # headers won't be put in the tags files, but for ctype,
35 # the functions are just backup for the #define's in the header.
36 tags_sources = $(all-headers) $(all-sources) $(all-dist)
37 else    # Not ctype.
38 tags_sources = $(all-sources) $(all-headers) $(all-dist)
39 endif   # ctype
40 endif   # No tags_sources
41
42 sysdep-dirs := $(full-config-sysdirs)
43
44 ifndef sysdep_dirs
45 # Find all sysdep directories.
46 sysdep_dirs := $(shell find $(..)sysdeps \
47                             $(wildcard \
48                                 $(patsubst %,$(..)%/sysdeps,$(add-ons))) \
49                             -type d ! -name RCS ! -name CVS -print)
50 endif
51
52 # Find all sysdep dirs there are, but putting the ones
53 # we are configured to use first and preserving their order.
54 all-dirs := $(subdir-dirs) \
55             $(objdir) \
56             $(sysdep-dirs) \
57             $(source_dirs) \
58             $(filter-out $(sysdep-dirs),$(sysdep_dirs))
59
60 # Find all the subdirs there are, but putting the ones
61 # we are configured to use first and preserving their order.
62 ifndef subdir
63 subdirs := $(subdirs) \
64            $(filter-out $(subdirs),\
65                         $(shell sed -e 's/\#.*$$//' \
66                                     $(wildcard $(addsuffix /Subdirs,\
67                                                            $(all-dirs)))\
68                                     /dev/null))
69 all-dist = $(foreach Dist,$(wildcard $(all-dirs:%=%/Dist)),\
70                      $(addprefix $(Dist:%/Dist=%)/,\
71                                  $(filter %.c %.h %.S %.s,\
72                                           $(shell cat $(Dist)))))
73 tags_sources = $(all-sources) $(all-headers) $(all-dist)
74 else
75 all-dist = $(distribute)
76 endif
77
78 # sources and headers must be simply expanded variables
79 sources := $(sources) $(filter %.c %.s %.S,$(all-dist))
80 headers := $(headers) $(filter %.h,$(all-dist))
81 all-dist := $(filter-out %.h %.c %.s %.S,$(all-dist))
82
83 sources += $(foreach lib,$(extra-libs),$($(lib)-routines:=.c))
84
85 # All different versions of $(sources), preserving the configured sysdep
86 # directory order.
87 all-sources = $(wildcard $(sort $(sources) $(sources:.c=.S) $(sources:.c=.s) \
88                                 $(others:=.c) $(tests:=.c))) \
89               $(foreach dir,$(all-dirs),\
90                         $(wildcard \
91                            $(addprefix $(dir)/,\
92                                        $(sort $(sources) $(sources:.c=.S) \
93                                               $(sources:.c=.s)))))
94
95 all-headers = $(wildcard $(headers)) \
96               $(foreach dir,$(all-dirs),\
97                         $(wildcard $(addprefix $(dir)/,$(headers))))
98
99 tags_sources := $(strip $(tags_sources))
100
101 TAGS: $(tags_sources)
102 ifdef subdir
103 ifdef tags_sources
104         $(ETAGS) -o $@ $^
105 else
106 # No sources.  Create a dummy file.
107         touch $@
108 endif # tags_sources
109 else # parent
110 TAGS: subdir_TAGS
111 # Note that this uses the -i switch, and thus requires v19 etags.
112         $(ETAGS) -o $@ \
113                  $(subdirs:%=-i %/TAGS) \
114                  $(filter-out subdir_TAGS,$^)
115
116 .PHONY: subdir_TAGS $(subdirs:%=%/TAGS)
117 subdir_TAGS: $(subdirs:%=%/TAGS)
118 $(subdirs:%=%/TAGS):
119         $(MAKE) -C $(@D) no_deps=t $(@F)
120
121 endif # subdir
122 \f
123 ifndef XGETTEXT
124 XGETTEXT = xgettext
125 endif
126
127 P = $(..)po
128
129 ifdef subdir
130 domain = $(subdir)
131 else
132 domain = libc-top
133 endif
134
135 define extract
136 @rm -f $@.new
137 $(XGETTEXT) --keyword=_ --keyword=N_ --add-comments=TRANS  --sort-output \
138             --omit-header -n -d - $(XGETTEXTFLAGS-$(@F)) > $@.new $^
139 mv -f $@.new $@
140 endef
141
142 text-srcs := $(filter %.c %.h %.cc %.C,$(tags_sources))
143 $P/$(domain).pot: $(text-srcs)
144 ifeq (,$(text-srcs))
145         cp /dev/null $@
146 else
147         $(extract)
148 endif
149
150 #$P/siglist.pot: $(common-objpfx)stdio-common/siglist.c; $(extract)
151 $P/siglist.pot: siglist.c; $(extract)
152
153 # Extract all strings from this file; its strings are not marked.
154 # Their surroundings are also not interesting.
155 XGETTEXTFLAGS-siglist.pot = -a --no-location
156
157 all-pot = $P/libc-top.pot $P/subdirs.pot $P/siglist.pot
158
159 ifndef subdir
160 # Collect all the subdir messages, massaging the file names in comments
161 # to include the subdir name.
162 $P/subdirs.pot: $(subdirs:%=$P/%.pot)
163         @rm -f $@.new
164         (for d in $(subdirs); \
165          do sed "/^#:/s% % $$d/%g" $P/$$d.pot; done) > $@.new
166         mv -f $@.new $@
167
168 # Get $(version) defined.
169 include $(common-objpfx)version.mk
170
171 # Combine all the messages into the final sorted template translation file.
172 # The following code requires GNU date.
173 $P/libc.pot: $(all-pot)
174         @rm -f $@.new
175         set `date -R`; disp="$$6"; \
176         sed -e 's/VERSION/$(version)/' \
177             -e "s/DATE/`date +'%Y-%m-%d %H:%M'$$disp`/" \
178             po/header.pot > $@.new
179         $(XGETTEXT) -d - --omit-header -n -s $^ >> $@.new
180         mv -f $@.new $@
181         test ! -d CVS || cvs ci -m'Regenerated from source files' $@
182
183 $(subdirs:%=$P/%.pot): $P/%.pot: FORCE
184         $(MAKE) -C $* no_deps=t ../$@
185 FORCE:
186 endif