Make-lang.in revision 90075
1# Top level -*- makefile -*- fragment for GNU C++.
2#   Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001
3#   Free Software Foundation, Inc.
4
5#This file is part of GNU CC.
6
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)
10#any later version.
11
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.
16
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.
21
22# This file provides the language dependent support in the main Makefile.
23# Each language makefile fragment must provide the following targets:
24#
25# foo.all.build, foo.all.cross, foo.start.encap, foo.rest.encap,
26# foo.info, foo.dvi,
27# foo.install-normal, foo.install-common, foo.install-info, foo.install-man,
28# foo.uninstall,
29# foo.mostlyclean, foo.clean, foo.distclean, foo.extraclean,
30# foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
31#
32# where `foo' is the name of the language.
33#
34# It should also provide rules for:
35#
36# - making any compiler driver (eg: g++)
37# - the compiler proper (eg: cc1plus)
38# - define the names for selecting the language in LANGUAGES.
39
40# Actual names to use when installing a native compiler.
41CXX_INSTALL_NAME = `echo c++|sed '$(program_transform_name)'`
42GXX_INSTALL_NAME = `echo g++|sed '$(program_transform_name)'`
43DEMANGLER_INSTALL_NAME = `echo c++filt|sed '$(program_transform_name)'`
44CXX_TARGET_INSTALL_NAME = $(target_alias)-`echo c++|sed '$(program_transform_name)'`
45GXX_TARGET_INSTALL_NAME = $(target_alias)-`echo g++|sed '$(program_transform_name)'`
46
47# Actual names to use when installing a cross-compiler.
48CXX_CROSS_NAME = `echo c++|sed '$(program_transform_cross_name)'`
49GXX_CROSS_NAME = `echo g++|sed '$(program_transform_cross_name)'`
50DEMANGLER_CROSS_NAME = `echo c++filt|sed '$(program_transform_cross_name)'`
51
52# The name to use for the demangler program.
53DEMANGLER_PROG = c++filt$(exeext)
54
55#
56# Define the names for selecting c++ in LANGUAGES.
57# Note that it would be nice to move the dependency on g++
58# into the C++ rule, but that needs a little bit of work
59# to do the right thing within all.cross.
60C++ c++: cc1plus$(exeext)
61
62# Tell GNU make to ignore these if they exist.
63.PHONY: C++ c++
64
65g++spec.o: $(srcdir)/cp/g++spec.c $(SYSTEM_H) $(GCC_H) $(CONFIG_H)
66	(SHLIB_LINK='$(SHLIB_LINK)' \
67	SHLIB_MULTILIB='$(SHLIB_MULTILIB)'; \
68	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(DRIVER_DEFINES) \
69		$(INCLUDES) $(srcdir)/cp/g++spec.c)
70
71po-generated: $(srcdir)/cp/parse.c
72
73# Create the compiler driver for g++.
74GXX_OBJS = gcc.o g++spec.o intl.o prefix.o version.o 
75g++$(exeext): $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBDEPS)
76	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
77	  $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBS)
78
79# Create a version of the g++ driver which calls the cross-compiler.
80g++-cross$(exeext): g++$(exeext)
81	-rm -f g++-cross$(exeext)
82	cp g++$(exeext) g++-cross$(exeext)
83
84# The demangler.
85cxxmain.o: $(srcdir)/../libiberty/cplus-dem.c $(DEMANGLE_H) $(CONFIG_H)
86	rm -f cxxmain.c
87	$(LN_S) $(srcdir)/../libiberty/cplus-dem.c cxxmain.c
88	$(CC) -c -DMAIN $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
89	  -DVERSION=\"$(version)\" cxxmain.c
90
91# Apparently OpenVM needs the -o to be at the beginning of the link line.
92$(DEMANGLER_PROG): cxxmain.o underscore.o $(LIBDEPS)
93	$(CC) -o $@ $(ALL_CFLAGS) $(LDFLAGS) \
94	  cxxmain.o underscore.o $(LIBS)
95
96# The compiler itself.
97# Shared with C front end:
98CXX_C_OBJS = attribs.o c-common.o c-format.o c-pragma.o c-semantics.o c-lex.o \
99 $(CXX_TARGET_OBJS)
100
101# Language-specific object files.
102CXX_OBJS = cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o \
103 cp/class.o cp/decl2.o cp/error.o cp/lex.o cp/parse.o cp/ptree.o cp/rtti.o \
104 cp/spew.o cp/typeck.o cp/cvt.o cp/except.o cp/friend.o cp/init.o cp/method.o \
105 cp/search.o cp/semantics.o cp/tree.o cp/xref.o cp/repo.o cp/dump.o \
106 cp/optimize.o cp/mangle.o cp/cp-lang.o
107
108# Use loose warnings for this front end.
109cp-warn =
110
111cc1plus$(exeext): $(CXX_OBJS) $(CXX_C_OBJS) $(BACKEND) \
112		  libcpp.a $(LIBDEPS)
113	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
114	      $(CXX_OBJS) $(CXX_C_OBJS) $(BACKEND) libcpp.a $(LIBS)
115
116# Special build rules.
117$(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf
118	gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' \
119		$(srcdir)/cp/cfns.gperf > $(srcdir)/cp/cfns.h
120
121$(srcdir)/cp/parse.h: $(srcdir)/cp/parse.c
122$(srcdir)/cp/parse.c: $(srcdir)/cp/parse.y
123	@echo "Expect 31 shift/reduce conflicts and 58 reduce/reduce conflicts."
124	cd $(srcdir)/cp && \
125	if $(BISON) $(BISONFLAGS) -d -o p$$$$.c parse.y; then \
126	  grep '^#define[ 	]*YYEMPTY' p$$$$.c >> p$$$$.h ; \
127	  test -f p$$$$.output && mv -f p$$$$.output parse.output ; \
128	  mv -f p$$$$.c parse.c ; mv -f p$$$$.h parse.h ; \
129	else \
130	  rm -f p$$$$.* ; \
131	  false ; \
132	fi
133
134#
135# Build hooks:
136
137c++.all.build: g++$(exeext)
138c++.all.cross: g++-cross$(exeext) $(DEMANGLER_PROG)
139c++.start.encap: g++$(exeext)
140c++.rest.encap: $(DEMANGLER_PROG)
141
142c++.info: 
143c++.dvi:
144c++.generated-manpages:
145
146#
147# Install hooks:
148# cc1plus is installed elsewhere as part of $(COMPILERS).
149
150# Nothing to do here.
151c++.install-normal:
152
153# Install the driver program as $(target)-g++
154# and also as either g++ (if native) or $(tooldir)/bin/g++.
155c++.install-common: installdirs
156	-if [ -f cc1plus$(exeext) ] ; then \
157	  if [ -f g++-cross$(exeext) ] ; then \
158	    rm -f $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
159	    $(INSTALL_PROGRAM) g++-cross$(exeext) $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
160	    chmod a+x $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
161	    rm -f $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
162	    $(LN) $(bindir)/$(GXX_CROSS_NAME)$(exeext) $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
163	    if [ -d $(gcc_tooldir)/bin/. ] ; then \
164	      rm -f $(gcc_tooldir)/bin/g++$(exeext); \
165	      $(INSTALL_PROGRAM) g++-cross$(exeext) $(gcc_tooldir)/bin/g++$(exeext); \
166	      rm -f $(gcc_tooldir)/bin/c++$(exeext); \
167	      $(LN) $(gcc_tooldir)/bin/g++$(exeext) $(gcc_tooldir)/bin/c++$(exeext); \
168	    else true; fi; \
169	  else \
170	    rm -f $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
171	    $(INSTALL_PROGRAM) g++$(exeext) $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
172	    chmod a+x $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
173	    rm -f $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
174	    $(LN) $(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
175	    rm -f $(bindir)/$(GXX_TARGET_INSTALL_NAME)$(exeext); \
176	    $(LN) $(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(bindir)/$(GXX_TARGET_INSTALL_NAME)$(exeext); \
177	    rm -f $(bindir)/$(CXX_TARGET_INSTALL_NAME)$(exeext); \
178	    $(LN) $(bindir)/$(CXX_INSTALL_NAME)$(exeext) $(bindir)/$(CXX_TARGET_INSTALL_NAME)$(exeext); \
179	  fi ; \
180	  if [ x$(DEMANGLER_PROG) != x ] && [ -x "$(DEMANGLER_PROG)" ]; then \
181	    if [ -f g++-cross$(exeext) ] ; then \
182	      rm -f $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
183	      $(INSTALL_PROGRAM) $(DEMANGLER_PROG) $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
184	      chmod a+x $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
185	    else \
186	      rm -f $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
187	      $(INSTALL_PROGRAM) $(DEMANGLER_PROG) $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
188	      chmod a+x $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
189	    fi ; \
190	  fi ; \
191	fi
192
193c++.install-info: 
194
195c++.install-man: installdirs $(srcdir)/cp/g++.1
196	-if [ -f cc1plus$(exeext) ] ; then \
197	  if [ -f g++-cross$(exeext) ] ; then \
198	    rm -f $(man1dir)/$(GXX_CROSS_NAME)$(man1ext); \
199	    $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(man1dir)/$(GXX_CROSS_NAME)$(man1ext); \
200	    chmod a-x $(man1dir)/$(GXX_CROSS_NAME)$(man1ext); \
201	  else \
202	    rm -f $(man1dir)/$(GXX_INSTALL_NAME)$(man1ext); \
203	    $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(man1dir)/$(GXX_INSTALL_NAME)$(man1ext); \
204	    chmod a-x $(man1dir)/$(GXX_INSTALL_NAME)$(man1ext); \
205	  fi; \
206	else true; fi
207
208c++.uninstall:
209	-rm -rf $(bindir)/$(CXX_INSTALL_NAME)$(exeext)
210	-rm -rf $(bindir)/$(CXX_CROSS_NAME)$(exeext)
211	-rm -rf $(bindir)/$(GXX_INSTALL_NAME)$(exeext)
212	-rm -rf $(bindir)/$(GXX_CROSS_NAME)$(exeext)
213	-rm -rf $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext)
214	-rm -rf $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext)
215	-rm -rf $(man1dir)/$(GXX_INSTALL_NAME)$(man1ext)
216	-rm -rf $(man1dir)/$(GXX_CROSS_NAME)$(man1ext)
217#
218# Clean hooks:
219# A lot of the ancillary files are deleted by the main makefile.
220# We just have to delete files specific to us.
221
222c++.mostlyclean:
223	-rm -f cp/*$(objext) $(DEMANGLER_PROG)
224c++.clean:
225c++.distclean:
226	-rm -f cp/config.status cp/Makefile
227	-rm -f $(srcdir)/cp/parse.output
228c++.extraclean:
229c++.maintainer-clean:
230	-rm -f $(srcdir)/cp/parse.c $(srcdir)/cp/parse.h
231#
232# Stage hooks:
233# The main makefile has already created stage?/cp.
234
235c++.stage1: stage1-start
236	-mv cp/*$(objext) stage1/cp
237c++.stage2: stage2-start
238	-mv cp/*$(objext) stage2/cp
239c++.stage3: stage3-start
240	-mv cp/*$(objext) stage3/cp
241c++.stage4: stage4-start
242	-mv cp/*$(objext) stage4/cp
243
244#
245# .o: .h dependencies.
246CXX_TREE_H = $(TREE_H) cp/cp-tree.h c-common.h cp/cp-tree.def c-common.def \
247	function.h varray.h $(SYSTEM_H) $(CONFIG_H) $(TARGET_H) \
248	$(srcdir)/../include/hashtab.h $(srcdir)/../include/splay-tree.h
249
250cp/spew.o: cp/spew.c $(CXX_TREE_H) cp/parse.h flags.h cp/lex.h toplev.h
251cp/lex.o: cp/lex.c $(CXX_TREE_H) cp/parse.h flags.h cp/lex.h c-pragma.h \
252  toplev.h output.h mbchar.h $(GGC_H) input.h diagnostic.h cp/operators.def \
253  $(TM_P_H)
254cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H) toplev.h langhooks.h langhooks-def.h \
255  c-common.h
256cp/decl.o: cp/decl.c $(CXX_TREE_H) flags.h cp/lex.h cp/decl.h stack.h \
257  output.h $(EXPR_H) except.h toplev.h hash.h $(GGC_H) $(RTL_H) \
258  cp/operators.def $(TM_P_H) tree-inline.h diagnostic.h
259cp/decl2.o: cp/decl2.c $(CXX_TREE_H) flags.h cp/lex.h cp/decl.h $(EXPR_H) \
260  output.h except.h toplev.h $(GGC_H) $(RTL_H)
261cp/typeck2.o: cp/typeck2.c $(CXX_TREE_H) flags.h toplev.h output.h $(TM_P_H) \
262   diagnostic.h
263cp/typeck.o: cp/typeck.c $(CXX_TREE_H) flags.h $(RTL_H) $(EXPR_H) toplev.h \
264   diagnostic.h
265cp/class.o: cp/class.c $(CXX_TREE_H) flags.h toplev.h $(RTL_H)
266cp/call.o: cp/call.c $(CXX_TREE_H) flags.h toplev.h $(RTL_H) $(EXPR_H) \
267     $(GGC_H) diagnostic.h
268cp/friend.o: cp/friend.c $(CXX_TREE_H) flags.h $(RTL_H) toplev.h $(EXPR_H)
269cp/init.o: cp/init.c $(CXX_TREE_H) flags.h $(RTL_H) $(EXPR_H) toplev.h \
270  $(GGC_H) except.h
271cp/method.o: cp/method.c $(CXX_TREE_H) toplev.h $(GGC_H) $(RTL_H) $(EXPR_H) \
272  $(TM_P_H)
273cp/cvt.o: cp/cvt.c $(CXX_TREE_H) cp/decl.h flags.h toplev.h convert.h
274cp/search.o: cp/search.c $(CXX_TREE_H) stack.h flags.h toplev.h $(RTL_H)
275cp/tree.o: cp/tree.c $(CXX_TREE_H) flags.h toplev.h $(GGC_H) $(RTL_H) \
276  insn-config.h integrate.h tree-inline.h
277cp/ptree.o: cp/ptree.c $(CXX_TREE_H) $(SYSTEM_H)
278cp/rtti.o: cp/rtti.c $(CXX_TREE_H) flags.h toplev.h
279cp/except.o: cp/except.c $(CXX_TREE_H) flags.h $(RTL_H) except.h toplev.h \
280  cp/cfns.h $(EXPR_H) libfuncs.h cp/decl.h $(OBSTACK_H)
281cp/expr.o: cp/expr.c $(CXX_TREE_H) $(RTL_H) flags.h $(EXPR_H) toplev.h \
282  except.h $(TM_P_H)
283cp/xref.o: cp/xref.c $(CXX_TREE_H) input.h toplev.h
284cp/pt.o: cp/pt.c $(CXX_TREE_H) cp/decl.h cp/parse.h cp/lex.h toplev.h \
285  $(GGC_H) $(RTL_H) except.h tree-inline.h
286cp/error.o: cp/error.c $(CXX_TREE_H) toplev.h diagnostic.h flags.h real.h
287cp/repo.o: cp/repo.c $(CXX_TREE_H) toplev.h $(GGC_H) diagnostic.h
288cp/semantics.o: cp/semantics.c $(CXX_TREE_H) cp/lex.h except.h toplev.h \
289  flags.h $(GGC_H) debug.h output.h $(RTL_H) $(TIMEVAR_H) $(EXPR_H) \
290  tree-inline.h
291cp/dump.o: cp/dump.c $(CXX_TREE_H) tree-dump.h
292cp/optimize.o: cp/optimize.c $(CXX_TREE_H) rtl.h integrate.h insn-config.h \
293  input.h $(PARAMS_H) debug.h tree-inline.h
294cp/mangle.o: cp/mangle.c $(CXX_TREE_H) toplev.h
295
296cp/parse.o: cp/parse.c $(CXX_TREE_H) flags.h cp/lex.h except.h output.h \
297	$(SYSTEM_H) toplev.h $(GGC_H)
298	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(BIG_SWITCHFLAG) \
299		$(srcdir)/cp/parse.c $(OUTPUT_OPTION)
300#
301# These exist for maintenance purposes.
302
303# Update the tags table.
304cp/TAGS: force
305	cd $(srcdir)/cp ;			\
306	etags --no-globals -l c `echo *.c | sed 's/parse.c//'` \
307	  parse.y *.h ../*.c ../*.h;
308
309.PHONY: cp/TAGS
310