1 # Top level -*- makefile -*- fragment for GNU C++.
2 # Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001
3 # Free Software Foundation, Inc.
5 #This file is part of GNU CC.
7 #GNU CC is free software; you can redistribute it and/or modify
8 #it under the terms of the GNU General Public License as published by
9 #the Free Software Foundation; either version 2, or (at your option)
12 #GNU CC is distributed in the hope that it will be useful,
13 #but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 #GNU General Public License for more details.
17 #You should have received a copy of the GNU General Public License
18 #along with GNU CC; see the file COPYING. If not, write to
19 #the Free Software Foundation, 59 Temple Place - Suite 330,
20 #Boston, MA 02111-1307, USA.
22 # This file provides the language dependent support in the main Makefile.
23 # Each language makefile fragment must provide the following targets:
25 # foo.all.build, foo.all.cross, foo.start.encap, foo.rest.encap,
27 # foo.install-normal, foo.install-common, foo.install-info, foo.install-man,
29 # foo.mostlyclean, foo.clean, foo.distclean, foo.extraclean,
30 # foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
32 # where `foo' is the name of the language.
34 # It should also provide rules for:
36 # - making any compiler driver (eg: g++)
37 # - the compiler proper (eg: cc1plus)
38 # - define the names for selecting the language in LANGUAGES.
40 # Actual names to use when installing a native compiler.
41 CXX_INSTALL_NAME = `t='$(program_transform_name)'; echo c++ | sed $$t`
42 GXX_INSTALL_NAME = `t='$(program_transform_name)'; echo g++ | sed $$t`
43 DEMANGLER_INSTALL_NAME = `t='$(program_transform_name)'; echo c++filt | sed $$t`
45 # Actual names to use when installing a cross-compiler.
46 CXX_CROSS_NAME = `t='$(program_transform_cross_name)'; echo c++ | sed $$t`
47 GXX_CROSS_NAME = `t='$(program_transform_cross_name)'; echo g++ | sed $$t`
48 DEMANGLER_CROSS_NAME = `t='$(program_transform_cross_name)'; echo c++filt | sed $$t`
50 # The name to use for the demangler program.
51 DEMANGLER_PROG = c++filt$(exeext)
54 # Define the names for selecting c++ in LANGUAGES.
55 # Note that it would be nice to move the dependency on g++
56 # into the C++ rule, but that needs a little bit of work
57 # to do the right thing within all.cross.
58 C++ c++: cc1plus$(exeext)
60 # Tell GNU make to ignore these if they exist.
63 g++spec.o: $(srcdir)/cp/g++spec.c $(SYSTEM_H) $(GCC_H) $(CONFIG_H)
64 (SHLIB_LINK='$(SHLIB_LINK)' \
65 SHLIB_MULTILIB='$(SHLIB_MULTILIB)'; \
66 $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(DRIVER_DEFINES) \
67 $(INCLUDES) $(srcdir)/cp/g++spec.c)
69 po-generated: $(srcdir)/cp/parse.c
71 # Create the compiler driver for g++.
72 GXX_OBJS = gcc.o g++spec.o intl.o prefix.o version.o
73 g++$(exeext): $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBDEPS)
74 $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
75 $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBS)
77 # Create a version of the g++ driver which calls the cross-compiler.
78 g++-cross$(exeext): g++$(exeext)
79 -rm -f g++-cross$(exeext)
80 cp g++$(exeext) g++-cross$(exeext)
83 cxxmain.o: $(srcdir)/../libiberty/cplus-dem.c $(DEMANGLE_H) $(CONFIG_H)
85 $(LN_S) $(srcdir)/../libiberty/cplus-dem.c cxxmain.c
86 $(CC) -c -DMAIN $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
87 -DVERSION=\"$(version)\" cxxmain.c
89 # Apparently OpenVM needs the -o to be at the beginning of the link line.
90 $(DEMANGLER_PROG): cxxmain.o underscore.o $(LIBDEPS)
91 $(CC) -o $@ $(ALL_CFLAGS) $(LDFLAGS) \
92 cxxmain.o underscore.o $(LIBS)
94 # The compiler itself.
95 # Shared with C front end:
96 CXX_C_OBJS = attribs.o c-common.o c-format.o c-pragma.o c-semantics.o c-lex.o \
97 c-dump.o $(CXX_TARGET_OBJS)
99 # Language-specific object files.
100 CXX_OBJS = cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o \
101 cp/class.o cp/decl2.o cp/error.o cp/lex.o cp/parse.o cp/ptree.o cp/rtti.o \
102 cp/spew.o cp/typeck.o cp/cvt.o cp/except.o cp/friend.o cp/init.o cp/method.o \
103 cp/search.o cp/semantics.o cp/tree.o cp/xref.o cp/repo.o cp/dump.o \
104 cp/optimize.o cp/mangle.o cp/cp-lang.o
106 # Use loose warnings for this front end.
109 cc1plus$(exeext): $(CXX_OBJS) $(CXX_C_OBJS) $(BACKEND) \
111 $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
112 $(CXX_OBJS) $(CXX_C_OBJS) $(BACKEND) libcpp.a $(LIBS)
114 # Special build rules.
115 $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf
116 gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' \
117 $(srcdir)/cp/cfns.gperf > $(srcdir)/cp/cfns.h
119 $(srcdir)/cp/parse.h $(srcdir)/cp/parse.c: $(srcdir)/cp/parse.y
120 @echo "Expect 33 shift/reduce conflicts and 58 reduce/reduce conflicts."
121 cd $(srcdir)/cp; $(BISON) $(BISONFLAGS) -d -o p$$$$.c parse.y ; \
122 grep '^#define[ ]*YYEMPTY' p$$$$.c >> p$$$$.h ; \
123 mv -f p$$$$.c parse.c ; mv -f p$$$$.h parse.h
128 c++.all.build: g++$(exeext)
129 c++.all.cross: g++-cross$(exeext) $(DEMANGLER_PROG)
130 c++.start.encap: g++$(exeext)
131 c++.rest.encap: $(DEMANGLER_PROG)
138 # cc1plus is installed elsewhere as part of $(COMPILERS).
140 # Nothing to do here.
143 # Install the driver program as $(target)-g++
144 # and also as either g++ (if native) or $(tooldir)/bin/g++.
145 c++.install-common: installdirs
146 -if [ -f cc1plus$(exeext) ] ; then \
147 if [ -f g++-cross$(exeext) ] ; then \
148 rm -f $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
149 $(INSTALL_PROGRAM) g++-cross$(exeext) $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
150 chmod a+x $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
151 rm -f $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
152 $(LN) $(bindir)/$(GXX_CROSS_NAME)$(exeext) $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
153 if [ -d $(gcc_tooldir)/bin/. ] ; then \
154 rm -f $(gcc_tooldir)/bin/g++$(exeext); \
155 $(INSTALL_PROGRAM) g++-cross$(exeext) $(gcc_tooldir)/bin/g++$(exeext); \
156 rm -f $(gcc_tooldir)/bin/c++$(exeext); \
157 $(LN) $(gcc_tooldir)/bin/g++$(exeext) $(gcc_tooldir)/bin/c++$(exeext); \
160 rm -f $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
161 $(INSTALL_PROGRAM) g++$(exeext) $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
162 chmod a+x $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
163 rm -f $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
164 $(LN) $(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
165 rm -f $(bindir)/$(target_alias)-g++$(exeext); \
166 $(LN) $(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(bindir)/$(target_alias)-g++$(exeext); \
167 rm -f $(bindir)/$(target_alias)-c++$(exeext); \
168 $(LN) $(bindir)/$(CXX_INSTALL_NAME)$(exeext) $(bindir)/$(target_alias)-c++$(exeext); \
170 if [ x$(DEMANGLER_PROG) != x ] && [ -x "$(DEMANGLER_PROG)" ]; then \
171 if [ -f g++-cross$(exeext) ] ; then \
172 rm -f $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
173 $(INSTALL_PROGRAM) $(DEMANGLER_PROG) $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
174 chmod a+x $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
176 rm -f $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
177 $(INSTALL_PROGRAM) $(DEMANGLER_PROG) $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
178 chmod a+x $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
185 c++.install-man: installdirs $(srcdir)/cp/g++.1
186 -if [ -f cc1plus$(exeext) ] ; then \
187 if [ -f g++-cross$(exeext) ] ; then \
188 rm -f $(man1dir)/$(GXX_CROSS_NAME)$(manext); \
189 $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(man1dir)/$(GXX_CROSS_NAME)$(manext); \
190 chmod a-x $(man1dir)/$(GXX_CROSS_NAME)$(manext); \
192 rm -f $(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
193 $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
194 chmod a-x $(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
199 -rm -rf $(bindir)/$(CXX_INSTALL_NAME)$(exeext)
200 -rm -rf $(bindir)/$(CXX_CROSS_NAME)$(exeext)
201 -rm -rf $(bindir)/$(GXX_INSTALL_NAME)$(exeext)
202 -rm -rf $(bindir)/$(GXX_CROSS_NAME)$(exeext)
203 -rm -rf $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext)
204 -rm -rf $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext)
205 -rm -rf $(man1dir)/$(GXX_INSTALL_NAME)$(manext)
206 -rm -rf $(man1dir)/$(GXX_CROSS_NAME)$(manext)
209 # A lot of the ancillary files are deleted by the main makefile.
210 # We just have to delete files specific to us.
213 -rm -f cp/*$(objext) $(DEMANGLER_PROG)
216 -rm -f cp/config.status cp/Makefile
217 -rm -f $(srcdir)/cp/parse.output
219 c++.maintainer-clean:
220 -rm -f $(srcdir)/cp/parse.c $(srcdir)/cp/parse.h
223 # The main makefile has already created stage?/cp.
225 c++.stage1: stage1-start
226 -mv cp/*$(objext) stage1/cp
227 c++.stage2: stage2-start
228 -mv cp/*$(objext) stage2/cp
229 c++.stage3: stage3-start
230 -mv cp/*$(objext) stage3/cp
231 c++.stage4: stage4-start
232 -mv cp/*$(objext) stage4/cp
235 # .o: .h dependencies.
236 CXX_TREE_H = $(TREE_H) cp/cp-tree.h c-common.h cp/cp-tree.def c-common.def \
237 function.h varray.h $(SYSTEM_H) $(CONFIG_H) $(TARGET_H) \
238 $(srcdir)/../include/hashtab.h $(srcdir)/../include/splay-tree.h
240 cp/spew.o: cp/spew.c $(CXX_TREE_H) cp/parse.h flags.h cp/lex.h toplev.h
241 cp/lex.o: cp/lex.c $(CXX_TREE_H) cp/parse.h flags.h cp/lex.h c-pragma.h \
242 toplev.h output.h mbchar.h $(GGC_H) input.h diagnostic.h cp/operators.def \
244 cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H) toplev.h langhooks.h
245 cp/decl.o: cp/decl.c $(CXX_TREE_H) flags.h cp/lex.h cp/decl.h stack.h \
246 output.h $(EXPR_H) except.h toplev.h hash.h $(GGC_H) $(RTL_H) \
247 cp/operators.def $(TM_P_H) tree-inline.h
248 cp/decl2.o: cp/decl2.c $(CXX_TREE_H) flags.h cp/lex.h cp/decl.h $(EXPR_H) \
249 output.h except.h toplev.h $(GGC_H) $(RTL_H)
250 cp/typeck2.o: cp/typeck2.c $(CXX_TREE_H) flags.h toplev.h output.h $(TM_P_H) \
252 cp/typeck.o: cp/typeck.c $(CXX_TREE_H) flags.h $(RTL_H) $(EXPR_H) toplev.h \
254 cp/class.o: cp/class.c $(CXX_TREE_H) flags.h toplev.h $(RTL_H)
255 cp/call.o: cp/call.c $(CXX_TREE_H) flags.h toplev.h $(RTL_H) $(EXPR_H) \
256 $(GGC_H) diagnostic.h
257 cp/friend.o: cp/friend.c $(CXX_TREE_H) flags.h $(RTL_H) toplev.h $(EXPR_H)
258 cp/init.o: cp/init.c $(CXX_TREE_H) flags.h $(RTL_H) $(EXPR_H) toplev.h \
260 cp/method.o: cp/method.c $(CXX_TREE_H) toplev.h $(GGC_H) $(RTL_H) $(EXPR_H) \
262 cp/cvt.o: cp/cvt.c $(CXX_TREE_H) cp/decl.h flags.h toplev.h convert.h
263 cp/search.o: cp/search.c $(CXX_TREE_H) stack.h flags.h toplev.h $(RTL_H)
264 cp/tree.o: cp/tree.c $(CXX_TREE_H) flags.h toplev.h $(GGC_H) $(RTL_H) \
265 insn-config.h integrate.h tree-inline.h
266 cp/ptree.o: cp/ptree.c $(CXX_TREE_H) $(SYSTEM_H)
267 cp/rtti.o: cp/rtti.c $(CXX_TREE_H) flags.h toplev.h
268 cp/except.o: cp/except.c $(CXX_TREE_H) flags.h $(RTL_H) except.h toplev.h \
269 cp/cfns.h $(EXPR_H) libfuncs.h cp/decl.h $(OBSTACK_H)
270 cp/expr.o: cp/expr.c $(CXX_TREE_H) $(RTL_H) flags.h $(EXPR_H) toplev.h \
272 cp/xref.o: cp/xref.c $(CXX_TREE_H) input.h toplev.h
273 cp/pt.o: cp/pt.c $(CXX_TREE_H) cp/decl.h cp/parse.h cp/lex.h toplev.h \
274 $(GGC_H) $(RTL_H) except.h tree-inline.h
275 cp/error.o: cp/error.c $(CXX_TREE_H) toplev.h diagnostic.h flags.h real.h
276 cp/repo.o: cp/repo.c $(CXX_TREE_H) toplev.h $(GGC_H) diagnostic.h
277 cp/semantics.o: cp/semantics.c $(CXX_TREE_H) cp/lex.h except.h toplev.h \
278 flags.h $(GGC_H) debug.h output.h $(RTL_H) $(TIMEVAR_H) $(EXPR_H) \
280 cp/dump.o: cp/dump.c $(CXX_TREE_H) c-dump.h
281 cp/optimize.o: cp/optimize.c $(CXX_TREE_H) rtl.h integrate.h insn-config.h \
282 input.h $(PARAMS_H) debug.h tree-inline.h
283 cp/mangle.o: cp/mangle.c $(CXX_TREE_H) toplev.h
285 cp/parse.o: cp/parse.c $(CXX_TREE_H) flags.h cp/lex.h except.h output.h \
286 $(SYSTEM_H) toplev.h $(GGC_H)
287 $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(BIG_SWITCHFLAG) \
288 $(srcdir)/cp/parse.c $(OUTPUT_OPTION)
290 # These exist for maintenance purposes.
292 # Update the tags table.
295 etags --no-globals -l c `echo *.c | sed 's/parse.c//'` \
296 parse.y *.h ../*.c ../*.h;