OSDN Git Service

1702b9f124f198185d9290a227f7baf3a7568c22
[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, 2007 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 3, 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 COPYING3.  If not see
21 #<http://www.gnu.org/licenses/>.
22
23 # This file provides the language dependent support in the main Makefile.
24 # Each language makefile fragment must provide the following targets:
25 #
26 # foo.all.cross, foo.start.encap, foo.rest.encap,
27 # foo.install-common, foo.install-man, foo.install-info, foo.install-pdf,
28 # foo.info, foo.dvi, foo.pdf, foo.html, foo.uninstall,
29 # foo.mostlyclean, foo.clean, foo.distclean,
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: gfortran)
37 # - the compiler proper (eg: f951)
38 # - define the names for selecting the language in LANGUAGES.
39 # $(srcdir) must be set to the gcc/ source directory (*not* gcc/fortran/).
40
41 # Actual name to use when installing a native compiler.
42 GFORTRAN_INSTALL_NAME := $(shell echo gfortran|sed '$(program_transform_name)')
43 GFORTRAN_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gfortran|sed '$(program_transform_name)')
44
45 #^L
46
47 # Use strict warnings for this front end.
48 fortran-warn = $(STRICT_WARN)
49
50 # These are the groups of object files we have.  The F95_PARSER_OBJS are
51 # all the front end files, the F95_OBJS are the files for the translation
52 # from the parse tree to GENERIC
53
54 F95_PARSER_OBJS = fortran/arith.o fortran/array.o fortran/bbt.o \
55     fortran/check.o fortran/data.o fortran/decl.o fortran/dump-parse-tree.o \
56     fortran/error.o fortran/expr.o fortran/interface.o \
57     fortran/intrinsic.o fortran/io.o fortran/iresolve.o \
58     fortran/match.o fortran/matchexp.o fortran/misc.o fortran/module.o \
59     fortran/openmp.o fortran/options.o fortran/parse.o fortran/primary.o \
60     fortran/resolve.o fortran/scanner.o fortran/simplify.o fortran/st.o \
61     fortran/symbol.o fortran/target-memory.o
62
63 F95_OBJS = $(F95_PARSER_OBJS) \
64     fortran/convert.o fortran/dependency.o fortran/f95-lang.o \
65     fortran/trans.o fortran/trans-array.o fortran/trans-common.o \
66     fortran/trans-const.o fortran/trans-decl.o fortran/trans-expr.o \
67     fortran/trans-intrinsic.o fortran/trans-io.o fortran/trans-openmp.o \
68     fortran/trans-stmt.o fortran/trans-types.o
69
70 #\f
71 # Define the names for selecting gfortran in LANGUAGES.
72 fortran: f951$(exeext)
73
74 # Tell GNU make to ignore files by these names if they exist.
75 .PHONY: fortran
76
77 gfortranspec.o: $(srcdir)/fortran/gfortranspec.c $(SYSTEM_H) $(TM_H) $(GCC_H) $(CONFIG_H)
78         (SHLIB_LINK='$(SHLIB_LINK)'; \
79         $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(DRIVER_DEFINES) \
80                 $(INCLUDES) $(srcdir)/fortran/gfortranspec.c)
81
82 # Create the compiler driver gfortran.
83 GFORTRAN_D_OBJS = $(GCC_OBJS) gfortranspec.o version.o prefix.o intl.o
84 gfortran$(exeext): $(GFORTRAN_D_OBJS) $(EXTRA_GCC_OBJS) $(LIBDEPS)
85         $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
86           $(GFORTRAN_D_OBJS) $(EXTRA_GCC_OBJS) $(LIBS)
87
88 # Create a version of the gfortran driver which calls the cross-compiler.
89 gfortran-cross$(exeext): gfortran$(exeext)
90         -rm -f gfortran-cross$(exeext)
91         cp gfortran$(exeext) gfortran-cross$(exeext)
92
93 # The compiler itself is called f951.
94 f951$(exeext): $(F95_OBJS) \
95                 $(BACKEND) $(LIBDEPS) attribs.o
96         $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
97                 $(F95_OBJS) $(BACKEND) $(LIBS) attribs.o $(GMPLIBS)
98
99 gt-fortran-trans.h    : s-gtype; @true
100 #\f
101 # Build hooks:
102
103 fortran.all.cross: gfortran-cross$(exeext)
104
105 fortran.start.encap: gfortran$(exeext)
106 fortran.rest.encap:
107
108 fortran.srcinfo: doc/gfortran.info
109         -cp -p $^ $(srcdir)/fortran
110
111 fortran.tags: force
112         cd $(srcdir)/fortran; etags -o TAGS.sub *.c *.h; \
113         etags --include TAGS.sub --include ../TAGS.sub
114
115 fortran.info: doc/gfortran.info doc/gfc-internals.info
116 fortran.dvi: doc/gfortran.dvi doc/gfc-internals.dvi
117 fortran.html: $(build_htmldir)/gfortran/index.html
118
119 F95_PDFFILES = doc/gfortran.pdf
120
121 fortran.pdf: $(F95_PDFFILES) doc/gfc-internals.pdf
122
123 fortran.install-pdf: $(F95_PDFFILES)
124         @$(NORMAL_INSTALL)
125         test -z "$(pdfdir)/gcc" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)/gcc"
126         @list='$(F95_PDFFILES)'; for p in $$list; do \
127           if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
128           f=$(pdf__strip_dir) \
129           echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/gcc/$$f'"; \
130           $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/gcc/$$f"; \
131         done
132
133 F95_MANFILES = doc/gfortran.1
134
135 fortran.man: $(F95_MANFILES)
136
137 fortran.srcman: $(F95_MANFILES)
138         -cp -p $^ $(srcdir)/doc
139
140 fortran.srcextra:
141
142 check-f95 : check-gfortran
143 check-fortran : check-gfortran
144 lang_checks += check-gfortran
145
146 # GFORTRAN documentation.
147 GFORTRAN_TEXI = \
148   $(srcdir)/fortran/gfortran.texi \
149   $(srcdir)/fortran/intrinsic.texi \
150   $(srcdir)/fortran/invoke.texi \
151   $(srcdir)/doc/include/fdl.texi \
152   $(srcdir)/doc/include/gpl.texi \
153   $(srcdir)/doc/include/funding.texi \
154   $(srcdir)/doc/include/gcc-common.texi \
155   gcc-vers.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 $@ $<; \
162         else true; fi
163
164 doc/gfortran.dvi: $(GFORTRAN_TEXI)
165         $(TEXI2DVI) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $<
166
167 doc/gfortran.pdf: $(GFORTRAN_TEXI)
168         $(TEXI2PDF) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $<
169
170 $(build_htmldir)/gfortran/index.html: $(GFORTRAN_TEXI)
171         $(mkinstalldirs) $(@D)
172         rm -f $(@D)/*
173         $(TEXI2HTML) -I $(gcc_docdir)/include -I $(srcdir)/fortran -o $(@D) $<
174
175 .INTERMEDIATE: gfortran.pod
176
177 gfortran.pod: $(GFORTRAN_TEXI)
178         -$(TEXI2POD) -DBUGURL="$(BUGURL_TEXI)" \
179           < $(srcdir)/fortran/invoke.texi > $@
180
181 # GFORTRAN internals documentation.
182 GFC_INTERNALS_TEXI = \
183   $(srcdir)/fortran/gfc-internals.texi \
184   $(srcdir)/doc/include/fdl.texi \
185   $(srcdir)/doc/include/gcc-common.texi \
186   gcc-vers.texi
187
188 doc/gfc-internals.info: $(GFC_INTERNALS_TEXI)
189         if [ x$(BUILD_INFO) = xinfo ]; then \
190           rm -f doc/gfc-internals.info-*; \
191           $(MAKEINFO) -I $(srcdir)/doc/include -I $(srcdir)/fortran \
192             -o $@ $<; \
193         else true; fi
194
195 doc/gfc-internals.dvi: $(GFC_INTERNALS_TEXI)
196         $(TEXI2DVI) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $<
197
198 doc/gfc-internals.pdf: $(GFC_INTERNALS_TEXI)
199         $(TEXI2PDF) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $<
200
201 # Create or recreate the gfortran private include file directory.
202 install-finclude-dir: installdirs
203         -rm -rf $(DESTDIR)$(libsubdir)/finclude
204         mkdir $(DESTDIR)$(libsubdir)/finclude
205         -chmod a+rx $(DESTDIR)$(libsubdir)/finclude
206 #\f
207 # Install hooks:
208 # f951 is installed elsewhere as part of $(COMPILERS).
209
210 # Install the driver program as $(target)-gfortran
211 # and also as either gfortran (if native) or $(tooldir)/bin/gfortran.
212 fortran.install-common: install-finclude-dir installdirs
213         -if [ -f f951$(exeext) ] ; then \
214           rm -f $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
215           $(INSTALL_PROGRAM) gfortran$(exeext) $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
216           chmod a+x $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
217           if [ -f gfortran-cross$(exeext) ] ; then \
218             if [ -d $(DESTDIR)$(gcc_tooldir)/bin/. ] ; then \
219               rm -f $(DESTDIR)$(gcc_tooldir)/bin/gfortran$(exeext); \
220               $(INSTALL_PROGRAM) gfortran-cross$(exeext) $(DESTDIR)$(gcc_tooldir)/bin/gfortran$(exeext); \
221             else true; fi; \
222           else \
223             rm -f $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \
224             $(LN) $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext) $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \
225           fi ; \
226         fi
227
228 fortran.install-info: $(DESTDIR)$(infodir)/gfortran.info
229
230 fortran.install-man: $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext)
231
232 $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext): doc/gfortran.1 \
233                 installdirs
234         -rm -f $@
235         -$(INSTALL_DATA) $< $@
236         -chmod a-x $@
237
238 fortran.uninstall:
239         if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \
240           echo " install-info --delete --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gfortran.info"; \
241           install-info --delete --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gfortran.info || : ; \
242         else : ; fi; \
243         rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
244         rm -rf $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext); \
245         rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \
246         rm -rf $(DESTDIR)$(infodir)/gfortran.info*
247
248 #\f
249 # Clean hooks:
250 # A lot of the ancillary files are deleted by the main makefile.
251 # We just have to delete files specific to us.
252
253 fortran.mostlyclean:
254         -rm -f f951$(exeext)
255         -rm -f fortran/*.o
256
257 fortran.clean:
258 fortran.distclean:
259         -rm -f fortran/config.status fortran/Makefile
260
261 fortran.extraclean:
262 fortran.maintainer-clean:
263         -rm -f doc/gfortran.info* fortran/gfortran.*aux
264         -rm -f $(docobjdir)/gfortran.1
265
266 #\f
267 # Stage hooks:
268 # The toplevel makefile has already created stage?/fortran at this point.
269
270 fortran.stage1: stage1-start
271         -mv fortran/*$(objext) stage1/fortran
272 fortran.stage2: stage2-start
273         -mv fortran/*$(objext) stage2/fortran
274 fortran.stage3: stage3-start
275         -mv fortran/*$(objext) stage3/fortran
276 fortran.stage4: stage4-start
277         -mv fortran/*$(objext) stage4/fortran
278 fortran.stageprofile: stageprofile-start
279         -mv fortran/*$(objext) stageprofile/fortran
280 fortran.stagefeedback: stageprofile-start
281         -mv fortran/*$(objext) stagefeedback/fortran
282
283 #\f
284 # .o: .h dependencies.
285
286 # Everything depends on gfortran.h, but only a few files depend on
287 # the other headers.  So at some point we'll have to split out
288 # which objects depend on what.  FIXME
289 # TODO: Add dependencies on the backend/tree header files
290
291 $(F95_PARSER_OBJS): fortran/gfortran.h fortran/libgfortran.h \
292                 fortran/intrinsic.h fortran/match.h \
293                 fortran/parse.h fortran/arith.h fortran/target-memory.h \
294                 $(CONFIG_H) $(SYSTEM_H) $(TM_H) $(TM_P_H) coretypes.h \
295                 $(RTL_H) $(TREE_H) $(TREE_DUMP_H) $(GGC_H) $(EXPR_H) \
296                 $(FLAGS_H) output.h $(DIAGNOSTIC_H) errors.h $(FUNCTION_H) 
297 fortran/openmp.o: pointer-set.h $(TARGET_H) toplev.h
298
299 GFORTRAN_TRANS_DEPS = fortran/gfortran.h fortran/libgfortran.h \
300     fortran/intrinsic.h fortran/trans-array.h \
301     fortran/trans-const.h fortran/trans-const.h fortran/trans.h \
302     fortran/trans-stmt.h fortran/trans-types.h \
303     $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(TM_H) coretypes.h $(GGC_H)
304
305 fortran/f95-lang.o: $(GFORTRAN_TRANS_DEPS) fortran/mathbuiltins.def \
306   gt-fortran-f95-lang.h gtype-fortran.h $(CGRAPH_H) $(TARGET_H) \
307   $(BUILTINS_DEF) fortran/types.def
308 fortran/scanner.o: toplev.h
309 fortran/convert.o: $(GFORTRAN_TRANS_DEPS)
310 fortran/trans.o: $(GFORTRAN_TRANS_DEPS)
311 fortran/trans-decl.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-decl.h \
312   $(CGRAPH_H) $(TARGET_H) $(FUNCTION_H) $(FLAGS_H) $(RTL_H) $(TREE_GIMPLE_H) \
313   $(TREE_DUMP_H)
314 fortran/trans-types.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-types.h \
315   $(REAL_H) toplev.h $(TARGET_H) $(FLAGS_H) dwarf2out.h
316 fortran/trans-const.o: $(GFORTRAN_TRANS_DEPS)
317 fortran/trans-expr.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h
318 fortran/trans-stmt.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h
319 fortran/trans-openmp.o: $(GFORTRAN_TRANS_DEPS)
320 fortran/trans-io.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-io.h \
321   fortran/ioparm.def
322 fortran/trans-array.o: $(GFORTRAN_TRANS_DEPS)
323 fortran/trans-intrinsic.o: $(GFORTRAN_TRANS_DEPS) fortran/mathbuiltins.def \
324   gt-fortran-trans-intrinsic.h
325 fortran/dependency.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h
326 fortran/trans-common.o: $(GFORTRAN_TRANS_DEPS) $(TARGET_H) $(RTL_H)
327 fortran/resolve.o: fortran/dependency.h fortran/data.h fortran/target-memory.h
328 fortran/data.o: fortran/data.h
329 fortran/options.o: $(PARAMS_H) $(TARGET_H)