Make-lang.in revision 52284
1# Top level makefile fragment for GNU C++.
2#   Copyright (C) 1994, 1995, 1997, 1998, 1999 Free Software Foundation, Inc.
3
4#This file is part of GNU CC.
5
6#GNU CC is free software; you can redistribute it and/or modify
7#it under the terms of the GNU General Public License as published by
8#the Free Software Foundation; either version 2, or (at your option)
9#any later version.
10
11#GNU CC 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
14#GNU General Public License for more details.
15
16#You should have received a copy of the GNU General Public License
17#along with GNU CC; see the file COPYING.  If not, write to
18#the Free Software Foundation, 59 Temple Place - Suite 330,
19#Boston, MA 02111-1307, USA.
20
21# This file provides the language dependent support in the main Makefile.
22# Each language makefile fragment must provide the following targets:
23#
24# foo.all.build, foo.all.cross, foo.start.encap, foo.rest.encap,
25# foo.info, foo.dvi,
26# foo.install-normal, foo.install-common, foo.install-info, foo.install-man,
27# foo.uninstall, foo.distdir,
28# foo.mostlyclean, foo.clean, foo.distclean, foo.extraclean,
29# foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
30#
31# where `foo' is the name of the language.
32#
33# It should also provide rules for:
34#
35# - making any compiler driver (eg: g++)
36# - the compiler proper (eg: cc1plus)
37# - define the names for selecting the language in LANGUAGES.
38#
39# Extra flags to pass to recursive makes.
40CXX_FLAGS_TO_PASS = \
41	"CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \
42	"CXXFLAGS=$(CXXFLAGS)" \
43	"CXX_FOR_TARGET=$(CXX_FOR_TARGET)"
44
45# Actual names to use when installing a native compiler.
46CXX_INSTALL_NAME = `t='$(program_transform_name)'; echo c++ | sed $$t`
47GXX_INSTALL_NAME = `t='$(program_transform_name)'; echo g++ | sed $$t`
48DEMANGLER_INSTALL_NAME = `t='$(program_transform_name)'; echo c++filt | sed $$t`
49
50# Actual names to use when installing a cross-compiler.
51CXX_CROSS_NAME = `t='$(program_transform_cross_name)'; echo c++ | sed $$t`
52GXX_CROSS_NAME = `t='$(program_transform_cross_name)'; echo g++ | sed $$t`
53DEMANGLER_CROSS_NAME = `t='$(program_transform_cross_name)'; echo c++filt | sed $$t`
54
55# The name to use for the demangler program.
56DEMANGLER_PROG = c++filt$(exeext)
57
58# Extra headers to install.
59CXX_EXTRA_HEADERS = $(srcdir)/cp/inc/typeinfo $(srcdir)/cp/inc/exception \
60	$(srcdir)/cp/inc/new $(srcdir)/cp/inc/new.h
61
62# Extra code to include in libgcc2.
63CXX_LIB2FUNCS = tinfo.o tinfo2.o new.o opnew.o opnewnt.o opvnew.o opvnewnt.o \
64	opdel.o opdelnt.o opvdel.o opvdelnt.o exception.o
65CXX_LIB2SRCS = $(srcdir)/cp/new.cc $(srcdir)/cp/new1.cc $(srcdir)/cp/new2.cc \
66	$(srcdir)/cp/exception.cc $(srcdir)/cp/tinfo.cc \
67	$(srcdir)/cp/tinfo2.cc $(srcdir)/cp/tinfo.h
68#
69# Define the names for selecting c++ in LANGUAGES.
70# Note that it would be nice to move the dependency on g++
71# into the C++ rule, but that needs a little bit of work
72# to do the right thing within all.cross.
73C++ c++: cc1plus$(exeext)
74
75# Tell GNU make to ignore these if they exist.
76.PHONY: C++ c++
77
78g++spec.o: $(srcdir)/cp/g++spec.c
79	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(srcdir)/cp/g++spec.c
80
81$(INTL_TARGETS): $(srcdir)/cp/parse.c
82$(srcdir)/cp/parse.c: $(srcdir)/cp/parse.y
83	@cp_srcdir=`sed -n 's/^srcdir[ 	]*=[	 ]*//p' cp/Makefile` && \
84	echo "cd cp && $(MAKE) $$cp_srcdir/parse.c" && \
85	cd cp && \
86	  $(MAKE) $(SUBDIR_FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) \
87	    $$cp_srcdir/parse.c
88
89# Create the compiler driver for g++.
90GXX_OBJS = gcc.o g++spec.o intl.o prefix.o version.o 
91g++$(exeext): $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBDEPS)
92	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
93	  $(GXX_OBJS) $(EXTRA_GCC_OBJS) $(LIBS)
94
95# Create a version of the g++ driver which calls the cross-compiler.
96g++-cross$(exeext): g++$(exeext)
97	-rm -f g++-cross$(exeext)
98	cp g++$(exeext) g++-cross$(exeext)
99
100cxxmain.o: $(srcdir)/../libiberty/cplus-dem.c $(DEMANGLE_H)
101	rm -f cxxmain.c
102	$(LN_S) $(srcdir)/../libiberty/cplus-dem.c cxxmain.c
103	$(CC) -c -DMAIN $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
104	  -DVERSION=\"$(version)\" cxxmain.c
105
106# Apparently OpenVM needs the -o to be at the beginning of the link line.
107$(DEMANGLER_PROG): cxxmain.o underscore.o $(LIBDEPS)
108	$(CC) -o $@ $(ALL_CFLAGS) $(LDFLAGS) \
109	  cxxmain.o underscore.o $(LIBS)
110
111CXX_SRCS = $(srcdir)/cp/call.c $(srcdir)/cp/decl2.c \
112 $(srcdir)/cp/except.c $(srcdir)/cp/input.c $(srcdir)/cp/pt.c \
113 $(srcdir)/cp/spew.c $(srcdir)/cp/xref.c $(srcdir)/cp/class.c \
114 $(srcdir)/cp/expr.c $(srcdir)/cp/lex.c \
115 $(srcdir)/cp/ptree.c $(srcdir)/cp/tree.c $(srcdir)/cp/cvt.c \
116 $(srcdir)/cp/errfn.c $(srcdir)/cp/rtti.c $(srcdir)/cp/method.c \
117 $(srcdir)/cp/search.c $(srcdir)/cp/typeck.c $(srcdir)/cp/decl.c \
118 $(srcdir)/cp/error.c $(srcdir)/cp/friend.c $(srcdir)/cp/init.c \
119 $(srcdir)/cp/parse.y $(srcdir)/cp/sig.c $(srcdir)/cp/typeck2.c \
120 $(srcdir)/cp/repo.c $(srcdir)/cp/semantics.c
121
122cc1plus$(exeext): $(P) $(CXX_SRCS) $(LIBDEPS) stamp-objlist c-common.o c-pragma.o \
123	$(srcdir)/cp/cp-tree.h $(srcdir)/cp/cp-tree.def hash.o
124	cd cp; $(MAKE) $(FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) ../cc1plus$(exeext)
125#
126# Build hooks:
127
128c++.all.build: g++$(exeext)
129c++.all.cross: g++-cross$(exeext) $(DEMANGLER_PROG)
130c++.start.encap: g++$(exeext)
131c++.rest.encap: $(DEMANGLER_PROG)
132
133c++.info:
134c++.dvi:
135
136# C++ language-support library pieces for libgcc.
137tinfo.o: cc1plus$(exeext) $(srcdir)/cp/tinfo.cc
138	$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
139	  -c $(srcdir)/cp/tinfo.cc
140tinfo2.o: cc1plus$(exeext) $(srcdir)/cp/tinfo2.cc
141	$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
142	  -c $(srcdir)/cp/tinfo2.cc
143exception.o: cc1plus$(exeext) $(srcdir)/cp/exception.cc
144	$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
145	  -c -fexceptions $(srcdir)/cp/exception.cc
146new.o: cc1plus$(exeext) $(srcdir)/cp/new.cc
147	$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
148	  -c $(srcdir)/cp/new.cc
149opnew.o: cc1plus$(exeext) $(srcdir)/cp/new1.cc
150	$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
151	  -c $(srcdir)/cp/new1.cc -DL_op_new -o opnew.o
152opnewnt.o: cc1plus$(exeext) $(srcdir)/cp/new1.cc
153	$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
154	  -c $(srcdir)/cp/new1.cc -DL_op_newnt -o opnewnt.o
155opvnew.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
156	$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
157	  -c $(srcdir)/cp/new2.cc -DL_op_vnew -o opvnew.o
158opvnewnt.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
159	$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
160	  -c $(srcdir)/cp/new2.cc -DL_op_vnewnt -o opvnewnt.o
161opdel.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
162	$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
163	  -c $(srcdir)/cp/new2.cc -DL_op_delete -o opdel.o
164opdelnt.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
165	$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
166	  -c $(srcdir)/cp/new2.cc -DL_op_delnt -o opdelnt.o
167opvdel.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
168	$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
169	  -c $(srcdir)/cp/new2.cc -DL_op_vdel -o opvdel.o
170opvdelnt.o: cc1plus$(exeext) $(srcdir)/cp/new2.cc
171	$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(CXXFLAGS) $(INCLUDES) \
172	  -c $(srcdir)/cp/new2.cc -DL_op_vdelnt -o opvdelnt.o
173
174# We want to update cplib2.txt if any of the source files change...
175cplib2.txt: $(CXX_LIB2SRCS) $(CXX_EXTRA_HEADERS) cplib2.ready
176	case " $(LANGUAGES) " in \
177	*" "[cC]"++ "*) \
178	  echo $(CXX_LIB2FUNCS) > cplib2.new;; \
179	*) \
180	  echo "" > cplib2.new;; \
181	esac
182	mv -f cplib2.new cplib2.txt 
183
184# Or if it would be different.
185# Don't try to do write if `.' is not writable;
186# in that case, we're installing from someone else's directory.
187# But go ahead and fail if that directory hasn't been properly built.
188cplib2.ready: $(GCC_PASSES) $(LIBGCC2_DEPS) stmp-int-hdrs
189	@if [ -r cplib2.txt -a -w . ]; then \
190	  case " $(LANGUAGES) " in \
191	  *" "[cC]"++ "*) \
192	    echo $(CXX_LIB2FUNCS) > cplib2.new;; \
193	  *) \
194	    echo "" > cplib2.new;; \
195	  esac; \
196	  if cmp -s cplib2.new cplib2.txt; then true; else \
197	    touch cplib2.ready; \
198	  fi; \
199	  rm -f cplib2.new; \
200	else true ; \
201	fi
202	@if [ -f cplib2.ready ]; then true; else \
203	  touch cplib2.ready; \
204	fi
205#
206# Install hooks:
207# cc1plus is installed elsewhere as part of $(COMPILERS).
208
209# Nothing to do here.
210c++.install-normal:
211
212# Install the driver program as $(target)-g++
213# and also as either g++ (if native) or $(tooldir)/bin/g++.
214c++.install-common:
215	-if [ -f cc1plus$(exeext) ] ; then \
216	  if [ -f g++-cross$(exeext) ] ; then \
217	    rm -f $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
218	    $(INSTALL_PROGRAM) g++-cross$(exeext) $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
219	    chmod a+x $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
220	    rm -f $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
221	    $(LN) $(bindir)/$(GXX_CROSS_NAME)$(exeext) $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
222	  else \
223	    rm -f $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
224	    $(INSTALL_PROGRAM) g++$(exeext) $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
225	    chmod a+x $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
226	    rm -f $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
227	    $(LN) $(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
228	  fi ; \
229	  if [ x$(DEMANGLER_PROG) != x ] && [ -x "$(DEMANGLER_PROG)" ]; then \
230	    if [ -f g++-cross$(exeext) ] ; then \
231	      rm -f $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
232	      $(INSTALL_PROGRAM) $(DEMANGLER_PROG) $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
233	      chmod a+x $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext); \
234	    else \
235	      rm -f $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
236	      $(INSTALL_PROGRAM) $(DEMANGLER_PROG) $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
237	      chmod a+x $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext); \
238	    fi ; \
239	  fi ; \
240	fi
241
242c++.install-info:
243
244c++.install-man: $(srcdir)/cp/g++.1
245	-if [ -f cc1plus$(exeext) ] ; then \
246	  if [ -f g++-cross$(exeext) ] ; then \
247	    rm -f $(man1dir)/$(GXX_CROSS_NAME)$(manext); \
248	    $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(man1dir)/$(GXX_CROSS_NAME)$(manext); \
249	    chmod a-x $(man1dir)/$(GXX_CROSS_NAME)$(manext); \
250	  else \
251	    rm -f $(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
252	    $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
253	    chmod a-x $(man1dir)/$(GXX_INSTALL_NAME)$(manext); \
254	  fi; \
255	else true; fi
256
257c++.uninstall:
258	-rm -rf $(bindir)/$(CXX_INSTALL_NAME)$(exeext)
259	-rm -rf $(bindir)/$(CXX_CROSS_NAME)$(exeext)
260	-rm -rf $(bindir)/$(GXX_INSTALL_NAME)$(exeext)
261	-rm -rf $(bindir)/$(GXX_CROSS_NAME)$(exeext)
262	-rm -rf $(bindir)/$(DEMANGLER_INSTALL_NAME)$(exeext)
263	-rm -rf $(bindir)/$(DEMANGLER_CROSS_NAME)$(exeext)
264	-rm -rf $(man1dir)/$(GXX_INSTALL_NAME)$(manext)
265	-rm -rf $(man1dir)/$(GXX_CROSS_NAME)$(manext)
266#
267# Clean hooks:
268# A lot of the ancillary files are deleted by the main makefile.
269# We just have to delete files specific to us.
270
271c++.mostlyclean:
272	-rm -f cp/*$(objext) $(DEMANGLER_PROG)
273c++.clean:
274	-rm -f cplib2.txt cplib2.ready
275c++.distclean:
276	-rm -f cp/config.status cp/Makefile
277	-rm -f cp/parse.output
278c++.extraclean:
279c++.maintainer-clean:
280	-rm -f cp/parse.c cp/parse.h
281#
282# Stage hooks:
283# The main makefile has already created stage?/cp.
284
285c++.stage1: stage1-start
286	-mv cp/*$(objext) stage1/cp
287c++.stage2: stage2-start
288	-mv cp/*$(objext) stage2/cp
289c++.stage3: stage3-start
290	-mv cp/*$(objext) stage3/cp
291c++.stage4: stage4-start
292	-mv cp/*$(objext) stage4/cp
293#
294# Maintenance hooks:
295
296# This target creates the files that can be rebuilt, but go in the
297# distribution anyway.  It then copies the files to the distdir directory.
298c++.distdir:
299	mkdir tmp/cp
300	mkdir tmp/cp/inc
301	cd cp ; $(MAKE) $(FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) parse.c hash.h
302	cd cp; \
303	for file in *[0-9a-zA-Z+]; do \
304	  $(LN) $$file ../tmp/cp; \
305	done
306	cd cp/inc; \
307	for file in *[0-9a-zA-Z+]; do \
308	  ln $$file ../../tmp/cp/inc >/dev/null 2>&1 \
309	   || cp $$file ../../tmp/cp/inc; \
310	done
311