Mon Jun 3 21:03:54 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
[glibc.git] / MakeTAGS
blob7e95c266e1321c30b4be567565a5659c5871806d
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 += $(filter %.c %.s %.S,$(all-dist))
77 headers += $(filter %.h,$(all-dist))
78 all-dist := $(filter-out %.h %.c %.s %.S,$(all-dist))
80 sources += $(foreach lib,$(extra-libs),$($(lib)-routines:=.c))
82 # All different versions of $(sources), preserving the configured sysdep
83 # directory order.
84 all-sources = $(wildcard $(sort $(sources) $(sources:.c=.S) $(sources:.c=.s) \
85                                 $(others:=.c) $(tests:=.c))) \
86               $(foreach dir,$(all-dirs),\
87                         $(wildcard \
88                            $(addprefix $(dir)/,\
89                                        $(sort $(sources) $(sources:.c=.S) \
90                                               $(sources:.c=.s)))))
92 all-headers = $(wildcard $(headers)) \
93               $(foreach dir,$(all-dirs),\
94                         $(wildcard $(addprefix $(dir)/,$(headers))))
96 tags_sources := $(strip $(tags_sources))
98 TAGS: $(tags_sources)
99 ifdef subdir
100 ifdef tags_sources
101         $(ETAGS) -o $@ $^
102 else
103 # No sources.  Create a dummy file.
104         touch $@
105 endif # tags_sources
106 else # parent
107 TAGS: subdir_TAGS
108 # Note that this uses the -i switch, and thus requires v19 etags.
109         $(ETAGS) -o $@ \
110                  $(subdirs:%=-i %/TAGS) \
111                  $(filter-out subdir_TAGS,$^)
113 .PHONY: subdir_TAGS $(subdirs:%=%/TAGS)
114 subdir_TAGS: $(subdirs:%=%/TAGS)
115 $(subdirs:%=%/TAGS):
116         $(MAKE) -C $(@D) no_deps=t $(@F)
118 endif # subdir
120 ifndef XGETTEXT
121 XGETTEXT = xgettext
122 endif
124 P = $(..)po
126 ifdef subdir
127 domain = $(subdir)
128 else
129 domain = libc-top
130 endif
132 define extract
133 @rm -f $@.new
134 $(XGETTEXT) --keyword=_ --keyword=N_ --sort-output -d - \
135             $(XGETTEXTFLAGS-$(@F)) > $@.new $^
136 mv -f $@.new $@
137 endef
139 text-srcs := $(filter %.c %.h %.cc %.C,$(tags_sources))
140 $P/$(domain).pot: $(text-srcs)
141 ifeq (,$(text-srcs))
142         cp /dev/null $@
143 else
144         $(extract)
145 endif
147 $P/siglist.pot: $(common-objpfx)siglist.c; $(extract)
148 $P/errlist.pot: $(..)sysdeps/mach/hurd/errlist.c; $(extract)
150 # Extract all strings from these files; their strings are not marked.
151 # Their surroundings are also not interesting.
152 XGETTEXTFLAGS-siglist.pot = -a --no-location
153 XGETTEXTFLAGS-errlist.pot = -a --no-location
155 all-pot = $P/libc-top.pot $P/subdirs.pot \
156           $P/siglist.pot $P/errlist.pot
158 ifndef subdir
159 # Collect all the subdir messages, massaging the file names in comments
160 # to include the subdir name.
161 $P/subdirs.pot: $(subdirs:%=$P/%.pot)
162         @rm -f $@.new
163         (for d in $(subdirs); \
164          do sed "s%^#: %&$$d/%" $P/$$d.pot; done) > $@.new
165         mv -f $@.new $@
167 # Get $(version) defined.
168 include $(common-objpfx)version.mk
170 # Combine all the messages into the final sorted template translation file.
171 $P/SYS_libc.pot: $(all-pot)
172         @rm -f $@.new
173         sed -e 's/VERSION/$(version)/' -e "s/DATE/`date +'%Y-%m-%d %k:%M'`/" \
174             po/header.pot > $@.new
175         $(XGETTEXT) -d - -n -s --omit-header $^ >> $@.new
176         mv -f $@.new $@
177         test ! -d CVS || cvs ci -m'Regenerated from source files' $@
179 $(subdirs:%=$P/%.pot): $P/%.pot: FORCE
180         $(MAKE) -C $* no_deps=t ../$@
181 FORCE:
182 endif