OSDN Git Service

14cdcfedf5e2ce52f4af9441d949627e5de0c11f
[pf3gnuchains/gcc-fork.git] / gcc / fortran / Make-lang.in
1 # -*- makefile -*-
2 # Top level makefile fragment for GNU gfortran, the GNU Fortran 95 compiler.
3 # Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
4 # Contributed by Paul Brook <paul@nowt.org
5 # and Steven Bosscher <s.bosscher@student.tudelft.nl>
6
7 #This file is part of GCC.
8
9 #GCC is free software; you can redistribute it and/or modify
10 #it under the terms of the GNU General Public License as published by
11 #the Free Software Foundation; either version 2, or (at your option)
12 #any later version.
13
14 #GCC is distributed in the hope that it will be useful,
15 #but WITHOUT ANY WARRANTY; without even the implied warranty of
16 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 #GNU General Public License for more details.
18
19 #You should have received a copy of the GNU General Public License
20 #along with GCC; see the file COPYING.  If not, write to
21 #the Free Software Foundation, 59 Temple Place - Suite 330,
22 #Boston, MA 02111-1307, USA.
23
24 # This file provides the language dependent support in the main Makefile.
25 # Each language makefile fragment must provide the following targets:
26 #
27 # foo.all.build, foo.all.cross, foo.start.encap, foo.rest.encap,
28 # foo.info, foo.dvi,
29 # foo.install-normal, foo.install-common, foo.install-info, foo.install-man,
30 # foo.uninstall, foo.distdir,
31 # foo.mostlyclean, foo.clean, foo.distclean, foo.extraclean,
32 # foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
33 #
34 # where `foo' is the name of the language.
35 #
36 # It should also provide rules for:
37 #
38 # - making any compiler driver (eg: gfortran)
39 # - the compiler proper (eg: f951)
40 # - define the names for selecting the language in LANGUAGES.
41 # $(srcdir) must be set to the gcc/ source directory (*not* gcc/fortran/).
42
43 # Actual name to use when installing a native compiler.
44 GFORTRAN_INSTALL_NAME := $(shell echo gfortran|sed '$(program_transform_name)')
45
46 # Actual name to use when installing a cross-compiler.
47 GFORTRAN_CROSS_NAME := $(shell echo gfortran|sed '$(program_transform_cross_name)')
48
49 #^L
50
51 # This is in addition to the warning flags defined by default.
52 # You can use it to enable/disable warnings globally or for specific
53 # files, e.g.
54 # fortran-warn = -Wno-strict-prototypes
55 # fortran/arith.o-warn = -Wno-error
56 #
57 # We don't need these cheats, everything builds fine with all warnings
58 # enabled and -Werror.
59
60 # These are the groups of object files we have.  The F95_PARSER_OBJS are
61 # all the front end files, the F95_OBJS are the files for the translation
62 # from the parse tree to GENERIC
63
64 F95_PARSER_OBJS = fortran/arith.o fortran/array.o fortran/bbt.o \
65     fortran/check.o fortran/data.o fortran/decl.o fortran/dump-parse-tree.o \
66     fortran/error.o fortran/expr.o fortran/interface.o \
67     fortran/intrinsic.o fortran/io.o fortran/iresolve.o \
68     fortran/match.o fortran/matchexp.o fortran/misc.o fortran/module.o \
69     fortran/options.o fortran/parse.o fortran/primary.o fortran/resolve.o \
70     fortran/scanner.o fortran/simplify.o fortran/st.o fortran/symbol.o
71
72 F95_OBJS = $(F95_PARSER_OBJS) \
73     fortran/convert.o fortran/dependency.o fortran/f95-lang.o \
74     fortran/trans.o fortran/trans-array.o fortran/trans-common.o \
75     fortran/trans-const.o fortran/trans-decl.o fortran/trans-expr.o \
76     fortran/trans-intrinsic.o fortran/trans-io.o fortran/trans-stmt.o \
77     fortran/trans-types.o
78
79 # GFORTRAN uses GMP for its internal arithmetics.
80 F95_LIBS = $(GMPLIBS) $(LIBS)
81
82 #\f
83 # Define the names for selecting gfortran in LANGUAGES.
84 F95 f95: f951$(exeext)
85
86 # Tell GNU make to ignore files by these names if they exist.
87 .PHONY: F95 f95
88
89 gfortranspec.o: $(srcdir)/fortran/gfortranspec.c $(SYSTEM_H) $(TM_H) $(GCC_H) $(CONFIG_H)
90         (SHLIB_LINK='$(SHLIB_LINK)' \
91         SHLIB_MULTILIB='$(SHLIB_MULTILIB)'; \
92         $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(DRIVER_DEFINES) \
93                 $(INCLUDES) $(srcdir)/fortran/gfortranspec.c)
94
95 # Create the compiler driver gfortran.
96 GFORTRAN_D_OBJS = gcc.o gfortranspec.o version.o prefix.o intl.o
97 gfortran$(exeext): $(GFORTRAN_D_OBJS) $(EXTRA_GCC_OBJS) $(LIBDEPS)
98         $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
99           $(GFORTRAN_D_OBJS) $(EXTRA_GCC_OBJS) $(LIBS)
100
101 # Create a version of the gfortran driver which calls the cross-compiler.
102 gfortran-cross$(exeext): gfortran$(exeext)
103         -rm -f gfortran-cross$(exeext)
104         cp gfortran$(exeext) gfortran-cross$(exeext)
105
106 # The compiler itself is called f951.
107 f951$(exeext): $(F95_OBJS) \
108                 $(BACKEND) $(LIBDEPS)
109         $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
110                 $(F95_OBJS) $(BACKEND) $(F95_LIBS)
111
112 gt-fortran-f95-lang.h gtype-fortran.h         : s-gtype; @true
113 gt-fortran-trans-decl.h gt-fortran-trans.h    : s-gtype; @true
114 gt-fortran-trans-io.h gt-fortran-trans-types.h: s-gtype; @true
115 gt-fortran-trans-intrinsic.h                  : s-gtype; @true
116
117 #\f
118 # Build hooks:
119
120 f95.all.build: gfortran$(exeext)
121 f95.all.cross: gfortran-cross$(exeext)
122
123 f95.start.encap: gfortran$(exeext)
124 f95.rest.encap:
125
126 f95.srcinfo: doc/gfortran.info
127         -cp -p $^ $(srcdir)/fortran
128
129 f95.tags: force
130         cd $(srcdir)/fortran; etags -o TAGS.sub *.c *.h; \
131         etags --include TAGS.sub --include ../TAGS.sub
132
133 f95.info: doc/gfortran.info
134 dvi:: doc/gfortran.dvi
135
136 F95_MANFILES = doc/gfortran.1
137
138 f95.man: $(F95_MANFILES)
139
140 f95.srcman: $(F95_MANFILES)
141         -cp -p $^ $(srcdir)/doc
142
143 f95.srcextra:
144
145 check-f95 : check-gfortran
146 lang_checks += check-gfortran
147
148 # GFORTRAN documentation.
149 GFORTRAN_TEXI = \
150   $(srcdir)/fortran/gfortran.texi \
151   $(srcdir)/fortran/invoke.texi \
152   $(srcdir)/doc/include/fdl.texi \
153   $(srcdir)/doc/include/gpl.texi \
154   $(srcdir)/doc/include/funding.texi \
155   $(srcdir)/doc/include/gcc-common.texi
156
157 doc/gfortran.info: $(GFORTRAN_TEXI)
158         if [ x$(BUILD_INFO) = xinfo ]; then \
159           rm -f doc/gfortran.info-*; \
160           $(MAKEINFO) -I$(srcdir)/doc/include -I$(srcdir)/fortran \
161             -o doc/gfortran.info $(srcdir)/fortran/gfortran.texi; \
162         else true; fi
163
164 doc/gfortran.dvi: $(GFORTRAN_TEXI)
165         $(TEXI2DVI) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $<
166
167 .INTERMEDIATE: gfortran.pod
168
169 gfortran.pod: $(GFORTRAN_TEXI)
170         -$(TEXI2POD) < $(srcdir)/fortran/invoke.texi > $@
171
172 #\f
173 # Install hooks:
174 # f951 is installed elsewhere as part of $(COMPILERS).
175
176 # Nothing to do here.
177 f95.install-normal:
178
179 # Install the driver program as $(target)-gfortran
180 # and also as either gfortran (if native) or $(tooldir)/bin/gfortran.
181 f95.install-common: installdirs
182         -if [ -f f951$(exeext) ] ; then \
183           if [ -f gfortran-cross$(exeext) ] ; then \
184             rm -f $(DESTDIR)$(bindir)/$(GFORTRAN_CROSS_NAME)$(exeext); \
185             $(INSTALL_PROGRAM) gfortran-cross$(exeext) $(DESTDIR)$(bindir)/$(GFORTRAN_CROSS_NAME)$(exeext); \
186             chmod a+x $(DESTDIR)$(bindir)/$(GFORTRAN_CROSS_NAME)$(exeext); \
187             if [ -d $(DESTDIR)$(gcc_tooldir)/bin/. ] ; then \
188               rm -f $(DESTDIR)$(gcc_tooldir)/bin/gfortran$(exeext); \
189               $(INSTALL_PROGRAM) gfortran-cross$(exeext) $(DESTDIR)$(gcc_tooldir)/bin/gfortran$(exeext); \
190             else true; fi; \
191           else \
192             rm -f $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
193             $(INSTALL_PROGRAM) gfortran$(exeext) $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
194             chmod a+x $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
195             rm -f $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \
196             $(LN) $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext) $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \
197           fi ; \
198         fi
199
200 install-info:: $(DESTDIR)$(infodir)/gfortran.info
201
202 f95.install-man: installdirs \
203         $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext)
204
205 $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext): doc/gfortran.1
206         -rm -f $@
207         -$(INSTALL_DATA) $< $@
208         -chmod a-x $@
209
210 f95.uninstall:
211         if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
212           echo " install-info --delete --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gfortran.info"; \
213           install-info --delete --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gfortran.info || : ; \
214         else : ; fi; \
215         rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
216         rm -rf $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext); \
217         rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_CROSS_NAME)$(exeext); \
218         rm -rf $(DESTDIR)$(infodir)/gfortran.info*
219
220 #\f
221 # Clean hooks:
222 # A lot of the ancillary files are deleted by the main makefile.
223 # We just have to delete files specific to us.
224
225 f95.mostlyclean:
226         -rm -f f951$(exeext)
227         -rm -f fortran/*.o
228
229 f95.clean:
230 f95.distclean:
231         -rm -f fortran/config.status fortran/Makefile
232
233 f95.extraclean:
234 f95.maintainer-clean:
235         -rm -f doc/gfortran.info* fortran/gfortran.*aux
236         -rm -f $(docobjdir)/gfortran.1
237
238 #\f
239 # Stage hooks:
240 # The toplevel makefile has already created stage?/fortran at this point.
241
242 f95.stage1: stage1-start
243         -mv fortran/*$(objext) stage1/fortran
244 f95.stage2: stage2-start
245         -mv fortran/*$(objext) stage2/fortran
246 f95.stage3: stage3-start
247         -mv fortran/*$(objext) stage3/fortran
248 f95.stage4: stage4-start
249         -mv fortran/*$(objext) stage4/fortran
250 f95.stageprofile: stageprofile-start
251         -mv fortran/*$(objext) stageprofile/fortran
252 f95.stagefeedback: stageprofile-start
253         -mv fortran/*$(objext) stagefeedback/fortran
254
255 #\f
256 # .o: .h dependencies.
257
258 # Everything depends on gfortran.h, but only a few files depend on
259 # the other headers.  So at some point we'll have to split out
260 # which objects depend on what.  FIXME
261 # TODO: Add dependencies on the backend/tree header files
262
263 $(F95_PARSER_OBJS): fortran/gfortran.h fortran/intrinsic.h fortran/match.h \
264                 fortran/parse.h \
265                 $(CONFIG_H) $(SYSTEM_H) $(TM_H) $(TM_P_H) coretypes.h \
266                 $(RTL_H) $(TREE_H) $(TREE_DUMP_H) $(GGC_H) $(EXPR_H) \
267                 flags.h output.h diagnostic.h errors.h function.h 
268
269 GFORTRAN_TRANS_DEPS = fortran/gfortran.h fortran/intrinsic.h fortran/trans-array.h \
270     fortran/trans-const.h fortran/trans-const.h fortran/trans.h \
271     fortran/trans-stmt.h fortran/trans-types.h \
272     $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(TM_H) coretypes.h $(GGC_H)
273
274 fortran/f95-lang.o: $(GFORTRAN_TRANS_DEPS) fortran/mathbuiltins.def \
275   gt-fortran-f95-lang.h gtype-fortran.h cgraph.h $(TARGET_H)
276 fortran/convert.o: $(GFORTRAN_TRANS_DEPS)
277 fortran/trans.o: $(GFORTRAN_TRANS_DEPS)
278 fortran/trans-decl.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-decl.h \
279   cgraph.h $(TARGET_H) function.h errors.h $(FLAGS_H) tree-gimple.h \
280   tree-dump.h
281 fortran/trans-types.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-types.h \
282   real.h toplev.h $(TARGET_H)
283 fortran/trans-const.o: $(GFORTRAN_TRANS_DEPS)
284 fortran/trans-expr.o: $(GFORTRAN_TRANS_DEPS)
285 fortran/trans-stmt.o: $(GFORTRAN_TRANS_DEPS)
286 fortran/trans-io.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-io.h
287 fortran/trans-array.o: $(GFORTRAN_TRANS_DEPS)
288 fortran/trans-intrinsic.o: $(GFORTRAN_TRANS_DEPS) fortran/mathbuiltins.def \
289   gt-fortran-trans-intrinsic.h
290 fortran/dependency.o: fortran/gfortran.h fortran/dependency.h
291 fortran/trans-common.o: $(GFORTRAN_TRANS_DEPS)
292