3 # Copyright (c) 2012-2020. The SimGrid Team. All rights reserved.
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the license (GNU LGPL) which comes with this package.
8 SIMGRID_VERSION="@SIMGRID_VERSION_STRING@"
9 SIMGRID_GITHASH="@SIMGRID_GITHASH@"
11 REAL_FORTRAN_COMPILER=@SMPI_Fortran_COMPILER@
13 INCLUDEARGS="@includeflag@"
14 CMAKE_LINKARGS="-L@libdir@"
18 list_set FFLAGS @SMPI_Fortran_FLAGS@
19 list_set LINKARGS "-lsimgrid" @SMPI_Fortran_LIBS@ "-lm"
20 if [ "x${SMPI_PRETEND_CC}" = "x" ]; then
21 list_add LINKARGS "-shared"
22 if [ "x${SMPI_NO_UNDEFINED_CHECK}" = "x" ]; then
23 if [ "x@APPLE@" != "x1" ]; then
24 list_add LINKARGS "-Wl,-z,defs"
26 list_add LINKARGS "-Wl,-undefined,error"
30 echo "Warning: smpif90 pretends to be a regular compiler (SMPI_PRETEND_CC is set). Produced binaries will not be usable in SimGrid."
36 eval $(list_get TMPFILES)
41 filter_and_compile() {
42 list_add TMPFILES "${TMPFILE}"
43 #replace "program main_name by subroutine user_main (and the end clause as well)"
44 if [ "x${SMPI_PRETEND_CC}" = "x" ]; then
45 sed 's/^\([[:space:]]*\)\([eE][nN][dD] \)\{0,1\}[pP][rR][oO][gG][rR][aA][mM][^a-zA-Z0-9]*\([a-zA-Z0-9_]*\)/\1\2subroutine user_main /g' "${ARG}" >> "${TMPFILE}"
50 list_add CMDLINE "${SRCFILE}"
55 list_set CMDLINE "${REAL_FORTRAN_COMPILER}"
56 list_add_not_empty CMDLINE "${FFLAGS}"
57 while [ $# -gt 0 ]; do
67 FILENAME=`basename ${ARG}`
68 TMPFILE=$(mymktemp "${ARG}" ".f90")
69 ORIGFILE="${FILENAME%.f90}"
73 FILENAME=`basename ${ARG}`
74 TMPFILE=$(mymktemp "${ARG}" ".F90")
75 ORIGFILE="${FILENAME%.F90}"
78 '-version' | '--version')
79 printf '%b\n' "$SIMGRID_VERSION"
82 "-git-version" | "--git-version")
83 printf '%b\n' "$SIMGRID_GITHASH"
86 '-compiler-version' | '--compiler-version')
87 ${REAL_FORTRAN_COMPILER} --version
90 list_add CMDLINE "-o$1"
94 '-show'|'-compile-info'|'-link-info')
95 # Dry run displaying commands instead of executing them. Useful to cmake
99 list_add CMDLINE "${ARG}"
104 if [ $NEEDS_OUTPUT -ne 0 ]; then
105 list_add CMDLINE "-o${ORIGFILE}.o"
108 list_add_not_empty CMDLINE ${INCLUDEARGS}
109 list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
110 list_add_not_empty CMDLINE "${LINKARGS}"
112 eval $(list_get CMDLINE)
113 if [ "x$VERBOSE" = x1 -o "x$show" = x1 ] ; then
115 [ "x$show" = x1 ] && exit 0