2 # Top level makefile fragment for GNU gfortran, the GNU Fortran 95 compiler.
3 # Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 # Contributed by Paul Brook <paul@nowt.org
5 # and Steven Bosscher <s.bosscher@student.tudelft.nl>
7 #This file is part of GCC.
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)
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.
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, 51 Franklin Street, Fifth Floor,
22 #Boston, MA 02110-1301, USA.
24 # This file provides the language dependent support in the main Makefile.
25 # Each language makefile fragment must provide the following targets:
27 # foo.all.build, foo.all.cross, foo.start.encap, foo.rest.encap,
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
34 # where `foo' is the name of the language.
36 # It should also provide rules for:
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/).
43 # Actual name to use when installing a native compiler.
44 GFORTRAN_INSTALL_NAME := $(shell echo gfortran|sed '$(program_transform_name)')
46 # Actual name to use when installing a cross-compiler.
47 GFORTRAN_CROSS_NAME := $(shell echo gfortran|sed '$(program_transform_cross_name)')
51 # Use strict warnings for this front end.
52 fortran-warn = $(STRICT_WARN)
54 # These files get warnings from an inline function in GMP saying:
55 # "control may reach end of non-void function '__gmpz_get_ui' being inlined"
56 fortran/expr.o-warn = -Wno-error
57 fortran/resolve.o-warn = -Wno-error
58 fortran/simplify.o-warn = -Wno-error
59 fortran/trans-common.o-warn = -Wno-error
61 # These are the groups of object files we have. The F95_PARSER_OBJS are
62 # all the front end files, the F95_OBJS are the files for the translation
63 # from the parse tree to GENERIC
65 F95_PARSER_OBJS = fortran/arith.o fortran/array.o fortran/bbt.o \
66 fortran/check.o fortran/data.o fortran/decl.o fortran/dump-parse-tree.o \
67 fortran/error.o fortran/expr.o fortran/interface.o \
68 fortran/intrinsic.o fortran/io.o fortran/iresolve.o \
69 fortran/match.o fortran/matchexp.o fortran/misc.o fortran/module.o \
70 fortran/options.o fortran/parse.o fortran/primary.o fortran/resolve.o \
71 fortran/scanner.o fortran/simplify.o fortran/st.o fortran/symbol.o
73 F95_OBJS = $(F95_PARSER_OBJS) \
74 fortran/convert.o fortran/dependency.o fortran/f95-lang.o \
75 fortran/trans.o fortran/trans-array.o fortran/trans-common.o \
76 fortran/trans-const.o fortran/trans-decl.o fortran/trans-expr.o \
77 fortran/trans-intrinsic.o fortran/trans-io.o fortran/trans-stmt.o \
80 # GFORTRAN uses GMP for its internal arithmetics.
81 F95_LIBS = $(GMPLIBS) $(LIBS)
84 # Define the names for selecting gfortran in LANGUAGES.
85 FORTRAN fortran: f951$(exeext)
87 # Tell GNU make to ignore files by these names if they exist.
90 gfortranspec.o: $(srcdir)/fortran/gfortranspec.c $(SYSTEM_H) $(TM_H) $(GCC_H) $(CONFIG_H)
91 (SHLIB_LINK='$(SHLIB_LINK)' \
92 SHLIB_MULTILIB='$(SHLIB_MULTILIB)'; \
93 $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(DRIVER_DEFINES) \
94 $(INCLUDES) $(srcdir)/fortran/gfortranspec.c)
96 # Create the compiler driver gfortran.
97 GFORTRAN_D_OBJS = gcc.o gfortranspec.o version.o prefix.o intl.o
98 gfortran$(exeext): $(GFORTRAN_D_OBJS) $(EXTRA_GCC_OBJS) $(LIBDEPS)
99 $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
100 $(GFORTRAN_D_OBJS) $(EXTRA_GCC_OBJS) $(LIBS)
102 # Create a version of the gfortran driver which calls the cross-compiler.
103 gfortran-cross$(exeext): gfortran$(exeext)
104 -rm -f gfortran-cross$(exeext)
105 cp gfortran$(exeext) gfortran-cross$(exeext)
107 # The compiler itself is called f951.
108 f951$(exeext): $(F95_OBJS) \
109 $(BACKEND) $(LIBDEPS)
110 $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
111 $(F95_OBJS) $(BACKEND) $(F95_LIBS)
113 gt-fortran-f95-lang.h gtype-fortran.h : s-gtype; @true
114 gt-fortran-trans-decl.h gt-fortran-trans.h : s-gtype; @true
115 gt-fortran-trans-io.h gt-fortran-trans-types.h: s-gtype; @true
116 gt-fortran-trans-intrinsic.h : s-gtype; @true
121 fortran.all.build: gfortran$(exeext)
122 fortran.all.cross: gfortran-cross$(exeext)
124 fortran.start.encap: gfortran$(exeext)
127 fortran.srcinfo: doc/gfortran.info
128 -cp -p $^ $(srcdir)/fortran
131 cd $(srcdir)/fortran; etags -o TAGS.sub *.c *.h; \
132 etags --include TAGS.sub --include ../TAGS.sub
134 fortran.info: doc/gfortran.info
135 dvi:: doc/gfortran.dvi
136 html:: $(htmldir)/gfortran/index.html
138 F95_MANFILES = doc/gfortran.1
140 fortran.man: $(F95_MANFILES)
142 fortran.srcman: $(F95_MANFILES)
143 -cp -p $^ $(srcdir)/doc
147 check-f95 : check-gfortran
148 check-fortran : check-gfortran
149 lang_checks += check-gfortran
151 # GFORTRAN documentation.
153 $(srcdir)/fortran/gfortran.texi \
154 $(srcdir)/fortran/invoke.texi \
155 $(srcdir)/doc/include/fdl.texi \
156 $(srcdir)/doc/include/gpl.texi \
157 $(srcdir)/doc/include/funding.texi \
158 $(srcdir)/doc/include/gcc-common.texi \
161 doc/gfortran.info: $(GFORTRAN_TEXI)
162 if [ x$(BUILD_INFO) = xinfo ]; then \
163 rm -f doc/gfortran.info-*; \
164 $(MAKEINFO) -I $(srcdir)/doc/include -I $(srcdir)/fortran \
168 doc/gfortran.dvi: $(GFORTRAN_TEXI)
169 $(TEXI2DVI) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $<
171 $(htmldir)/gfortran/index.html: $(GFORTRAN_TEXI)
172 $(mkinstalldirs) $(@D)
174 $(TEXI2HTML) -I $(docdir)/include -I $(srcdir)/fortran -o $(@D) $<
176 .INTERMEDIATE: gfortran.pod
178 gfortran.pod: $(GFORTRAN_TEXI)
179 -$(TEXI2POD) < $(srcdir)/fortran/invoke.texi > $@
183 # f951 is installed elsewhere as part of $(COMPILERS).
185 # Nothing to do here.
186 fortran.install-normal:
188 # Install the driver program as $(target)-gfortran
189 # and also as either gfortran (if native) or $(tooldir)/bin/gfortran.
190 fortran.install-common: installdirs
191 -if [ -f f951$(exeext) ] ; then \
192 if [ -f gfortran-cross$(exeext) ] ; then \
193 rm -f $(DESTDIR)$(bindir)/$(GFORTRAN_CROSS_NAME)$(exeext); \
194 $(INSTALL_PROGRAM) gfortran-cross$(exeext) $(DESTDIR)$(bindir)/$(GFORTRAN_CROSS_NAME)$(exeext); \
195 chmod a+x $(DESTDIR)$(bindir)/$(GFORTRAN_CROSS_NAME)$(exeext); \
196 if [ -d $(DESTDIR)$(gcc_tooldir)/bin/. ] ; then \
197 rm -f $(DESTDIR)$(gcc_tooldir)/bin/gfortran$(exeext); \
198 $(INSTALL_PROGRAM) gfortran-cross$(exeext) $(DESTDIR)$(gcc_tooldir)/bin/gfortran$(exeext); \
201 rm -f $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
202 $(INSTALL_PROGRAM) gfortran$(exeext) $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
203 chmod a+x $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
204 rm -f $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \
205 $(LN) $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext) $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \
209 install-info:: $(DESTDIR)$(infodir)/gfortran.info
211 fortran.install-man: $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext)
213 $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext): doc/gfortran.1 \
216 -$(INSTALL_DATA) $< $@
220 if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
221 echo " install-info --delete --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gfortran.info"; \
222 install-info --delete --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gfortran.info || : ; \
224 rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
225 rm -rf $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext); \
226 rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_CROSS_NAME)$(exeext); \
227 rm -rf $(DESTDIR)$(infodir)/gfortran.info*
231 # A lot of the ancillary files are deleted by the main makefile.
232 # We just have to delete files specific to us.
240 -rm -f fortran/config.status fortran/Makefile
243 fortran.maintainer-clean:
244 -rm -f doc/gfortran.info* fortran/gfortran.*aux
245 -rm -f $(docobjdir)/gfortran.1
249 # The toplevel makefile has already created stage?/fortran at this point.
251 fortran.stage1: stage1-start
252 -mv fortran/*$(objext) stage1/fortran
253 fortran.stage2: stage2-start
254 -mv fortran/*$(objext) stage2/fortran
255 fortran.stage3: stage3-start
256 -mv fortran/*$(objext) stage3/fortran
257 fortran.stage4: stage4-start
258 -mv fortran/*$(objext) stage4/fortran
259 fortran.stageprofile: stageprofile-start
260 -mv fortran/*$(objext) stageprofile/fortran
261 fortran.stagefeedback: stageprofile-start
262 -mv fortran/*$(objext) stagefeedback/fortran
265 # .o: .h dependencies.
267 # Everything depends on gfortran.h, but only a few files depend on
268 # the other headers. So at some point we'll have to split out
269 # which objects depend on what. FIXME
270 # TODO: Add dependencies on the backend/tree header files
272 $(F95_PARSER_OBJS): fortran/gfortran.h fortran/intrinsic.h fortran/match.h \
274 $(CONFIG_H) $(SYSTEM_H) $(TM_H) $(TM_P_H) coretypes.h \
275 $(RTL_H) $(TREE_H) $(TREE_DUMP_H) $(GGC_H) $(EXPR_H) \
276 flags.h output.h diagnostic.h errors.h function.h
278 GFORTRAN_TRANS_DEPS = fortran/gfortran.h fortran/intrinsic.h fortran/trans-array.h \
279 fortran/trans-const.h fortran/trans-const.h fortran/trans.h \
280 fortran/trans-stmt.h fortran/trans-types.h \
281 $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(TM_H) coretypes.h $(GGC_H)
283 fortran/f95-lang.o: $(GFORTRAN_TRANS_DEPS) fortran/mathbuiltins.def \
284 gt-fortran-f95-lang.h gtype-fortran.h cgraph.h $(TARGET_H)
285 fortran/convert.o: $(GFORTRAN_TRANS_DEPS)
286 fortran/trans.o: $(GFORTRAN_TRANS_DEPS)
287 fortran/trans-decl.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-decl.h \
288 cgraph.h $(TARGET_H) function.h $(FLAGS_H) tree-gimple.h \
290 fortran/trans-types.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-types.h \
291 real.h toplev.h $(TARGET_H)
292 fortran/trans-const.o: $(GFORTRAN_TRANS_DEPS)
293 fortran/trans-expr.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h
294 fortran/trans-stmt.o: $(GFORTRAN_TRANS_DEPS)
295 fortran/trans-io.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-io.h
296 fortran/trans-array.o: $(GFORTRAN_TRANS_DEPS)
297 fortran/trans-intrinsic.o: $(GFORTRAN_TRANS_DEPS) fortran/mathbuiltins.def \
298 gt-fortran-trans-intrinsic.h
299 fortran/dependency.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h
300 fortran/trans-common.o: $(GFORTRAN_TRANS_DEPS)