OSDN Git Service

2006-10-09 Brooks Moses <bmoses@stanford.edu>
[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, 2005, 2006 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, 51 Franklin Street, Fifth Floor,
22 #Boston, MA 02110-1301, 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.cross, foo.start.encap, foo.rest.encap,
28 # foo.info
29 # foo.install-common, foo.install-info, foo.install-man,
30 # foo.uninstall, foo.install-info, foo.dvi, foo.html,
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 GFORTRAN_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gfortran|sed '$(program_transform_name)')
46
47 #^L
48
49 # Use strict warnings for this front end.
50 fortran-warn = $(STRICT_WARN)
51
52 # These files get warnings from an inline function in GMP saying:
53 # "control may reach end of non-void function '__gmpz_get_ui' being inlined"
54 fortran/expr.o-warn = -Wno-error
55 fortran/resolve.o-warn = -Wno-error
56 fortran/simplify.o-warn = -Wno-error
57 fortran/trans-common.o-warn = -Wno-error
58
59 # These are the groups of object files we have.  The F95_PARSER_OBJS are
60 # all the front end files, the F95_OBJS are the files for the translation
61 # from the parse tree to GENERIC
62
63 F95_PARSER_OBJS = fortran/arith.o fortran/array.o fortran/bbt.o \
64     fortran/check.o fortran/data.o fortran/decl.o fortran/dump-parse-tree.o \
65     fortran/error.o fortran/expr.o fortran/interface.o \
66     fortran/intrinsic.o fortran/io.o fortran/iresolve.o \
67     fortran/match.o fortran/matchexp.o fortran/misc.o fortran/module.o \
68     fortran/openmp.o fortran/options.o fortran/parse.o fortran/primary.o \
69     fortran/resolve.o fortran/scanner.o fortran/simplify.o fortran/st.o \
70     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-openmp.o \
77     fortran/trans-stmt.o 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 fortran: f951$(exeext)
85
86 # Tell GNU make to ignore files by these names if they exist.
87 .PHONY: fortran
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_OBJS) 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-trans.h    : s-gtype; @true
113 #\f
114 # Build hooks:
115
116 fortran.all.cross: gfortran-cross$(exeext)
117
118 fortran.start.encap: gfortran$(exeext)
119 fortran.rest.encap:
120
121 fortran.srcinfo: doc/gfortran.info
122         -cp -p $^ $(srcdir)/fortran
123
124 fortran.tags: force
125         cd $(srcdir)/fortran; etags -o TAGS.sub *.c *.h; \
126         etags --include TAGS.sub --include ../TAGS.sub
127
128 fortran.info: doc/gfortran.info
129 fortran.dvi: doc/gfortran.dvi
130 fortran.html: $(build_htmldir)/gfortran/index.html
131
132 F95_MANFILES = doc/gfortran.1
133
134 fortran.man: $(F95_MANFILES)
135
136 fortran.srcman: $(F95_MANFILES)
137         -cp -p $^ $(srcdir)/doc
138
139 fortran.srcextra:
140
141 check-f95 : check-gfortran
142 check-fortran : check-gfortran
143 lang_checks += check-gfortran
144
145 # GFORTRAN documentation.
146 GFORTRAN_TEXI = \
147   $(srcdir)/fortran/gfortran.texi \
148   $(srcdir)/fortran/intrinsic.texi \
149   $(srcdir)/fortran/invoke.texi \
150   $(srcdir)/doc/include/fdl.texi \
151   $(srcdir)/doc/include/gpl.texi \
152   $(srcdir)/doc/include/funding.texi \
153   $(srcdir)/doc/include/gcc-common.texi \
154   gcc-vers.texi
155
156 doc/gfortran.info: $(GFORTRAN_TEXI)
157         if [ x$(BUILD_INFO) = xinfo ]; then \
158           rm -f doc/gfortran.info-*; \
159           $(MAKEINFO) -I $(srcdir)/doc/include -I $(srcdir)/fortran \
160             -o $@ $<; \
161         else true; fi
162
163 doc/gfortran.dvi: $(GFORTRAN_TEXI)
164         $(TEXI2DVI) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $<
165
166 $(build_htmldir)/gfortran/index.html: $(GFORTRAN_TEXI)
167         $(mkinstalldirs) $(@D)
168         rm -f $(@D)/*
169         $(TEXI2HTML) -I $(gcc_docdir)/include -I $(srcdir)/fortran -o $(@D) $<
170
171 .INTERMEDIATE: gfortran.pod
172
173 gfortran.pod: $(GFORTRAN_TEXI)
174         -$(TEXI2POD) < $(srcdir)/fortran/invoke.texi > $@
175
176 # Create or recreate the gfortran private include file directory.
177 install-finclude-dir: installdirs
178         -rm -rf $(DESTDIR)$(libsubdir)/finclude
179         mkdir $(DESTDIR)$(libsubdir)/finclude
180         -chmod a+rx $(DESTDIR)$(libsubdir)/finclude
181 #\f
182 # Install hooks:
183 # f951 is installed elsewhere as part of $(COMPILERS).
184
185 # Install the driver program as $(target)-gfortran
186 # and also as either gfortran (if native) or $(tooldir)/bin/gfortran.
187 fortran.install-common: install-finclude-dir installdirs
188         -if [ -f f951$(exeext) ] ; then \
189           rm -f $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
190           $(INSTALL_PROGRAM) gfortran$(exeext) $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
191           chmod a+x $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
192           if [ -f gfortran-cross$(exeext) ] ; then \
193             if [ -d $(DESTDIR)$(gcc_tooldir)/bin/. ] ; then \
194               rm -f $(DESTDIR)$(gcc_tooldir)/bin/gfortran$(exeext); \
195               $(INSTALL_PROGRAM) gfortran-cross$(exeext) $(DESTDIR)$(gcc_tooldir)/bin/gfortran$(exeext); \
196             else true; fi; \
197           else \
198             rm -f $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \
199             $(LN) $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext) $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \
200           fi ; \
201         fi
202
203 fortran.install-info: $(DESTDIR)$(infodir)/gfortran.info
204
205 fortran.install-man: $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext)
206
207 $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext): doc/gfortran.1 \
208                 installdirs
209         -rm -f $@
210         -$(INSTALL_DATA) $< $@
211         -chmod a-x $@
212
213 fortran.uninstall:
214         if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
215           echo " install-info --delete --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gfortran.info"; \
216           install-info --delete --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gfortran.info || : ; \
217         else : ; fi; \
218         rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
219         rm -rf $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext); \
220         rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \
221         rm -rf $(DESTDIR)$(infodir)/gfortran.info*
222
223 #\f
224 # Clean hooks:
225 # A lot of the ancillary files are deleted by the main makefile.
226 # We just have to delete files specific to us.
227
228 fortran.mostlyclean:
229         -rm -f f951$(exeext)
230         -rm -f fortran/*.o
231
232 fortran.clean:
233 fortran.distclean:
234         -rm -f fortran/config.status fortran/Makefile
235
236 fortran.extraclean:
237 fortran.maintainer-clean:
238         -rm -f doc/gfortran.info* fortran/gfortran.*aux
239         -rm -f $(docobjdir)/gfortran.1
240
241 #\f
242 # Stage hooks:
243 # The toplevel makefile has already created stage?/fortran at this point.
244
245 fortran.stage1: stage1-start
246         -mv fortran/*$(objext) stage1/fortran
247 fortran.stage2: stage2-start
248         -mv fortran/*$(objext) stage2/fortran
249 fortran.stage3: stage3-start
250         -mv fortran/*$(objext) stage3/fortran
251 fortran.stage4: stage4-start
252         -mv fortran/*$(objext) stage4/fortran
253 fortran.stageprofile: stageprofile-start
254         -mv fortran/*$(objext) stageprofile/fortran
255 fortran.stagefeedback: stageprofile-start
256         -mv fortran/*$(objext) stagefeedback/fortran
257
258 #\f
259 # .o: .h dependencies.
260
261 # Everything depends on gfortran.h, but only a few files depend on
262 # the other headers.  So at some point we'll have to split out
263 # which objects depend on what.  FIXME
264 # TODO: Add dependencies on the backend/tree header files
265
266 $(F95_PARSER_OBJS): fortran/gfortran.h fortran/intrinsic.h fortran/match.h \
267                 fortran/parse.h \
268                 $(CONFIG_H) $(SYSTEM_H) $(TM_H) $(TM_P_H) coretypes.h \
269                 $(RTL_H) $(TREE_H) $(TREE_DUMP_H) $(GGC_H) $(EXPR_H) \
270                 $(FLAGS_H) output.h $(DIAGNOSTIC_H) errors.h $(FUNCTION_H) 
271 fortran/openmp.o: pointer-set.h $(TARGET_H) toplev.h
272
273 GFORTRAN_TRANS_DEPS = fortran/gfortran.h fortran/intrinsic.h fortran/trans-array.h \
274     fortran/trans-const.h fortran/trans-const.h fortran/trans.h \
275     fortran/trans-stmt.h fortran/trans-types.h \
276     $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(TM_H) coretypes.h $(GGC_H)
277
278 fortran/f95-lang.o: $(GFORTRAN_TRANS_DEPS) fortran/mathbuiltins.def \
279   gt-fortran-f95-lang.h gtype-fortran.h $(CGRAPH_H) $(TARGET_H) \
280   $(BUILTINS_DEF) fortran/types.def
281 fortran/scanner.o: toplev.h
282 fortran/convert.o: $(GFORTRAN_TRANS_DEPS)
283 fortran/trans.o: $(GFORTRAN_TRANS_DEPS)
284 fortran/trans-decl.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-decl.h \
285   $(CGRAPH_H) $(TARGET_H) $(FUNCTION_H) $(FLAGS_H) $(RTL_H) $(TREE_GIMPLE_H) \
286   $(TREE_DUMP_H)
287 fortran/trans-types.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-types.h \
288   $(REAL_H) toplev.h $(TARGET_H)
289 fortran/trans-const.o: $(GFORTRAN_TRANS_DEPS)
290 fortran/trans-expr.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h
291 fortran/trans-stmt.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h
292 fortran/trans-openmp.o: $(GFORTRAN_TRANS_DEPS)
293 fortran/trans-io.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-io.h \
294   fortran/ioparm.def
295 fortran/trans-array.o: $(GFORTRAN_TRANS_DEPS)
296 fortran/trans-intrinsic.o: $(GFORTRAN_TRANS_DEPS) fortran/mathbuiltins.def \
297   gt-fortran-trans-intrinsic.h
298 fortran/dependency.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h
299 fortran/trans-common.o: $(GFORTRAN_TRANS_DEPS) $(TARGET_H) $(RTL_H)
300 fortran/resolve.o: fortran/dependency.h
301 fortran/options.o: $(TARGET_H)