3 # Copyright (c) 2012-2019. 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"
23 echo "Warning: smpiff pretends to be a regular compiler (SMPI_PRETEND_CC is set). Produced binaries will not be usable in SimGrid."
29 eval $(list_get TMPFILES)
34 filter_and_compile_f77() {
35 list_add TMPFILES "${TMPFILE}"
36 #replace "program main_name by subroutine user_main (and the end clause as well)"
37 if [ $TRACE_CALL_LOCATION -gt 0 ]; then
38 echo "#include \"@includedir@/smpi/smpi_extended_traces_fortran.h\"" > ${TMPFILE}
39 echo "#line 1 \"${ARG}\"" >> ${TMPFILE}
41 sed 's/^[[:space:]]\{6\}[[:space:]]*\([eE][nN][dD] \)\{0,1\}[pP][rR][oO][gG][rR][aA][mM][^a-zA-Z0-9]*\([a-zA-Z0-9_]*\)/ \1subroutine user_main /g' "${ARG}" >> "${TMPFILE}"
43 list_add CMDLINE "${SRCFILE}"
45 filter_and_compile_f90() {
46 list_add TMPFILES "${TMPFILE}"
47 #replace "program main_name by subroutine user_main (and the end clause as well)"
48 if [ $TRACE_CALL_LOCATION -gt 0 ]; then
49 echo "#include \"@includedir@/smpi/smpi_extended_traces_fortran.h\"" > ${TMPFILE}
50 echo "#line 1 \"${ARG}\"" >> ${TMPFILE}
52 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}"
54 list_add CMDLINE "${SRCFILE}"
59 # By default, we execute the commands instead of only showing them to cmake
62 list_set CMDLINE "${REAL_FORTRAN_COMPILER}"
63 list_add_not_empty CMDLINE "${FFLAGS}"
64 while [ $# -gt 0 ]; do
74 FILENAME=`basename ${ARG}`
75 TMPFILE=$(mymktemp "${ARG}" ".f")
76 ORIGFILE="${FILENAME%.f}"
77 filter_and_compile_f77
80 FILENAME=`basename ${ARG}`
81 TMPFILE=$(mymktemp "${ARG}" ".F")
82 ORIGFILE="${FILENAME%.F}"
83 filter_and_compile_f77
86 FILENAME=`basename ${ARG}`
87 TMPFILE=$(mymktemp "${ARG}" ".f90")
88 ORIGFILE="${FILENAME%.f90}"
89 filter_and_compile_f90
92 FILENAME=`basename ${ARG}`
93 TMPFILE=$(mymktemp "${ARG}" ".F90")
94 ORIGFILE="${FILENAME%.F90}"
95 filter_and_compile_f90
97 '-version' | '--version')
98 printf '%b\n' "$SIMGRID_VERSION"
101 "-git-version" | "--git-version")
102 printf '%b\n' "$SIMGRID_GITHASH"
105 '-compiler-version' | '--compiler-version')
106 ${REAL_FORTRAN_COMPILER} --version
108 '-trace-call-location')
109 TRACE_CALL_LOCATION=1
110 # This should be list_add FFLAGS but it's not possible
111 # anymore: FFLAGS was already moved into CMDLINE above.
112 list_add_not_empty CMDLINE "-ffixed-line-length-none" "-cpp"
115 list_add CMDLINE "-o$1"
119 '-show'|'-compile-info'|'-link-info')
120 # Dry run displaying commands instead of executing them. Useful to cmake
124 list_add CMDLINE "${ARG}"
129 if [ $NEEDS_OUTPUT -ne 0 ]; then
130 list_add CMDLINE "-o${ORIGFILE}.o"
133 list_add_not_empty CMDLINE ${INCLUDEARGS}
134 list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
135 list_add_not_empty CMDLINE "${LINKARGS}"
137 eval $(list_get CMDLINE)