Foad S. Farimani
Foad S. Farimani

Reputation: 14026

How to Set gfortran Compiler Flags in a Complex Build System Involving Makefile.am, configure.ac, and setup.py?

Following this question, I am working on building a project that involves compiling FORTRAN 77 code using gfortran, but I am encountering a compilation error due to missing compiler flags. The specific error message is:

error: Command "/usr/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops -I/mnt/c/dev/JModelica/jmodelica_env/lib/python2.7/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-2.7/build/src.linux-x86_64-2.7/assimulo/thirdparty/hairer -I/mnt/c/dev/JModelica/jmodelica_env/lib/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c -c assimulo/thirdparty/hairer/radau_decsol.f -o build/temp.linux-x86_64-2.7/assimulo/thirdparty/hairer/radau_decsol.o" failed with exit status 1
make[2]: *** [Makefile:1088: build-python-packages] Error 1
make[2]: Leaving directory '/mnt/c/dev/JModelica/build'
make[1]: *** [Makefile:514: all-recursive] Error 1
make[1]: Leaving directory '/mnt/c/dev/JModelica/build'
make: *** [Makefile:451: all] Error 2

I want to include the -ffixed-line-length-120 flag in the gfortran command to resolve this issue, but I am unsure where the gfortran flags are configured in the build system. The build system involves multiple configuration files such as Makefile.am, configure.ac, and setup.py.

Here’s a snippet from the generated build/Makefile related to building Python packages:

build-python-packages:
    mkdir -p $(assimulo_build_dir); \
    cd $(abs_top_srcdir)/external; \
    find Assimulo -type f |grep -v /.svn | grep -v .pyc | grep -v ~ |tar c -T - -f - | tar x -C $(assimulo_build_dir); \
    cd $(assimulo_build_dir)/Assimulo; \
    case $(build) in \
        *-cygwin*) \
        python setup.py install --with_openmp=True --superlu-home=$(abs_builddir)/superlu_build/ --sundials-home=$(SUNDIALS_HOME) --sundials-with-superlu=True --blas-home=$(abs_builddir)/blas_install/ --lapack-home=$(abs_builddir)/lapack_install/ --force-32bit="true" --extra-c-flags="-mincoming-stack-boundary=2" --prefix=$(assimulo_install_dir) ;; \
        *-mingw*) \
        python setup.py install --with_openmp=True --superlu-home=$(abs_builddir)/superlu_build/ --sundials-home=$(SUNDIALS_HOME) --sundials-with-superlu=True --blas-home=$(abs_builddir)/blas_install/ --lapack-home=$(abs_builddir)/lapack_install/ --force-32bit="true" $(NUMPY_NO_MSVCR_ARG) --extra-c-flags="-mincoming-stack-boundary=2" --prefix=$(assimulo_install_dir) ;; \
        *) \
        python setup.py install --with_openmp=True --superlu-home=$(abs_builddir)/superlu_build/ --sundials-home=$(SUNDIALS_HOME) --sundials-with-superlu=True --blas-home=$(abs_builddir)/blas_install/ --lapack-home=$(abs_builddir)/lapack_install/ --prefix=$(assimulo_install_dir) ;; \
    esac
    cd $(abs_top_srcdir)/Python/src; \
    python setup_pymodelica.py install --prefix=$(pymodelica_install_dir); \
    rm -rf build
    mkdir -p $(pyfmi_build_dir); \
    cd $(abs_top_srcdir)/external; \
    find PyFMI -type f |grep -v /.svn | grep -v .pyc | grep -v ~ |tar c -T - -f - | tar x -C $(pyfmi_build_dir); \
    cd $(pyfmi_build_dir)/PyFMI; \
    case $(build) in \
        *-cygwin*) \
        python setup.py install --fmil-home=$(abs_builddir)/FMIL_install/ --force-32bit="true" --extra-c-flags="-mincoming-stack-boundary=2" --prefix=$(pyfmi_install_dir) ;; \
        *-mingw*) \
        python setup.py install --fmil-home=$(abs_builddir)/FMIL_install/ --force-32bit="true" $(NUMPY_NO_MSVCR_ARG) --extra-c-flags="-mincoming-stack-boundary=2" --prefix=$(pyfmi_install_dir) ;; \
        *) \
        python setup.py install --fmil-home=$(abs_builddir)/FMIL_install/ --prefix=$(pyfmi_install_dir) ;; \
    esac
    rm -rf build
    cd $(abs_top_srcdir)/Python/src; \
    python setup_pyjmi.py install --prefix=$(pyjmi_install_dir); \
    rm -rf build

I suspect the Fortran compiler settings might be specified in one of these files, but I'm unsure how to trace or modify them appropriately.

Could anyone guide me on where to look or how to modify the build configuration to include additional gfortran flags? I am not sure where to look or what to look for.

Upvotes: 1

Views: 170

Answers (0)

Related Questions