*** empty log message ***
[glibc.git] / MakeTAGS
blob04164934890b8299f48cb004ce159d7981fc6491
1 # Make the TAGS files.
3 # Copyright (C) 1992, 1994, 1995, 1996 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
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.
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.
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
18 # not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19 # Cambridge, MA 02139, USA.
21 # Make this the default goal.
22 TAGS:
24 ifdef subdir
25 .. := ../
26 endif
28 include $(..)Makeconfig
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
42 sysdep-dirs := $(addprefix $(sysdep_dir)/,$(sysdirs))
44 ifndef sysdep_dirs
45 # Find all sysdep directories.
46 sysdep_dirs := $(shell find $(..)sysdeps -type d \
47                                          ! -name RCS ! -name CVS -print)
48 endif
50 # Find all sysdep dirs there are, but putting the ones
51 # we are configured to use first and preserving their order.
52 all-dirs := $(subdir-dirs) \
53             $(objdir) \
54             $(sysdep-dirs) \
55             $(source_dirs) \
56             $(filter-out $(sysdep-dirs),$(sysdep_dirs))
58 # Find all the subdirs there are, but putting the ones
59 # we are configured to use first and preserving their order.
60 ifndef subdir
61 subdirs := $(subdirs) \
62            $(filter-out $(subdirs),\
63                         $(shell sed -e 's/\#.*$$//' \
64                                     $(wildcard $(addsuffix /Subdirs,\
65                                                            $(all-dirs)))\
66                                     /dev/null))
67 all-dist = $(foreach Dist,$(wildcard $(all-dirs:%=%/Dist)),\
68                      $(addprefix $(Dist:%/Dist=%)/,\
69                                  $(filter %.c %.h %.S %.s,\
70                                           $(shell cat $(Dist)))))
71 tags_sources = $(all-sources) $(all-headers) $(all-dist)
72 else
73 all-dist = $(distribute)
74 endif
76 # sources and headers must be simply expanded variables
77 sources := $(sources) $(filter %.c %.s %.S,$(all-dist))
78 headers := $(headers) $(filter %.h,$(all-dist))
79 all-dist := $(filter-out %.h %.c %.s %.S,$(all-dist))
81 sources += $(foreach lib,$(extra-libs),$($(lib)-routines:=.c))
83 # All different versions of $(sources), preserving the configured sysdep
84 # directory order.
85 all-sources = $(wildcard $(sort $(sources) $(sources:.c=.S) $(sources:.c=.s) \
86                                 $(others:=.c) $(tests:=.c))) \
87               $(foreach dir,$(all-dirs),\
88                         $(wildcard \
89                            $(addprefix $(dir)/,\
90                                        $(sort $(sources) $(sources:.c=.S) \
91                                               $(sources:.c=.s)))))
93 all-headers = $(wildcard $(headers)) \
94               $(foreach dir,$(all-dirs),\
95                         $(wildcard $(addprefix $(dir)/,$(headers))))
97 tags_sources := $(strip $(tags_sources))
99 TAGS: $(tags_sources)
100 ifdef subdir
101 ifdef tags_sources
102         $(ETAGS) -o $@ $^
103 else
104 # No sources.  Create a dummy file.
105         touch $@
106 endif # tags_sources
107 else # parent
108 TAGS: subdir_TAGS
109 # Note that this uses the -i switch, and thus requires v19 etags.
110         $(ETAGS) -o $@ \
111                  $(subdirs:%=-i %/TAGS) \
112                  $(filter-out subdir_TAGS,$^)
114 .PHONY: subdir_TAGS $(subdirs:%=%/TAGS)
115 subdir_TAGS: $(subdirs:%=%/TAGS)
116 $(subdirs:%=%/TAGS):
117         $(MAKE) -C $(@D) no_deps=t $(@F)
119 endif # subdir
121 ifndef XGETTEXT
122 XGETTEXT = xgettext
123 endif
125 P = $(..)po
127 ifdef subdir
128 domain = $(subdir)
129 else
130 domain = libc-top
131 endif
133 define extract
134 @rm -f $@.new
135 $(XGETTEXT) --keyword=_ --keyword=N_ --add-comments=TRANS  --sort-output \
136             --omit-header -n -d - $(XGETTEXTFLAGS-$(@F)) > $@.new $^
137 mv -f $@.new $@
138 endef
140 text-srcs := $(filter %.c %.h %.cc %.C,$(tags_sources))
141 $P/$(domain).pot: $(text-srcs)
142 ifeq (,$(text-srcs))
143         cp /dev/null $@
144 else
145         $(extract)
146 endif
148 $P/siglist.pot: $(common-objpfx)siglist.c; $(extract)
150 # Extract all strings from this file; its strings are not marked.
151 # Their surroundings are also not interesting.
152 XGETTEXTFLAGS-siglist.pot = -a --no-location
154 all-pot = $P/libc-top.pot $P/subdirs.pot $P/siglist.pot
156 ifndef subdir
157 # Collect all the subdir messages, massaging the file names in comments
158 # to include the subdir name.
159 $P/subdirs.pot: $(subdirs:%=$P/%.pot)
160         @rm -f $@.new
161         (for d in $(subdirs); \
162          do sed "s%^#: %&$$d/%" $P/$$d.pot; done) > $@.new
163         mv -f $@.new $@
165 # Get $(version) defined.
166 include $(common-objpfx)version.mk
168 # Combine all the messages into the final sorted template translation file.
169 $P/SYS_libc.pot: $(all-pot)
170         @rm -f $@.new
171         sed -e 's/VERSION/$(version)/' -e "s/DATE/`date +'%Y-%m-%d %k:%M'`/" \
172             po/header.pot > $@.new
173         $(XGETTEXT) -d - --omit-header -n -s $^ >> $@.new
174         mv -f $@.new $@
175         test ! -d CVS || cvs ci -m'Regenerated from source files' $@
177 $(subdirs:%=$P/%.pot): $P/%.pot: FORCE
178         $(MAKE) -C $* no_deps=t ../$@
179 FORCE:
180 endif