@@ -23453,7 +23453,7 @@ def run_task(task):
2345323453 print("\n" + "=" * 60)
2345423454 print("Generating top-level management files...")
2345523455 print("=" * 60)
23456- generate_top_level_makefile(out_root, args.flat)
23456+ generate_top_level_makefile(out_root, args.flat, compiler=args.compiler, c_compiler=args.c_compiler )
2345723457 generate_top_level_test_script(out_root, run_d, run_dv, run_b, run_bv, args.flat)
2345823458 generate_meson_build(out_root, args.flat)
2345923459 generate_python_interface_test_script(out_root)
@@ -23475,7 +23475,7 @@ def run_task(task):
2347523475 print(" make vector-reverse # Build vector reverse mode only")
2347623476 print(" ./test_<function>_vector_forward # Run vector forward mode test")
2347723477
23478- def generate_top_level_makefile(out_dir, flat_mode=False):
23478+ def generate_top_level_makefile(out_dir, flat_mode=False, compiler="gfortran", c_compiler="gcc" ):
2347923479 """Generate the top-level Makefile for building all subdirectories or flat makefiles"""
2348023480
2348123481 if flat_mode:
@@ -23486,6 +23486,7 @@ def generate_top_level_makefile(out_dir, flat_mode=False):
2348623486# Compilers and flags
2348723487FC = gfortran
2348823488CC = gcc
23489+
2348923490# Ensure .mod files are written to (and read from) build/
2349023491# Defaults: gfortran -> -J, ifort/ifx -> -module. You can still override MODFLAG on the make command line.
2349123492MODDIR = $(BUILD_DIR)
@@ -23496,8 +23497,19 @@ def generate_top_level_makefile(out_dir, flat_mode=False):
2349623497else
2349723498MODFLAG ?= -J$(MODDIR)
2349823499endif
23500+
23501+ # Compiler-specific flag sets (avoid passing gfortran-only flags to ifort/ifx)
23502+ ifeq ($(findstring ifort,$(FC)),ifort)
23503+ FFLAGS = -O2 -fPIC -warn all -traceback -Iinclude -I$(MODDIR) $(MODFLAG)
23504+ FFLAGS_F77 = -O2 -fPIC -warn all -traceback -Iinclude -I$(MODDIR)
23505+ else ifeq ($(findstring ifx,$(FC)),ifx)
23506+ FFLAGS = -O2 -fPIC -warn all -traceback -Iinclude -I$(MODDIR) $(MODFLAG)
23507+ FFLAGS_F77 = -O2 -fPIC -warn all -traceback -Iinclude -I$(MODDIR)
23508+ else
2349923509FFLAGS = -O2 -fPIC -ffree-line-length-none -Wuninitialized -Wmaybe-uninitialized -Iinclude -I$(MODDIR) $(MODFLAG)
2350023510FFLAGS_F77 = -O2 -fPIC -ffixed-line-length-none -Wuninitialized -Wmaybe-uninitialized -Iinclude -I$(MODDIR)
23511+ endif
23512+
2350123513CFLAGS = -O2 -fPIC
2350223514
2350323515# Directory structure
@@ -24072,6 +24084,10 @@ def generate_top_level_makefile(out_dir, flat_mode=False):
2407224084.PHONY: all forward reverse vector-forward vector-reverse clean rebuild test status help $(SUBDIRS)
2407324085'''
2407424086
24087+ # Apply requested compilers for the generated Makefile(s)
24088+ makefile_content = makefile_content.replace("FC = gfortran", f"FC = {compiler}")
24089+ makefile_content = makefile_content.replace("CC = gcc", f"CC = {c_compiler}")
24090+
2407524091 makefile_path = out_dir / "Makefile"
2407624092 with open(makefile_path, 'w') as f:
2407724093 f.write(makefile_content)
0 commit comments