Skip to content

Commit f38dd83

Browse files
iotamudeltaItsPitt
andauthored
Support --with-fc (#106)
Details: * Adding --with-fc as a configure flag * FC and FCFLAGS can be adjusted at configure time Co-authored-by: ItsPitt <[email protected]>
1 parent 646ed90 commit f38dd83

File tree

8 files changed

+457
-18
lines changed

8 files changed

+457
-18
lines changed

build/ac-macros/fla_check_with_fc.m4

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
AC_DEFUN([FLA_CHECK_WITH_FC],
2+
[
3+
dnl Tell the user we're checking whether to enable the option.
4+
AC_MSG_CHECKING([whether user requested a specific Fortran compiler])
5+
6+
dnl Determine whether the user gave the --enable-<option> or
7+
dnl --disable-<option>. If so, then run the first snippet of code;
8+
dnl otherwise, run the second code block.
9+
AC_ARG_WITH([fc],
10+
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.]),
11+
[
12+
dnl If any form of the option is given, handle each case.
13+
if test "$withval" = "no" ; then
14+
15+
dnl User provided --with-<option>=no or --without-<option>.
16+
fla_with_specific_fc=without
17+
fla_requested_fc=''
18+
19+
elif test "$withval" = "yes" ; then
20+
21+
dnl User provided --with-<option>=yes or --with-<option>.
22+
fla_with_specific_fc=no
23+
fla_requested_fc=''
24+
else
25+
26+
dnl User provided argument value: --with-<option>=value.
27+
fla_with_specific_fc=yes
28+
fla_requested_fc=$withval
29+
fi
30+
],
31+
[
32+
dnl User did not specify whether to enable or disable the option.
33+
dnl Default behavior is to disable the option.
34+
fla_with_specific_fc=no
35+
fla_requested_fc=''
36+
]
37+
)
38+
39+
dnl Now act according to whether a specific value was given.
40+
if test "$fla_with_specific_fc" = "yes" ; then
41+
42+
dnl Output the result.
43+
AC_MSG_RESULT([yes ($fla_requested_fc)])
44+
45+
elif test "$fla_with_specific_fc" = "without" ; then
46+
47+
dnl Output the result.
48+
AC_MSG_RESULT([no])
49+
50+
dnl The user requested --with-fc=no or --without-fc. Scold him.
51+
AC_MSG_ERROR([[Detected --without-fc. Cannot continue with Fortran compiler disabled!]])
52+
53+
else
54+
dnl Output the result.
55+
AC_MSG_RESULT([no])
56+
fi
57+
58+
dnl Check for FC environment variable, which would override everything else.
59+
if test "$FC" != "" ; then
60+
AC_MSG_NOTICE([[FC environment variable is set to $FC, which will override --with-fc option and default search list for Fortran compiler.]])
61+
fi
62+
63+
])

build/ac-macros/fla_require_fc.m4

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
AC_DEFUN([FLA_REQUIRE_FC],
2+
[
3+
AC_REQUIRE([FLA_OBSERVE_HOST_CPU_TYPE])
4+
5+
dnl Save the value of FFLAGS. This will come in useful later in determining
6+
dnl whether the user provided his own definition of FFLAGS.
7+
fla_userdef_fflags=$FFLAGS
8+
9+
dnl Find a Fortran compiler.
10+
dnl If the FC environment variable is not already set, search for the
11+
dnl compiler defined by fla_requested_fc (which may be empty) and then
12+
dnl continue searching for the compilers in $fla_f_compiler_list, if
13+
dnl necessary.
14+
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"
15+
AC_PROG_FC([$fla_requested_fc $fla_f_compiler_list])
16+
17+
if test "$FC" = "" ; then
18+
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])
19+
fi
20+
21+
dnl Ascertain the compiler "vendor".
22+
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 ; })
23+
dnl AC_MSG_NOTICE([[FC_VENDOR environment variable is set to ${FC_VENDOR}.]])
24+
25+
dnl Substitute the user-defined FFLAGS into the autoconf output files.
26+
AC_SUBST(fla_userdef_fflags)
27+
dnl AC_SUBST(FC_VENDOR)
28+
])

build/config.mk.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ ARFLAGS := cr
155155
#AR_ARG_LIST_FILE := ar_arg_list
156156
AR_OBJ_LIST_FILE := ar_obj_list
157157

158+
# --- Determine the Fortran compiler and related flags ---
159+
FC := @FC@
160+
FC_VENDOR := @FC_VENDOR@
161+
162+
# If the user provided his own FFLAGS, allow them to override our own.
163+
ifneq (@fla_userdef_fflags@,)
164+
FFLAGS := @FFLAGS@ $(FFLAGS)
165+
endif
158166

159167
# --- Determine the python interpreter ---
160168

build/post-configure.sh.in

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ echo "Enable maximum argument list hack............... : @fla_enable_max_arg_lis
3030
echo ""
3131
echo "C compiler...................................... : @CC@"
3232
echo "C compiler vendor............................... : @CC_VENDOR@"
33+
echo "Fortran compiler................................ : @FC@"
34+
echo "Fortran compiler vendor......................... : @FC_VENDOR@"
3335
echo "Library archiver................................ : @AR@"
3436
echo "Library archive indexer......................... : @RANLIB@"
3537
echo "Python interpreter.............................. : @PYTHON@"
@@ -113,6 +115,9 @@ echo "Enable LTO...................................... : @fla_enable_lto@"
113115
echo ""
114116
echo "User-specified CFLAGS (prepended)............... : @fla_userdef_cflags@"
115117

118+
echo ""
119+
echo "User-specified FFLAGS (prepended)............... : @fla_userdef_fflags@"
120+
116121
echo ""
117122
echo "Enable internal error checking.................. : @fla_enable_internal_error_checking@"
118123
if [ "@fla_enable_internal_error_checking@" = "yes" ] ; then
@@ -154,17 +159,6 @@ if [ "@fla_enable_portable_timer@" = "yes" ] ; then
154159
echo " Portable timer function...................... : @fla_portable_timer_function@"
155160
fi
156161

157-
echo ""
158-
echo "Autodetect Fortran linker flags................. : @fla_enable_autodetect_f77_ldflags@"
159-
if [ "@fla_enable_autodetect_f77_ldflags@" = "yes" ] ; then
160-
echo " Fortran linker flags......................... : @FLIBS@"
161-
fi
162-
echo "Autodetect Fortran name-mangling................ : @fla_enable_autodetect_f77_name_mangling@"
163-
if [ "@fla_enable_autodetect_f77_name_mangling@" = "yes" ] ; then
164-
echo " Unmangled name............................... : @fla_f77_foobar_unmangled@"
165-
echo " Mangled name................................. : @fla_f77_foobar_mangled@"
166-
fi
167-
168162
echo ""
169163
echo "Installation directories"
170164
echo " prefix....................................... : "'@prefix@'
@@ -175,13 +169,6 @@ echo " header files will be installed in............ : "'@includedir@'
175169
echo ""
176170
echo "Configuration complete!"
177171
echo ""
178-
if [ "@fla_enable_autodetect_f77_ldflags@" = "yes" ] ; then
179-
echo "NOTE: Autodetection of Fortran linker flags was enabled. The configure"
180-
echo "script thinks that the flags listed above are necessary to successfully"
181-
echo "link a program to Fortran object code. If your program uses any Fortran"
182-
echo "libraries, you will probably need to link with these flags."
183-
echo ""
184-
fi
185172
echo "You may now run 'make' to build all libflame libraries and then 'make install'"
186173
echo "to install the libraries."
187174
echo ""

0 commit comments

Comments
 (0)