Skip to content

Commit

Permalink
[SCons] Remove Makefile generation for samples
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Jun 21, 2023
1 parent 2eccea0 commit 5c789d4
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 296 deletions.
102 changes: 0 additions & 102 deletions platform/posix/Cantera.mak.in

This file was deleted.

48 changes: 1 addition & 47 deletions platform/posix/SConscript
Expand Up @@ -11,80 +11,37 @@ if env['INSTALL_MANPAGES']:

### Generate customized scripts ###

# Cantera.mak include file for Makefile projects
# cantera.pc for use with pkg-config

pc_libs = list(localenv['cantera_libs'])
pc_libdirs = []
pc_incdirs = []
pc_cflags = list(localenv['CXXFLAGS'])

localenv["mak_corelibs"] = " ".join(f"-l{lib}" for lib in localenv["cantera_libs"])

if localenv["package_build"]:
# folders outside of conda environment are not transferable
localenv["mak_extra_includes"] = ""
localenv["mak_extra_libdirs"] = ""
else:
localenv["mak_extra_includes"] = " ".join(
f"-I{dir}" for dir in localenv["extra_inc_dirs"])
if not localenv["package_build"]:
pc_incdirs.extend(localenv["extra_inc_dirs"])

localenv["mak_extra_libdirs"] = " ".join(
f"-L{dir} -Wl,-rpath,{dir}" for dir in localenv["extra_lib_dirs"])
pc_libdirs.extend(localenv["extra_lib_dirs"])

localenv["mak_stdlib"] = " ".join(f"-l{lib}" for lib in env["cxx_stdlib"])

if localenv['system_sundials']:
# Add links to the sundials environment
localenv["mak_sundials_libs"] = " ".join(
f"-l{lib}" for lib in localenv["sundials_libs"])
if localenv["sundials_libdir"] and not localenv["package_build"]:
localenv["mak_sundials_libdir"] = f"-L{localenv['sundials_libdir']}"
pc_libdirs.append(localenv['sundials_libdir'])
else:
localenv['mak_sundials_libdir'] = ''

if localenv["sundials_include"] and not localenv["package_build"]:
localenv["mak_sundials_include"] = f"-I{localenv['sundials_include']}"
pc_incdirs.append(localenv['sundials_include'])
else:
localenv['mak_sundials_include'] = ''

if localenv["boost_inc_dir"] and not localenv["package_build"]:
localenv["mak_boost_include"] = f"-I{localenv['boost_inc_dir']}"
pc_incdirs.append(localenv['boost_inc_dir'])
else:
localenv['mak_boost_include'] = ''

if localenv["use_hdf5"] and not localenv["package_build"]:
localenv["mak_hdf_include"] = f"-I{localenv['hdf_include']}"
pc_incdirs.append(localenv["hdf_include"])
localenv["mak_hdf_libs"] = f"-L{localenv['hdf_libdir']} -lhdf5"
else:
localenv["mak_hdf_include"] = ""
localenv["mak_hdf_libs"] = "-lhdf5"

# Handle BLAS/LAPACK linkage
blas_lapack_libs = " ".join(f"-l{lib}" for lib in localenv["blas_lapack_libs"])
if localenv["blas_lapack_dir"] and not localenv["package_build"]:
localenv["mak_blas_lapack_libs"] = (
f"-L{localenv['blas_lapack_dir']} {blas_lapack_libs}")
else:
localenv['mak_blas_lapack_libs'] = blas_lapack_libs

if 'Accelerate' in localenv['FRAMEWORKS']:
localenv['mak_blas_lapack_libs'] += ' -framework Accelerate'
pc_cflags.append('-framework Accelerate')

localenv['mak_threadflags'] = localenv['thread_flags']
if '-pthread' in localenv['thread_flags']:
localenv['mak_fort_threadflags'] = '-lpthread'
pc_cflags.append('-pthread')
pc_libs.append('pthread')
else:
localenv['mak_fort_threadflags'] = ''

if localenv["package_build"]:
# Remove sysroot flags in templated output files. This only applies to the
Expand All @@ -96,9 +53,6 @@ if localenv["package_build"]:
localenv["CCFLAGS"] = compiler_flag_list(localenv["CCFLAGS"], excludes)
localenv["CXXFLAGS"] = compiler_flag_list(localenv["CXXFLAGS"], excludes)

mak = build(localenv.SubstFile('Cantera.mak', 'Cantera.mak.in'))
install('$inst_incdir', mak)

# Generate cantera.pc for use with pkg-config
localenv["pc_prefix"] = localenv["prefix"]
localenv["pc_libdirs"] = " ".join(f"-L{dir}" for dir in pc_libdirs)
Expand Down
19 changes: 0 additions & 19 deletions samples/clib/Makefile.in

This file was deleted.

15 changes: 0 additions & 15 deletions samples/clib/SConscript
Expand Up @@ -49,18 +49,3 @@ for programName, sources in samples:
localenv['cmake_cantera_libdirs'] = ' '.join(quoted(x) for x in libdirs if x)
cmakelists = localenv.SubstFile('CMakeLists.txt', 'CMakeLists.txt.in')
install("$inst_sampledir/clib", cmakelists)

if localenv["OS"] != "Windows":
# Generate Makefile to be installed
mak_path = pjoin(localenv["ct_incroot"], "cantera", "Cantera.mak")
localenv["mak_compiler_flags"] = " ".join(cc_flags)
if " " in mak_path:
# There is no reasonable way to handle spaces in Makefile 'include'
# statement, so we fall back to using the relative path instead
mak_path = relpath(mak_path, pjoin(localenv["ct_sampledir"], "clib"))
localenv["make_Cantera_dot_mak"] = mak_path

localenv["make_target"] = programName
localenv["make_sourcefile"] = programName + ".c"
makefile = localenv.SubstFile("Makefile", "Makefile.in")
install("$inst_sampledir/clib", makefile)
20 changes: 0 additions & 20 deletions samples/cxx/Makefile.in

This file was deleted.

15 changes: 1 addition & 14 deletions samples/cxx/SConscript
Expand Up @@ -49,7 +49,7 @@ set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS})
buildSample(localenv.Program, pjoin(subdir, name),
multi_glob(localenv, subdir, *extensions))

# Note: These Makefiles and SConstruct files are automatically installed
# Note: These CMakeLists.txt and SConstruct files are automatically installed
# by the "RecursiveInstall" that grabs everything in the cxx directory.

incdirs = [localenv["ct_incroot"]]
Expand Down Expand Up @@ -118,16 +118,3 @@ set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS})
## Generate CMakeList.txt files to be installed
cmakelists = localenv.SubstFile(pjoin(subdir, 'CMakeLists.txt'), 'CMakeLists.txt.in')
install(pjoin('$inst_sampledir', 'cxx', subdir), cmakelists)

if localenv["OS"] != "Windows":
## Generate Makefiles to be installed
mak_path = pjoin(localenv["ct_incroot"], "cantera", "Cantera.mak")
localenv["mak_compiler_flags"] = " ".join(cc_flags)
if " " in mak_path:
# There is no reasonable way to handle spaces in Makefile 'include'
# statement, so we fall back to using the relative path instead
mak_path = os.path.relpath(mak_path, pjoin(localenv["ct_sampledir"], "cxx", subdir))
localenv["make_Cantera_dot_mak"] = mak_path

makefile = build(localenv.SubstFile(pjoin(subdir, "Makefile"), "Makefile.in"))
install(pjoin("$inst_sampledir", "cxx", subdir), makefile)
22 changes: 0 additions & 22 deletions samples/f77/Makefile.in

This file was deleted.

16 changes: 0 additions & 16 deletions samples/f77/SConscript
Expand Up @@ -4,8 +4,6 @@ from buildutils import *
Import('env', 'install', 'buildSample')
localenv = env.Clone()

localenv['mak_stdlib'] = ['-l' + lib for lib in env['cxx_stdlib']]

# (program name, [source files])
samples = [("ctlib", ["ctlib.f"]),
("demo", ["demo.f"]),
Expand Down Expand Up @@ -71,19 +69,5 @@ if localenv["package_build"]:
localenv["F77"] = "gfortran"
localenv["CC"] = "gcc"

localenv["mak_compiler_flags"] = " ".join(cc_flags)

sconstruct = localenv.SubstFile('SConstruct', 'SConstruct.in')
install("$inst_sampledir/f77", sconstruct)

if localenv["OS"] != "Windows":
# Generate Makefile to be installed
mak_path = pjoin(localenv["ct_incroot"], "cantera", "Cantera.mak")
if " " in mak_path:
# There is no reasonable way to handle spaces in Makefile 'include'
# statement, so we fall back to using the relative path instead
mak_path = relpath(mak_path, pjoin(localenv["ct_sampledir"], "f77"))
localenv["make_Cantera_dot_mak"] = mak_path

makefile = localenv.SubstFile("Makefile", "Makefile.in")
install("$inst_sampledir/f77", makefile)
25 changes: 0 additions & 25 deletions samples/f90/Makefile.in

This file was deleted.

16 changes: 0 additions & 16 deletions samples/f90/SConscript
Expand Up @@ -4,8 +4,6 @@ from buildutils import *
Import('env', 'install', 'buildSample')
localenv = env.Clone()

localenv['mak_stdlib'] = ['-l' + lib for lib in env['cxx_stdlib']]

# (program name, [source files])
samples = [('demo', ['demo.f90'])]

Expand Down Expand Up @@ -51,17 +49,3 @@ for programName, sources in samples:
localenv['cmake_cantera_libdirs'] = ' '.join(quoted(x) for x in libdirs if x)
cmakelists = localenv.SubstFile('CMakeLists.txt', 'CMakeLists.txt.in')
install("$inst_sampledir/f90", cmakelists)

if localenv["OS"] != "Windows":
# Generate Makefile to be installed
mak_path = pjoin(localenv["ct_incroot"], "cantera", "Cantera.mak")
if " " in mak_path:
# There is no reasonable way to handle spaces in Makefile 'include'
# statement, so we fall back to using the relative path instead
mak_path = relpath(mak_path, pjoin(localenv["ct_sampledir"], "f90"))
localenv["make_Cantera_dot_mak"] = mak_path

localenv["make_target"] = programName
localenv["make_sourcefile"] = programName + ".f90"
makefile = localenv.SubstFile("Makefile", "Makefile.in")
install("$inst_sampledir/f90", makefile)

0 comments on commit 5c789d4

Please sign in to comment.