Skip to content

Commit

Permalink
Autoconf configuration of Python
Browse files Browse the repository at this point in the history
The introduction of makedep means that Python is now a dependency of the
MOM6 compilation.  On some systems, we cannot assume that `python` is
the name of the interpreter, and strictly should not even assume that it
exists.

This is notably an issue on the recent MacOS M1 systems, which use
`python3` as its interpreter, and do not provide one named `python`.

This patch adds macros to the MOM6 and FMS autoconf builds to detect if
Python is on the system, and makes a few attempts to determine the name
of the interpreter (python, python3, python2).  Perhaps more can be done
here, but this is probably sufficient in nearly all cases.
  • Loading branch information
marshallward committed Feb 16, 2023
1 parent 2fe2631 commit e8386eb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ac/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

FC = @FC@
LD = @FC@
PYTHON = @PYTHON@
MAKEDEP = @MAKEDEP@

DEFS = @DEFS@
Expand All @@ -32,7 +33,7 @@ rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(su
.PHONY: depend
depend: Makefile.dep
Makefile.dep: $(MAKEDEP) $(call rwildcard,$(SRC_DIRS),*.h *.c *.inc *.F90)
$(MAKEDEP) -o Makefile.dep -e $(SRC_DIRS)
$(PYTHON) $(MAKEDEP) -o Makefile.dep -e $(SRC_DIRS)


# Delete any files associated with configuration (including the Makefile).
Expand Down
7 changes: 7 additions & 0 deletions ac/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ AC_COMPILE_IFELSE(
)


# Verify that Python is available
AC_PATH_PROGS([PYTHON], [python python3 python2], [
AC_MSG_ERROR([Could not find python.])
])
AC_ARG_VAR([PYTHON], [Python interpreter command])


# Verify that makedep is available
AC_PATH_PROG([MAKEDEP], [makedep], [${srcdir}/ac/makedep])
AC_SUBST([MAKEDEP])
Expand Down
3 changes: 2 additions & 1 deletion ac/deps/Makefile.fms.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CC = @CC@
FC = @FC@
LD = @FC@
AR = @AR@
PYTHON = @PYTHON@
MAKEDEP = @MAKEDEP@

DEFS = @DEFS@
Expand All @@ -22,4 +23,4 @@ ARFLAGS = @ARFLAGS@
.PHONY: depend
depend: Makefile.dep
Makefile.dep:
$(MAKEDEP) -o Makefile.dep -e -x libFMS.a @srcdir@
$(PYTHON) $(MAKEDEP) -o Makefile.dep -e -x libFMS.a @srcdir@
9 changes: 8 additions & 1 deletion ac/deps/configure.fms.ac
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,14 @@ AX_FC_ALLOW_ARG_MISMATCH
FCFLAGS="$FCFLAGS $ALLOW_ARG_MISMATCH_FCFLAGS"


# Verify makedep
# Verify that Python is available
AC_PATH_PROGS([PYTHON], [python python3 python2], [
AC_MSG_ERROR([Could not find python.])
])
AC_ARG_VAR([PYTHON], [Python interpreter command])


# Verify that makedep is available
AC_PATH_PROGS([MAKEDEP], [makedep], [], ["${PATH}:${srcdir}/../../.."])
AS_IF([test -n "${MAKEDEP}"], [
AC_SUBST([MAKEDEP])
Expand Down

0 comments on commit e8386eb

Please sign in to comment.