Skip to content

Commit

Permalink
Support --with-fc (#106)
Browse files Browse the repository at this point in the history
Details:
* Adding --with-fc as a configure flag
* FC and FCFLAGS can be adjusted at configure time

Co-authored-by: ItsPitt <[email protected]>
  • Loading branch information
iotamudelta and ItsPitt authored May 20, 2024
1 parent 646ed90 commit f38dd83
Show file tree
Hide file tree
Showing 8 changed files with 457 additions and 18 deletions.
63 changes: 63 additions & 0 deletions build/ac-macros/fla_check_with_fc.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
AC_DEFUN([FLA_CHECK_WITH_FC],
[
dnl Tell the user we're checking whether to enable the option.
AC_MSG_CHECKING([whether user requested a specific Fortran compiler])
dnl Determine whether the user gave the --enable-<option> or
dnl --disable-<option>. If so, then run the first snippet of code;
dnl otherwise, run the second code block.
AC_ARG_WITH([fc],
AS_HELP_STRING([--with-fc=fc],[Search for and use a Fortran compiler named <fc>. If <fc> is not found, then use the first compiler found from the default search list for the detected build architecture.]),
[
dnl If any form of the option is given, handle each case.
if test "$withval" = "no" ; then
dnl User provided --with-<option>=no or --without-<option>.
fla_with_specific_fc=without
fla_requested_fc=''
elif test "$withval" = "yes" ; then
dnl User provided --with-<option>=yes or --with-<option>.
fla_with_specific_fc=no
fla_requested_fc=''
else
dnl User provided argument value: --with-<option>=value.
fla_with_specific_fc=yes
fla_requested_fc=$withval
fi
],
[
dnl User did not specify whether to enable or disable the option.
dnl Default behavior is to disable the option.
fla_with_specific_fc=no
fla_requested_fc=''
]
)
dnl Now act according to whether a specific value was given.
if test "$fla_with_specific_fc" = "yes" ; then
dnl Output the result.
AC_MSG_RESULT([yes ($fla_requested_fc)])
elif test "$fla_with_specific_fc" = "without" ; then
dnl Output the result.
AC_MSG_RESULT([no])
dnl The user requested --with-fc=no or --without-fc. Scold him.
AC_MSG_ERROR([[Detected --without-fc. Cannot continue with Fortran compiler disabled!]])
else
dnl Output the result.
AC_MSG_RESULT([no])
fi
dnl Check for FC environment variable, which would override everything else.
if test "$FC" != "" ; then
AC_MSG_NOTICE([[FC environment variable is set to $FC, which will override --with-fc option and default search list for Fortran compiler.]])
fi
])
28 changes: 28 additions & 0 deletions build/ac-macros/fla_require_fc.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
AC_DEFUN([FLA_REQUIRE_FC],
[
AC_REQUIRE([FLA_OBSERVE_HOST_CPU_TYPE])
dnl Save the value of FFLAGS. This will come in useful later in determining
dnl whether the user provided his own definition of FFLAGS.
fla_userdef_fflags=$FFLAGS
dnl Find a Fortran compiler.
dnl If the FC environment variable is not already set, search for the
dnl compiler defined by fla_requested_fc (which may be empty) and then
dnl continue searching for the compilers in $fla_f_compiler_list, if
dnl necessary.
fla_f_compiler_list="gfortran f77 g77 xlf frt pgf77 cf77 fort77 fl32 af77 xlf90 f90 pgf90 pghpf epcf90 g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn nagfor"
AC_PROG_FC([$fla_requested_fc $fla_f_compiler_list])
if test "$FC" = "" ; then
AC_MSG_ERROR([Could not locate any of the following Fortran compilers: $FC $fla_requested_fc $fla_f_compiler_list. Cannot continue without a Fortran compiler.],[1])
fi
dnl Ascertain the compiler "vendor".
dnl FC_VENDOR=$(echo "$FC" | egrep -o 'gfortran|f77|g77|xlf|frt|pgf77|cf77|fort77|fl32|af77|xlf90|f90|pgf90|pghpf|epcf90|g95|xlf95|f95|fort|ifort|ifc|efc|pgfortran|pgf95|lf95|ftn|nagfor' | { read first rest ; echo $first ; })
dnl AC_MSG_NOTICE([[FC_VENDOR environment variable is set to ${FC_VENDOR}.]])
dnl Substitute the user-defined FFLAGS into the autoconf output files.
AC_SUBST(fla_userdef_fflags)
dnl AC_SUBST(FC_VENDOR)
])
8 changes: 8 additions & 0 deletions build/config.mk.in
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ ARFLAGS := cr
#AR_ARG_LIST_FILE := ar_arg_list
AR_OBJ_LIST_FILE := ar_obj_list

# --- Determine the Fortran compiler and related flags ---
FC := @FC@
FC_VENDOR := @FC_VENDOR@

# If the user provided his own FFLAGS, allow them to override our own.
ifneq (@fla_userdef_fflags@,)
FFLAGS := @FFLAGS@ $(FFLAGS)
endif

# --- Determine the python interpreter ---

Expand Down
23 changes: 5 additions & 18 deletions build/post-configure.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ echo "Enable maximum argument list hack............... : @fla_enable_max_arg_lis
echo ""
echo "C compiler...................................... : @CC@"
echo "C compiler vendor............................... : @CC_VENDOR@"
echo "Fortran compiler................................ : @FC@"
echo "Fortran compiler vendor......................... : @FC_VENDOR@"
echo "Library archiver................................ : @AR@"
echo "Library archive indexer......................... : @RANLIB@"
echo "Python interpreter.............................. : @PYTHON@"
Expand Down Expand Up @@ -113,6 +115,9 @@ echo "Enable LTO...................................... : @fla_enable_lto@"
echo ""
echo "User-specified CFLAGS (prepended)............... : @fla_userdef_cflags@"

echo ""
echo "User-specified FFLAGS (prepended)............... : @fla_userdef_fflags@"

echo ""
echo "Enable internal error checking.................. : @fla_enable_internal_error_checking@"
if [ "@fla_enable_internal_error_checking@" = "yes" ] ; then
Expand Down Expand Up @@ -154,17 +159,6 @@ if [ "@fla_enable_portable_timer@" = "yes" ] ; then
echo " Portable timer function...................... : @fla_portable_timer_function@"
fi

echo ""
echo "Autodetect Fortran linker flags................. : @fla_enable_autodetect_f77_ldflags@"
if [ "@fla_enable_autodetect_f77_ldflags@" = "yes" ] ; then
echo " Fortran linker flags......................... : @FLIBS@"
fi
echo "Autodetect Fortran name-mangling................ : @fla_enable_autodetect_f77_name_mangling@"
if [ "@fla_enable_autodetect_f77_name_mangling@" = "yes" ] ; then
echo " Unmangled name............................... : @fla_f77_foobar_unmangled@"
echo " Mangled name................................. : @fla_f77_foobar_mangled@"
fi

echo ""
echo "Installation directories"
echo " prefix....................................... : "'@prefix@'
Expand All @@ -175,13 +169,6 @@ echo " header files will be installed in............ : "'@includedir@'
echo ""
echo "Configuration complete!"
echo ""
if [ "@fla_enable_autodetect_f77_ldflags@" = "yes" ] ; then
echo "NOTE: Autodetection of Fortran linker flags was enabled. The configure"
echo "script thinks that the flags listed above are necessary to successfully"
echo "link a program to Fortran object code. If your program uses any Fortran"
echo "libraries, you will probably need to link with these flags."
echo ""
fi
echo "You may now run 'make' to build all libflame libraries and then 'make install'"
echo "to install the libraries."
echo ""
Expand Down
Loading

0 comments on commit f38dd83

Please sign in to comment.