(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / MakeTAGS
blobbee41252ee5538df38234ec24f2ffd88e8c7a090
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.
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.
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.
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.
21 # Make this the default goal.
22 TAGS:
24 ifdef subdir
25 .. := ../
26 endif
28 include $(..)Makeconfig
30 # Pass these to $(MAKE) calls to avoid source generation and such.
31 sub-make-vars = generating=t no_deps=t
33 ifndef tags_sources
34 ifeq ($(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.
39 tags_sources = $(all-headers) $(all-sources) $(all-dist)
40 else    # Not ctype.
41 tags_sources = $(all-sources) $(all-headers) $(all-dist)
42 endif   # ctype
43 endif   # No tags_sources
45 sysdep-dirs := $(full_config_sysdirs)
47 ifndef sysdep_dirs
48 # Find all sysdep directories.
49 sysdep_dirs := $(shell find $(..)sysdeps \
50                             $(wildcard \
51                                 $(patsubst %,$(..)%/sysdeps,$(add-ons))) \
52                             -type d ! -name RCS ! -name CVS \
53                             ! -name SCCS -print)
54 endif
56 # Find all sysdep dirs there are, but putting the ones
57 # we are configured to use first and preserving their order.
58 all-dirs := $(subdir-dirs) \
59             $(objdir) \
60             $(sysdep-dirs) \
61             $(source_dirs) \
62             $(filter-out $(sysdep-dirs),$(sysdep_dirs))
64 # Find all the subdirs there are, but putting the ones
65 # we are configured to use first and preserving their order.
66 ifndef subdir
67 subdirs := $(subdirs) \
68            $(filter-out $(subdirs),\
69                         $(sort \
70                           $(shell sed -e 's/\#.*$$//' \
71                                       $(wildcard $(addsuffix /Subdirs,\
72                                                              $(all-dirs)))\
73                                       /dev/null)))
74 all-dist = $(foreach Dist,$(wildcard $(all-dirs:%=%/Dist)),\
75                      $(addprefix $(Dist:%/Dist=%)/,\
76                                  $(filter %.c %.h %.S %.s,\
77                                           $(shell cat $(Dist)))))
78 tags_sources = $(all-sources) $(all-headers) $(all-dist)
79 else
80 all-dist = $(distribute)
81 endif
83 # sources and headers must be simply expanded variables
84 sources := $(sources) $(filter %.c %.s %.S,$(all-dist))
85 headers := $(headers) $(filter %.h,$(all-dist))
86 all-dist := $(filter-out %.h %.c %.s %.S,$(all-dist))
88 sources += $(foreach lib,$(extra-libs),$($(lib)-routines:=.c))
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.
94 sysdep-sources := $(filter-out $(wildcard $(sources)), $(sources))
95 all-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)))))
105 sysdep-headers := $(filter-out $(wildcard $(headers)), $(headers))
106 all-headers = $(wildcard $(headers)) \
107               $(foreach dir,$(all-dirs),\
108                         $(wildcard $(addprefix $(dir)/,$(sysdep-headers))))
110 tags_sources := $(strip $(tags_sources))
112 TAGS: $(tags_sources)
113 ifdef subdir
114 ifdef tags_sources
115         $(ETAGS) -o $@ $^
116 else
117 # No sources.  Create a dummy file.
118         touch $@
119 endif # tags_sources
120 else # parent
121 TAGS: 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,$^)
127 .PHONY: subdir_TAGS $(subdirs:%=%/TAGS)
128 subdir_TAGS: $(subdirs:%=%/TAGS)
129 $(subdirs:%=%/TAGS):
130         $(MAKE) -C $(@D) $(sub-make-vars) $(@F)
132 endif # subdir
134 ifndef XGETTEXT
135 XGETTEXT = xgettext
136 endif
138 P = $(..)po
140 ifdef subdir
141 domain = $(subdir)
142 else
143 domain = libc-top
144 endif
146 define 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 $^
150 mv -f $@.new $@
151 endef
153 text-srcs := $(filter %.c %.h %.cc %.C,$(tags_sources))
154 $P/$(domain).pot: $(text-srcs)
155 ifeq (,$(text-srcs))
156         cp /dev/null $@
157 else
158         $(extract)
159 endif
161 all-pot = $P/libc-top.pot $P/subdirs.pot
163 ifndef 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 $@
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 $@
182 ifeq ($(with-cvs),yes)
183         test ! -d CVS || cvs $(CVSOPTS) ci -m'Regenerated from source files' $@
184 endif
186 $(subdirs:%=$P/%.pot): $P/%.pot: FORCE
187         $(MAKE) -C $* $(sub-make-vars) ../$@
188 FORCE:
189 endif