1# -*- makefile -*- 2# Top level makefile fragment for GNU gfortran, the GNU Fortran 95 compiler. 3# Copyright (C) 2002-2013 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.install-html, 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. 42GFORTRAN_INSTALL_NAME := $(shell echo gfortran|sed '$(program_transform_name)') 43GFORTRAN_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gfortran|sed '$(program_transform_name)') 44 45#^L 46 47# Use strict warnings for this front end. 48fortran-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 54F95_PARSER_OBJS = fortran/arith.o fortran/array.o fortran/bbt.o \ 55 fortran/check.o fortran/class.o fortran/constructor.o fortran/cpp.o \ 56 fortran/data.o fortran/decl.o fortran/dump-parse-tree.o fortran/error.o \ 57 fortran/expr.o fortran/interface.o fortran/intrinsic.o fortran/io.o \ 58 fortran/iresolve.o fortran/match.o fortran/matchexp.o fortran/misc.o \ 59 fortran/module.o fortran/openmp.o fortran/options.o fortran/parse.o \ 60 fortran/primary.o fortran/resolve.o fortran/scanner.o fortran/simplify.o \ 61 fortran/st.o fortran/symbol.o fortran/target-memory.o 62 63F95_OBJS = $(F95_PARSER_OBJS) $(FORTRAN_TARGET_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 fortran/frontend-passes.o 69 70fortran_OBJS = $(F95_OBJS) gfortranspec.o 71 72# 73# Define the names for selecting gfortran in LANGUAGES. 74fortran: f951$(exeext) 75 76# Tell GNU make to ignore files by these names if they exist. 77.PHONY: fortran 78 79gfortranspec.o: $(srcdir)/fortran/gfortranspec.c $(SYSTEM_H) $(TM_H) $(GCC_H) \ 80 $(CONFIG_H) coretypes.h intl.h $(OPTS_H) 81 (SHLIB='$(SHLIB)'; \ 82 $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(DRIVER_DEFINES) \ 83 $(INCLUDES) $(srcdir)/fortran/gfortranspec.c) 84 85# Create the compiler driver gfortran. 86GFORTRAN_D_OBJS = $(GCC_OBJS) gfortranspec.o 87gfortran$(exeext): $(GFORTRAN_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \ 88 $(LIBDEPS) 89 +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ 90 $(GFORTRAN_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \ 91 $(EXTRA_GCC_LIBS) $(LIBS) 92 93# Create a version of the gfortran driver which calls the cross-compiler. 94gfortran-cross$(exeext): gfortran$(exeext) 95 -rm -f gfortran-cross$(exeext) 96 cp gfortran$(exeext) gfortran-cross$(exeext) 97 98# The compiler itself is called f951. 99f951$(exeext): $(F95_OBJS) \ 100 $(BACKEND) $(LIBDEPS) attribs.o 101 +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ 102 $(F95_OBJS) $(BACKEND) $(LIBS) attribs.o $(BACKENDLIBS) 103 104gt-fortran-trans.h : s-gtype; @true 105# 106# Build hooks: 107 108fortran.all.cross: gfortran-cross$(exeext) 109 110fortran.start.encap: gfortran$(exeext) 111fortran.rest.encap: 112 113fortran.srcinfo: doc/gfortran.info 114 -cp -p $^ $(srcdir)/fortran 115 116fortran.tags: force 117 cd $(srcdir)/fortran; etags -o TAGS.sub *.c *.h; \ 118 etags --include TAGS.sub --include ../TAGS.sub 119 120fortran.info: doc/gfortran.info doc/gfc-internals.info 121fortran.dvi: doc/gfortran.dvi doc/gfc-internals.dvi 122 123F95_HTMLFILES = $(build_htmldir)/gfortran 124 125fortran.html: $(F95_HTMLFILES)/index.html 126 127fortran.install-html: $(F95_HTMLFILES) 128 @$(NORMAL_INSTALL) 129 test -z "$(htmldir)" || $(mkinstalldirs) "$(DESTDIR)$(htmldir)" 130 @list='$(F95_HTMLFILES)'; for p in $$list; do \ 131 if test -f "$$p" || test -d "$$p"; then d=""; else d="$(srcdir)/"; fi; \ 132 f=$(html__strip_dir) \ 133 if test -d "$$d$$p"; then \ 134 echo " $(mkinstalldirs) '$(DESTDIR)$(htmldir)/$$f'"; \ 135 $(mkinstalldirs) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \ 136 echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \ 137 $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f"; \ 138 else \ 139 echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \ 140 $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \ 141 fi; \ 142 done 143 144F95_PDFFILES = doc/gfortran.pdf 145 146fortran.pdf: $(F95_PDFFILES) doc/gfc-internals.pdf 147 148fortran.install-pdf: $(F95_PDFFILES) 149 @$(NORMAL_INSTALL) 150 test -z "$(pdfdir)/gcc" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)/gcc" 151 @list='$(F95_PDFFILES)'; for p in $$list; do \ 152 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ 153 f=$(pdf__strip_dir) \ 154 echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/gcc/$$f'"; \ 155 $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/gcc/$$f"; \ 156 done 157 158F95_MANFILES = doc/gfortran.1 159 160fortran.man: $(F95_MANFILES) 161 162fortran.srcman: $(F95_MANFILES) 163 -cp -p $^ $(srcdir)/doc 164 165fortran.srcextra: 166 167check-f95 : check-gfortran 168check-fortran : check-gfortran 169check-f95-subtargets : check-gfortran-subtargets 170check-fortran-subtargets : check-gfortran-subtargets 171lang_checks += check-gfortran 172lang_checks_parallelized += check-gfortran 173# For description see comment above check_gcc_parallelize in gcc/Makefile.in. 174check_gfortran_parallelize = dg.exp=gfortran.dg/\[adAD\]* \ 175 dg.exp=gfortran.dg/\[bcBC\]* \ 176 dg.exp=gfortran.dg/\[nopNOP\]* \ 177 dg.exp=gfortran.dg/\[isuvISUV\]* \ 178 dg.exp=gfortran.dg/\[efhkqrxzEFHKQRXZ\]* \ 179 dg.exp=gfortran.dg/\[0-9gjlmtwyGJLMTWY\]* 180 181# GFORTRAN documentation. 182GFORTRAN_TEXI = \ 183 $(srcdir)/fortran/gfortran.texi \ 184 $(srcdir)/fortran/intrinsic.texi \ 185 $(srcdir)/fortran/invoke.texi \ 186 $(srcdir)/doc/include/fdl.texi \ 187 $(srcdir)/doc/include/gpl_v3.texi \ 188 $(srcdir)/doc/include/funding.texi \ 189 $(srcdir)/doc/include/gcc-common.texi \ 190 gcc-vers.texi 191 192doc/gfortran.info: $(GFORTRAN_TEXI) 193 if [ x$(BUILD_INFO) = xinfo ]; then \ 194 rm -f doc/gfortran.info-*; \ 195 $(MAKEINFO) -I $(srcdir)/doc/include -I $(srcdir)/fortran \ 196 -o $@ $<; \ 197 else true; fi 198 199doc/gfortran.dvi: $(GFORTRAN_TEXI) 200 $(TEXI2DVI) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $< 201 202doc/gfortran.pdf: $(GFORTRAN_TEXI) 203 $(TEXI2PDF) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $< 204 205$(build_htmldir)/gfortran/index.html: $(GFORTRAN_TEXI) 206 $(mkinstalldirs) $(@D) 207 rm -f $(@D)/* 208 $(TEXI2HTML) -I $(gcc_docdir)/include -I $(srcdir)/fortran -o $(@D) $< 209 210.INTERMEDIATE: gfortran.pod 211 212gfortran.pod: $(GFORTRAN_TEXI) 213 -$(TEXI2POD) -DBUGURL="$(BUGURL_TEXI)" \ 214 < $(srcdir)/fortran/invoke.texi > $@ 215 216# GFORTRAN internals documentation. 217GFC_INTERNALS_TEXI = \ 218 $(srcdir)/fortran/gfc-internals.texi \ 219 $(srcdir)/doc/include/fdl.texi \ 220 $(srcdir)/doc/include/gcc-common.texi \ 221 gcc-vers.texi 222 223doc/gfc-internals.info: $(GFC_INTERNALS_TEXI) 224 if [ x$(BUILD_INFO) = xinfo ]; then \ 225 rm -f doc/gfc-internals.info-*; \ 226 $(MAKEINFO) -I $(srcdir)/doc/include -I $(srcdir)/fortran \ 227 -o $@ $<; \ 228 else true; fi 229 230doc/gfc-internals.dvi: $(GFC_INTERNALS_TEXI) 231 $(TEXI2DVI) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $< 232 233doc/gfc-internals.pdf: $(GFC_INTERNALS_TEXI) 234 $(TEXI2PDF) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $< 235 236# Create or recreate the gfortran private include file directory. 237install-finclude-dir: installdirs 238 $(mkinstalldirs) -m 0755 $(DESTDIR)$(libsubdir)/finclude 239# 240# Install hooks: 241# f951 is installed elsewhere as part of $(COMPILERS). 242 243# Install the driver program as $(target)-gfortran 244# and also as either gfortran (if native) or $(tooldir)/bin/gfortran. 245fortran.install-common: install-finclude-dir installdirs 246 -if [ -f f951$(exeext) ] ; then \ 247 rm -f $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \ 248 $(INSTALL_PROGRAM) gfortran$(exeext) $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \ 249 chmod a+x $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \ 250 if [ -f gfortran-cross$(exeext) ] ; then \ 251 if [ -d $(DESTDIR)$(gcc_tooldir)/bin/. ] ; then \ 252 rm -f $(DESTDIR)$(gcc_tooldir)/bin/gfortran$(exeext); \ 253 $(INSTALL_PROGRAM) gfortran-cross$(exeext) $(DESTDIR)$(gcc_tooldir)/bin/gfortran$(exeext); \ 254 else true; fi; \ 255 else \ 256 rm -f $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \ 257 $(LN) $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext) $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \ 258 fi ; \ 259 fi 260 261fortran.install-plugin: 262 263fortran.install-info: $(DESTDIR)$(infodir)/gfortran.info 264 265fortran.install-man: $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext) 266 267$(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext): doc/gfortran.1 \ 268 installdirs 269 -rm -f $@ 270 -$(INSTALL_DATA) $< $@ 271 -chmod a-x $@ 272 273fortran.uninstall: 274 if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \ 275 echo " install-info --delete --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gfortran.info"; \ 276 install-info --delete --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gfortran.info || : ; \ 277 else : ; fi; \ 278 rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \ 279 rm -rf $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext); \ 280 rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \ 281 rm -rf $(DESTDIR)$(infodir)/gfortran.info* 282 283# 284# Clean hooks: 285# A lot of the ancillary files are deleted by the main makefile. 286# We just have to delete files specific to us. 287 288fortran.mostlyclean: 289 -rm -f f951$(exeext) 290 -rm -f fortran/*.o 291 292fortran.clean: 293fortran.distclean: 294 -rm -f fortran/config.status fortran/Makefile 295 296fortran.extraclean: 297fortran.maintainer-clean: 298 -rm -f doc/gfortran.info* fortran/gfortran.*aux 299 -rm -f $(docobjdir)/gfortran.1 300 301# 302# Stage hooks: 303# The toplevel makefile has already created stage?/fortran at this point. 304 305fortran.stage1: stage1-start 306 -mv fortran/*$(objext) stage1/fortran 307fortran.stage2: stage2-start 308 -mv fortran/*$(objext) stage2/fortran 309fortran.stage3: stage3-start 310 -mv fortran/*$(objext) stage3/fortran 311fortran.stage4: stage4-start 312 -mv fortran/*$(objext) stage4/fortran 313fortran.stageprofile: stageprofile-start 314 -mv fortran/*$(objext) stageprofile/fortran 315fortran.stagefeedback: stageprofile-start 316 -mv fortran/*$(objext) stagefeedback/fortran 317 318# 319# .o: .h dependencies. 320 321# Everything depends on gfortran.h, but only a few files depend on 322# the other headers. So at some point we'll have to split out 323# which objects depend on what. FIXME 324# TODO: Add dependencies on the backend/tree header files 325 326$(F95_PARSER_OBJS): fortran/gfortran.h fortran/libgfortran.h \ 327 fortran/intrinsic.h fortran/match.h fortran/constructor.h \ 328 fortran/parse.h fortran/arith.h fortran/target-memory.h \ 329 $(CONFIG_H) $(SYSTEM_H) $(TM_H) $(TM_P_H) coretypes.h \ 330 dumpfile.h $(TREE_H) dumpfile.h $(GGC_H) $(VEC_H) \ 331 $(FLAGS_H) $(DIAGNOSTIC_H) errors.h $(FUNCTION_H) \ 332 fortran/iso-c-binding.def fortran/iso-fortran-env.def 333fortran/openmp.o: pointer-set.h $(TARGET_H) toplev.h 334 335GFORTRAN_TRANS_DEPS = fortran/gfortran.h fortran/libgfortran.h \ 336 fortran/intrinsic.h fortran/trans-array.h \ 337 fortran/trans-const.h fortran/trans-const.h fortran/trans.h \ 338 fortran/trans-stmt.h fortran/trans-types.h \ 339 $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(TM_H) coretypes.h $(GGC_H) \ 340 fortran/iso-c-binding.def fortran/iso-fortran-env.def 341 342CFLAGS-fortran/cpp.o += $(TARGET_SYSTEM_ROOT_DEFINE) 343fortran/f95-lang.o: $(GFORTRAN_TRANS_DEPS) fortran/mathbuiltins.def \ 344 gt-fortran-f95-lang.h gtype-fortran.h $(CGRAPH_H) $(TARGET_H) fortran/cpp.h \ 345 $(BUILTINS_DEF) fortran/types.def \ 346 $(TM_H) debug.h langhooks.h $(FLAGS_H) $(EXPR_H) $(LANGHOOKS_DEF_H) \ 347 libfuncs.h expr.h $(DIAGNOSTIC_H) 348fortran/scanner.o: toplev.h fortran/cpp.h 349fortran/convert.o: $(GFORTRAN_TRANS_DEPS) convert.h 350fortran/frontend-passes.o: $(GFORTRAN_TRANS_DEPS) 351fortran/trans.o: $(GFORTRAN_TRANS_DEPS) tree-iterator.h 352fortran/trans-decl.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-decl.h \ 353 $(CGRAPH_H) $(TARGET_H) $(FUNCTION_H) $(FLAGS_H) $(RTL_H) $(GIMPLE_H) \ 354 $(TREE_DUMP_H) debug.h pointer-set.h 355fortran/trans-types.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-types.h \ 356 $(REAL_H) toplev.h $(TARGET_H) $(FLAGS_H) dwarf2out.h 357fortran/trans-const.o: $(GFORTRAN_TRANS_DEPS) realmpfr.h 358fortran/trans-expr.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h 359fortran/trans-stmt.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h 360fortran/trans-openmp.o: $(GFORTRAN_TRANS_DEPS) 361fortran/trans-io.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-io.h \ 362 fortran/ioparm.def 363fortran/trans-array.o: $(GFORTRAN_TRANS_DEPS) $(GIMPLE_H) 364fortran/trans-intrinsic.o: $(GFORTRAN_TRANS_DEPS) fortran/mathbuiltins.def \ 365 gt-fortran-trans-intrinsic.h 366fortran/dependency.o: $(GFORTRAN_TRANS_DEPS) fortran/dependency.h 367fortran/trans-common.o: $(GFORTRAN_TRANS_DEPS) $(TARGET_H) $(RTL_H) 368fortran/resolve.o: fortran/dependency.h fortran/data.h fortran/target-memory.h 369fortran/data.o: fortran/data.h 370fortran/options.o: $(PARAMS_H) $(TARGET_H) fortran/cpp.h 371fortran/cpp.o: fortran/cpp.c incpath.h incpath.o cppbuiltin.h 372