* sysdeps/unix/sysv/linux/ia64/ioperm.c: Don't include kernel
[glibc/pb-stable.git] / MakeTAGS
blobac028d70c9f3fa995d0f2c0f7c24b5f86fc41271
1 # Make the TAGS files.
3 # Copyright (C) 1992, 1994, 1995, 1996, 1998 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 not,
18 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, 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 := $(full_config_sysdirs)
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 \
50                             ! -name SCCS -print)
51 endif
53 # Find all sysdep dirs there are, but putting the ones
54 # we are configured to use first and preserving their order.
55 all-dirs := $(subdir-dirs) \
56             $(objdir) \
57             $(sysdep-dirs) \
58             $(source_dirs) \
59             $(filter-out $(sysdep-dirs),$(sysdep_dirs))
61 # Find all the subdirs there are, but putting the ones
62 # we are configured to use first and preserving their order.
63 ifndef subdir
64 subdirs := $(subdirs) \
65            $(filter-out $(subdirs),\
66                         $(shell sed -e 's/\#.*$$//' \
67                                     $(wildcard $(addsuffix /Subdirs,\
68                                                            $(all-dirs)))\
69                                     /dev/null))
70 all-dist = $(foreach Dist,$(wildcard $(all-dirs:%=%/Dist)),\
71                      $(addprefix $(Dist:%/Dist=%)/,\
72                                  $(filter %.c %.h %.S %.s,\
73                                           $(shell cat $(Dist)))))
74 tags_sources = $(all-sources) $(all-headers) $(all-dist)
75 else
76 all-dist = $(distribute)
77 endif
79 # sources and headers must be simply expanded variables
80 sources := $(sources) $(filter %.c %.s %.S,$(all-dist))
81 headers := $(headers) $(filter %.h,$(all-dist))
82 all-dist := $(filter-out %.h %.c %.s %.S,$(all-dist))
84 sources += $(foreach lib,$(extra-libs),$($(lib)-routines:=.c))
86 # All different versions of $(sources), preserving the configured sysdep
87 # directory order.
88 # Files that are found in the current directory cannot occur in
89 # sysdep directories, so don't bother searching them.
90 sysdep-sources := $(filter-out $(wildcard $(sources)), $(sources))
91 all-sources = $(wildcard $(sort $(sources) $(sources:.c=.S) $(sources:.c=.s)  \
92                                 $(others:=.c) $(tests:=.c) $(test-srcs:=.c))) \
93               $(foreach dir,$(all-dirs),\
94                         $(wildcard \
95                            $(addprefix $(dir)/,\
96                                        $(sort $(sysdep-sources) \
97                                               $(sysdep-sources:.c=.S) \
98                                               $(sysdep-sources:.c=.s)))))
100 sysdep-headers := $(filter-out $(wildcard $(headers)), $(headers))
101 all-headers = $(wildcard $(headers)) \
102               $(foreach dir,$(all-dirs),\
103                         $(wildcard $(addprefix $(dir)/,$(sysdep-headers))))
105 tags_sources := $(strip $(tags_sources))
107 TAGS: $(tags_sources)
108 ifdef subdir
109 ifdef tags_sources
110         $(ETAGS) -o $@ $^
111 else
112 # No sources.  Create a dummy file.
113         touch $@
114 endif # tags_sources
115 else # parent
116 TAGS: subdir_TAGS
117 # Note that this uses the -i switch, and thus requires v19 etags.
118         $(ETAGS) -o $@ \
119                  $(subdirs:%=-i %/TAGS) \
120                  $(filter-out subdir_TAGS,$^)
122 .PHONY: subdir_TAGS $(subdirs:%=%/TAGS)
123 subdir_TAGS: $(subdirs:%=%/TAGS)
124 $(subdirs:%=%/TAGS):
125         $(MAKE) -C $(@D) no_deps=t $(@F)
127 endif # subdir
129 ifndef XGETTEXT
130 XGETTEXT = xgettext
131 endif
133 P = $(..)po
135 ifdef subdir
136 domain = $(subdir)
137 else
138 domain = libc-top
139 endif
141 define extract
142 @rm -f $@.new
143 $(XGETTEXT) --keyword=_ --keyword=N_ --add-comments=TRANS  --sort-output \
144             --omit-header -n -d - $(XGETTEXTFLAGS-$(@F)) > $@.new $^
145 mv -f $@.new $@
146 endef
148 text-srcs := $(filter %.c %.h %.cc %.C,$(tags_sources))
149 $P/$(domain).pot: $(text-srcs)
150 ifeq (,$(text-srcs))
151         cp /dev/null $@
152 else
153         $(extract)
154 endif
156 all-pot = $P/libc-top.pot $P/subdirs.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/%g" $P/$$d.pot; done) > $@.new
165         mv -f $@.new $@
167 # Combine all the messages into the final sorted template translation file.
168 # The following code requires GNU date.
169 $P/libc.pot: $(all-pot)
170         @rm -f $@.new
171         set `date -R`; disp="$$6"; \
172         sed -e 's/VERSION/$(version)/' \
173             -e "s/DATE/`date +'%Y-%m-%d %H:%M'$$disp`/" \
174             po/header.pot > $@.new
175         $(XGETTEXT) -d - --omit-header -n -s $^ >> $@.new
176         mv -f $@.new $@
177 ifeq ($(with-cvs),yes)
178         test ! -d CVS || cvs $(CVSOPTS) ci -m'Regenerated from source files' $@
179 endif
181 $(subdirs:%=$P/%.pot): $P/%.pot: FORCE
182         $(MAKE) -C $* no_deps=t ../$@
183 FORCE:
184 endif