1181254a7Smrg# -*- makefile -*- 2181254a7Smrg# Top level makefile fragment for GNU gfortran, the GNU Fortran 95 compiler. 3*b1e83836Smrg# Copyright (C) 2002-2022 Free Software Foundation, Inc. 4181254a7Smrg# Contributed by Paul Brook <paul@nowt.org 5181254a7Smrg# and Steven Bosscher <s.bosscher@student.tudelft.nl> 6181254a7Smrg 7181254a7Smrg#This file is part of GCC. 8181254a7Smrg 9181254a7Smrg#GCC is free software; you can redistribute it and/or modify 10181254a7Smrg#it under the terms of the GNU General Public License as published by 11181254a7Smrg#the Free Software Foundation; either version 3, or (at your option) 12181254a7Smrg#any later version. 13181254a7Smrg 14181254a7Smrg#GCC is distributed in the hope that it will be useful, 15181254a7Smrg#but WITHOUT ANY WARRANTY; without even the implied warranty of 16181254a7Smrg#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17181254a7Smrg#GNU General Public License for more details. 18181254a7Smrg 19181254a7Smrg#You should have received a copy of the GNU General Public License 20181254a7Smrg#along with GCC; see the file COPYING3. If not see 21181254a7Smrg#<http://www.gnu.org/licenses/>. 22181254a7Smrg 23181254a7Smrg# This file provides the language dependent support in the main Makefile. 24181254a7Smrg# Each language makefile fragment must provide the following targets: 25181254a7Smrg# 26181254a7Smrg# foo.all.cross, foo.start.encap, foo.rest.encap, 27181254a7Smrg# foo.install-common, foo.install-man, foo.install-info, foo.install-pdf, 28181254a7Smrg# foo.install-html, foo.info, foo.dvi, foo.pdf, foo.html, foo.uninstall, 29181254a7Smrg# foo.mostlyclean, foo.clean, foo.distclean, 30181254a7Smrg# foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4 31181254a7Smrg# 32181254a7Smrg# where `foo' is the name of the language. 33181254a7Smrg# 34181254a7Smrg# It should also provide rules for: 35181254a7Smrg# 36181254a7Smrg# - making any compiler driver (eg: gfortran) 37181254a7Smrg# - the compiler proper (eg: f951) 38181254a7Smrg# - define the names for selecting the language in LANGUAGES. 39181254a7Smrg# $(srcdir) must be set to the gcc/ source directory (*not* gcc/fortran/). 40181254a7Smrg 41181254a7Smrg# Actual name to use when installing a native compiler. 42181254a7SmrgGFORTRAN_INSTALL_NAME := $(shell echo gfortran|sed '$(program_transform_name)') 43181254a7SmrgGFORTRAN_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gfortran|sed '$(program_transform_name)') 44181254a7Smrg 45181254a7Smrg#^L 46181254a7Smrg 47181254a7Smrg# Use strict warnings for this front end. 48181254a7Smrgfortran-warn = $(STRICT_WARN) 49181254a7Smrg 50181254a7Smrg# These are the groups of object files we have. The F95_PARSER_OBJS are 51181254a7Smrg# all the front end files, the F95_OBJS are the files for the translation 52181254a7Smrg# from the parse tree to GENERIC 53181254a7Smrg 54181254a7SmrgF95_PARSER_OBJS = fortran/arith.o fortran/array.o fortran/bbt.o \ 55181254a7Smrg fortran/check.o fortran/class.o fortran/constructor.o fortran/cpp.o \ 56181254a7Smrg fortran/data.o fortran/decl.o fortran/dump-parse-tree.o fortran/error.o \ 57181254a7Smrg fortran/expr.o fortran/interface.o fortran/intrinsic.o fortran/io.o \ 58181254a7Smrg fortran/iresolve.o fortran/match.o fortran/matchexp.o fortran/misc.o \ 59181254a7Smrg fortran/module.o fortran/openmp.o fortran/options.o fortran/parse.o \ 60181254a7Smrg fortran/primary.o fortran/resolve.o fortran/scanner.o fortran/simplify.o \ 61181254a7Smrg fortran/st.o fortran/symbol.o fortran/target-memory.o 62181254a7Smrg 63181254a7SmrgF95_OBJS = $(F95_PARSER_OBJS) $(FORTRAN_TARGET_OBJS) \ 64181254a7Smrg fortran/convert.o fortran/dependency.o fortran/f95-lang.o \ 65181254a7Smrg fortran/trans.o fortran/trans-array.o fortran/trans-common.o \ 66181254a7Smrg fortran/trans-const.o fortran/trans-decl.o fortran/trans-expr.o \ 67181254a7Smrg fortran/trans-intrinsic.o fortran/trans-io.o fortran/trans-openmp.o \ 68181254a7Smrg fortran/trans-stmt.o fortran/trans-types.o fortran/frontend-passes.o 69181254a7Smrg 70181254a7Smrgfortran_OBJS = $(F95_OBJS) fortran/gfortranspec.o 71181254a7Smrg 72181254a7Smrg# 73181254a7Smrg# Define the names for selecting gfortran in LANGUAGES. 74181254a7Smrgfortran: f951$(exeext) 75*b1e83836Smrgfortran.serial = f951$(exeext) 76181254a7Smrg 77181254a7Smrg# Tell GNU make to ignore files by these names if they exist. 78181254a7Smrg.PHONY: fortran 79181254a7Smrg 80181254a7SmrgCFLAGS-fortran/gfortranspec.o += $(DRIVER_DEFINES) 81181254a7Smrg 82181254a7Smrg# Create the compiler driver gfortran. 83181254a7SmrgGFORTRAN_D_OBJS = $(GCC_OBJS) fortran/gfortranspec.o 84181254a7Smrggfortran$(exeext): $(GFORTRAN_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \ 85181254a7Smrg $(LIBDEPS) 86181254a7Smrg +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ 87181254a7Smrg $(GFORTRAN_D_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \ 88181254a7Smrg $(EXTRA_GCC_LIBS) $(LIBS) 89181254a7Smrg 90181254a7Smrg# Create a version of the gfortran driver which calls the cross-compiler. 91181254a7Smrggfortran-cross$(exeext): gfortran$(exeext) 92181254a7Smrg -rm -f gfortran-cross$(exeext) 93181254a7Smrg cp gfortran$(exeext) gfortran-cross$(exeext) 94181254a7Smrg 95181254a7Smrg# The compiler itself is called f951. 96*b1e83836Smrgf951$(exeext): $(F95_OBJS) $(BACKEND) $(LIBDEPS) attribs.o $(fortran.prev) 97*b1e83836Smrg @$(call LINK_PROGRESS,$(INDEX.fortran),start) 98181254a7Smrg +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ 99181254a7Smrg $(F95_OBJS) $(BACKEND) $(ZLIB) $(LIBS) attribs.o \ 100181254a7Smrg $(BACKENDLIBS) 101*b1e83836Smrg @$(call LINK_PROGRESS,$(INDEX.fortran),end) 102181254a7Smrg 103181254a7Smrggt-fortran-trans.h : s-gtype; @true 104181254a7Smrg# 105181254a7Smrg# Build hooks: 106181254a7Smrg 107181254a7Smrgfortran.all.cross: gfortran-cross$(exeext) 108181254a7Smrg 109181254a7Smrgfortran.start.encap: gfortran$(exeext) 110181254a7Smrgfortran.rest.encap: 111181254a7Smrg 112181254a7Smrgfortran.srcinfo: doc/gfortran.info 113181254a7Smrg -cp -p $^ $(srcdir)/fortran 114181254a7Smrg 115181254a7Smrgfortran.tags: force 116*b1e83836Smrg cd $(srcdir)/fortran; $(ETAGS) -o TAGS.sub *.c *.h; \ 117*b1e83836Smrg $(ETAGS) --include TAGS.sub --include ../TAGS.sub 118181254a7Smrg 119181254a7Smrgfortran.info: doc/gfortran.info doc/gfc-internals.info 120*b1e83836Smrg 121*b1e83836SmrgF95_DVIFILES = doc/gfortran.dvi 122*b1e83836Smrg 123*b1e83836Smrgfortran.dvi: $(F95_DVIFILES) doc/gfc-internals.dvi 124*b1e83836Smrg 125*b1e83836Smrgfortran.install-dvi: $(F95_DVIFILES) 126*b1e83836Smrg @$(NORMAL_INSTALL) 127*b1e83836Smrg test -z "$(dvidir)/gcc" || $(mkinstalldirs) "$(DESTDIR)$(dvidir)/gcc" 128*b1e83836Smrg @list='$(F95_DVIFILES)'; for p in $$list; do \ 129*b1e83836Smrg if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ 130*b1e83836Smrg f=$(dvi__strip_dir) \ 131*b1e83836Smrg echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(dvidir)/gcc/$$f'"; \ 132*b1e83836Smrg $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(dvidir)/gcc/$$f"; \ 133*b1e83836Smrg done 134181254a7Smrg 135181254a7SmrgF95_HTMLFILES = $(build_htmldir)/gfortran 136181254a7Smrg 137181254a7Smrgfortran.html: $(F95_HTMLFILES)/index.html 138181254a7Smrg 139181254a7Smrgfortran.install-html: $(F95_HTMLFILES) 140181254a7Smrg @$(NORMAL_INSTALL) 141181254a7Smrg test -z "$(htmldir)" || $(mkinstalldirs) "$(DESTDIR)$(htmldir)" 142181254a7Smrg @list='$(F95_HTMLFILES)'; for p in $$list; do \ 143181254a7Smrg if test -f "$$p" || test -d "$$p"; then d=""; else d="$(srcdir)/"; fi; \ 144181254a7Smrg f=$(html__strip_dir) \ 145181254a7Smrg if test -d "$$d$$p"; then \ 146181254a7Smrg echo " $(mkinstalldirs) '$(DESTDIR)$(htmldir)/$$f'"; \ 147181254a7Smrg $(mkinstalldirs) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \ 148181254a7Smrg echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \ 149181254a7Smrg $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f"; \ 150181254a7Smrg else \ 151181254a7Smrg echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(htmldir)/$$f'"; \ 152181254a7Smrg $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(htmldir)/$$f"; \ 153181254a7Smrg fi; \ 154181254a7Smrg done 155181254a7Smrg 156181254a7SmrgF95_PDFFILES = doc/gfortran.pdf 157181254a7Smrg 158181254a7Smrgfortran.pdf: $(F95_PDFFILES) doc/gfc-internals.pdf 159181254a7Smrg 160181254a7Smrgfortran.install-pdf: $(F95_PDFFILES) 161181254a7Smrg @$(NORMAL_INSTALL) 162181254a7Smrg test -z "$(pdfdir)/gcc" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)/gcc" 163181254a7Smrg @list='$(F95_PDFFILES)'; for p in $$list; do \ 164181254a7Smrg if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ 165181254a7Smrg f=$(pdf__strip_dir) \ 166181254a7Smrg echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/gcc/$$f'"; \ 167181254a7Smrg $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/gcc/$$f"; \ 168181254a7Smrg done 169181254a7Smrg 170181254a7SmrgF95_MANFILES = doc/gfortran.1 171181254a7Smrg 172181254a7Smrgfortran.man: $(F95_MANFILES) 173181254a7Smrg 174181254a7Smrgfortran.srcman: $(F95_MANFILES) 175181254a7Smrg -cp -p $^ $(srcdir)/doc 176181254a7Smrg 177181254a7Smrgfortran.srcextra: 178181254a7Smrg 179181254a7Smrgcheck-f95 : check-gfortran 180181254a7Smrgcheck-fortran : check-gfortran 181181254a7Smrgcheck-f95-subtargets : check-gfortran-subtargets 182181254a7Smrgcheck-fortran-subtargets : check-gfortran-subtargets 183181254a7Smrglang_checks += check-gfortran 184181254a7Smrglang_checks_parallelized += check-gfortran 185181254a7Smrg# For description see the check_$lang_parallelize comment in gcc/Makefile.in. 186181254a7Smrgcheck_gfortran_parallelize = 10000 187181254a7Smrg 188181254a7Smrg# No fortran-specific selftests 189181254a7Smrgselftest-fortran: 190181254a7Smrg 191181254a7Smrg# GFORTRAN documentation. 192181254a7SmrgGFORTRAN_TEXI = \ 193181254a7Smrg $(srcdir)/fortran/gfortran.texi \ 194181254a7Smrg $(srcdir)/fortran/intrinsic.texi \ 195181254a7Smrg $(srcdir)/fortran/invoke.texi \ 196181254a7Smrg $(srcdir)/doc/include/fdl.texi \ 197181254a7Smrg $(srcdir)/doc/include/gpl_v3.texi \ 198181254a7Smrg $(srcdir)/doc/include/funding.texi \ 199181254a7Smrg $(srcdir)/doc/include/gcc-common.texi \ 200181254a7Smrg gcc-vers.texi 201181254a7Smrg 202181254a7Smrgdoc/gfortran.info: $(GFORTRAN_TEXI) 203181254a7Smrg if [ x$(BUILD_INFO) = xinfo ]; then \ 204181254a7Smrg rm -f doc/gfortran.info-*; \ 205181254a7Smrg $(MAKEINFO) -I $(srcdir)/doc/include -I $(srcdir)/fortran \ 206181254a7Smrg -o $@ $<; \ 207181254a7Smrg else true; fi 208181254a7Smrg 209181254a7Smrgdoc/gfortran.dvi: $(GFORTRAN_TEXI) 210181254a7Smrg $(TEXI2DVI) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $< 211181254a7Smrg 212181254a7Smrgdoc/gfortran.pdf: $(GFORTRAN_TEXI) 213181254a7Smrg $(TEXI2PDF) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $< 214181254a7Smrg 215181254a7Smrg$(build_htmldir)/gfortran/index.html: $(GFORTRAN_TEXI) 216181254a7Smrg $(mkinstalldirs) $(@D) 217181254a7Smrg rm -f $(@D)/* 218181254a7Smrg $(TEXI2HTML) -I $(gcc_docdir)/include -I $(srcdir)/fortran -o $(@D) $< 219181254a7Smrg 220181254a7Smrg.INTERMEDIATE: gfortran.pod 221181254a7Smrg 222181254a7Smrggfortran.pod: $(GFORTRAN_TEXI) 223181254a7Smrg -$(TEXI2POD) -DBUGURL="$(BUGURL_TEXI)" \ 224181254a7Smrg < $(srcdir)/fortran/invoke.texi > $@ 225181254a7Smrg 226181254a7Smrg# GFORTRAN internals documentation. 227181254a7SmrgGFC_INTERNALS_TEXI = \ 228181254a7Smrg $(srcdir)/fortran/gfc-internals.texi \ 229181254a7Smrg $(srcdir)/doc/include/fdl.texi \ 230181254a7Smrg $(srcdir)/doc/include/gcc-common.texi \ 231181254a7Smrg gcc-vers.texi 232181254a7Smrg 233181254a7Smrgdoc/gfc-internals.info: $(GFC_INTERNALS_TEXI) 234181254a7Smrg if [ x$(BUILD_INFO) = xinfo ]; then \ 235181254a7Smrg rm -f doc/gfc-internals.info-*; \ 236181254a7Smrg $(MAKEINFO) -I $(srcdir)/doc/include -I $(srcdir)/fortran \ 237181254a7Smrg -o $@ $<; \ 238181254a7Smrg else true; fi 239181254a7Smrg 240181254a7Smrgdoc/gfc-internals.dvi: $(GFC_INTERNALS_TEXI) 241181254a7Smrg $(TEXI2DVI) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $< 242181254a7Smrg 243181254a7Smrgdoc/gfc-internals.pdf: $(GFC_INTERNALS_TEXI) 244181254a7Smrg $(TEXI2PDF) -I $(srcdir)/fortran -I $(abs_docdir)/include -o $@ $< 245181254a7Smrg 246181254a7Smrg# Create or recreate the gfortran private include file directory. 247181254a7Smrginstall-finclude-dir: installdirs 248181254a7Smrg $(mkinstalldirs) -m 0755 $(DESTDIR)$(libsubdir)/finclude 249181254a7Smrg# 250181254a7Smrg# Install hooks: 251181254a7Smrg# f951 is installed elsewhere as part of $(COMPILERS). 252181254a7Smrg 253181254a7Smrg# Install the driver program as $(target)-gfortran, and also as gfortran 254181254a7Smrg# if native. 255181254a7Smrgfortran.install-common: install-finclude-dir installdirs 256181254a7Smrg -if test "$(enable_as_accelerator)" != "yes" ; then \ 257181254a7Smrg if [ -f f951$(exeext) ] ; then \ 258181254a7Smrg rm -f $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \ 259181254a7Smrg $(INSTALL_PROGRAM) gfortran$(exeext) $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \ 260181254a7Smrg chmod a+x $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \ 261181254a7Smrg if [ ! -f gfortran-cross$(exeext) ] ; then \ 262181254a7Smrg rm -f $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \ 263181254a7Smrg $(LN) $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext) $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \ 264181254a7Smrg fi ; \ 265181254a7Smrg fi; \ 266181254a7Smrg fi 267181254a7Smrg 268181254a7Smrgfortran.install-plugin: 269181254a7Smrg 270181254a7Smrgfortran.install-info: $(DESTDIR)$(infodir)/gfortran.info 271181254a7Smrg 272181254a7Smrgfortran.install-man: $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext) 273181254a7Smrg 274181254a7Smrg$(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext): doc/gfortran.1 \ 275181254a7Smrg installdirs 276181254a7Smrg -rm -f $@ 277181254a7Smrg -$(INSTALL_DATA) $< $@ 278181254a7Smrg -chmod a-x $@ 279181254a7Smrg 280181254a7Smrgfortran.uninstall: 281181254a7Smrg if $(SHELL) -c 'install-info --version | sed 1q | fgrep -s -v -i debian' >/dev/null 2>&1; then \ 282181254a7Smrg echo " install-info --delete --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gfortran.info"; \ 283181254a7Smrg install-info --delete --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/gfortran.info || : ; \ 284181254a7Smrg else : ; fi; \ 285181254a7Smrg rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \ 286181254a7Smrg rm -rf $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext); \ 287181254a7Smrg rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \ 288181254a7Smrg rm -rf $(DESTDIR)$(infodir)/gfortran.info* 289181254a7Smrg 290181254a7Smrg# 291181254a7Smrg# Clean hooks: 292181254a7Smrg# A lot of the ancillary files are deleted by the main makefile. 293181254a7Smrg# We just have to delete files specific to us. 294181254a7Smrg 295181254a7Smrgfortran.mostlyclean: 296181254a7Smrg -rm -f gfortran$(exeext) gfortran-cross$(exeext) f951$(exeext) 297181254a7Smrg -rm -f fortran/*.o 298181254a7Smrg 299181254a7Smrgfortran.clean: 300181254a7Smrgfortran.distclean: 301181254a7Smrg -rm -f fortran/config.status fortran/Makefile 302181254a7Smrg 303181254a7Smrgfortran.extraclean: 304181254a7Smrgfortran.maintainer-clean: 305181254a7Smrg -rm -f doc/gfortran.info* fortran/gfortran.*aux 306181254a7Smrg -rm -f $(docobjdir)/gfortran.1 307181254a7Smrg 308181254a7Smrg# 309181254a7Smrg# Stage hooks: 310181254a7Smrg# The toplevel makefile has already created stage?/fortran at this point. 311181254a7Smrg 312181254a7Smrgfortran.stage1: stage1-start 313181254a7Smrg -mv fortran/*$(objext) stage1/fortran 314181254a7Smrgfortran.stage2: stage2-start 315181254a7Smrg -mv fortran/*$(objext) stage2/fortran 316181254a7Smrgfortran.stage3: stage3-start 317181254a7Smrg -mv fortran/*$(objext) stage3/fortran 318181254a7Smrgfortran.stage4: stage4-start 319181254a7Smrg -mv fortran/*$(objext) stage4/fortran 320181254a7Smrgfortran.stageprofile: stageprofile-start 321181254a7Smrg -mv fortran/*$(objext) stageprofile/fortran 322181254a7Smrgfortran.stagefeedback: stageprofile-start 323181254a7Smrg -mv fortran/*$(objext) stagefeedback/fortran 324181254a7Smrg 325181254a7Smrg# 326181254a7Smrg 327181254a7SmrgCFLAGS-fortran/cpp.o += $(TARGET_SYSTEM_ROOT_DEFINE) 328181254a7SmrgCFLAGS-fortran/module.o += $(ZLIBINC) 329