Skip to content

Commit

Permalink
[samples] Do not install Makefile's on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Aug 27, 2022
1 parent 943ecc6 commit 6bce1da
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 40 deletions.
23 changes: 12 additions & 11 deletions samples/cxx/SConscript
Expand Up @@ -115,14 +115,15 @@ set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS})
cmakelists = localenv.SubstFile(pjoin(subdir, 'CMakeLists.txt'), 'CMakeLists.txt.in')
install(pjoin('$inst_sampledir', 'cxx', subdir), cmakelists)

## 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)
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)
2 changes: 1 addition & 1 deletion samples/f77/Makefile.in
@@ -1,4 +1,4 @@
include @tmpl_Cantera_dot_mak@
include @make_Cantera_dot_mak@

F77=@F77@
RM=rm -f
Expand Down
22 changes: 11 additions & 11 deletions samples/f77/SConscript
Expand Up @@ -34,13 +34,6 @@ if not localenv["package_build"]:
libs = ['cantera_fortran'] + localenv['cantera_libs'] + env['cxx_stdlib']
linkflags = ('-g', localenv['thread_flags'])

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['tmpl_Cantera_dot_mak'] = mak_path

localenv['tmpl_cantera_incdirs'] = repr([x for x in incdirs if x])
localenv['tmpl_cantera_libs'] = repr(libs)
localenv['tmpl_cantera_libdirs'] = repr([x for x in libdirs if x])
Expand All @@ -62,9 +55,16 @@ if localenv["package_build"]:
localenv["CC"] = "gcc"

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

# Generate Makefile to be installed
makefile = localenv.SubstFile('Makefile', 'Makefile.in')
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

install('$inst_sampledir/f77', makefile)
install('$inst_sampledir/f77', sconstruct)
makefile = localenv.SubstFile("Makefile", "Makefile.in")
install("$inst_sampledir/f77", makefile)
2 changes: 1 addition & 1 deletion samples/f90/Makefile.in
@@ -1,4 +1,4 @@
include @tmpl_Cantera_dot_mak@
include @make_Cantera_dot_mak@

F90=@F90@
RM=rm -f
Expand Down
32 changes: 16 additions & 16 deletions samples/f90/SConscript
Expand Up @@ -29,13 +29,6 @@ for programName, sources in samples:
libs = ['cantera_fortran'] + localenv['cantera_libs'] + env['cxx_stdlib']
linkflags = ('-g', localenv['thread_flags'])

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['tmpl_Cantera_dot_mak'] = mak_path

localenv['tmpl_cantera_incdirs'] = repr([x for x in incdirs if x])
localenv['tmpl_cantera_libs'] = repr(libs)
localenv['tmpl_cantera_libdirs'] = repr([x for x in libdirs if x])
Expand All @@ -46,18 +39,25 @@ for programName, sources in samples:
localenv['tmpl_sourcename'] = programName + '.f90'

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

# Generate CMakeLists.txt to be installed
localenv['cmake_cantera_incdirs'] = ' '.join(quoted(x) for x in incdirs if x)
localenv['cmake_cantera_libs'] = ' '.join(libs)
localenv['cmake_cantera_libdirs'] = ' '.join(quoted(x) for x in libdirs if x)
cmakelists = localenv.SubstFile('CMakeLists.txt', 'CMakeLists.txt.in')

# Generate Makefile to be installed
localenv['make_target'] = programName
localenv['make_sourcefile'] = programName + '.f90'
makefile = localenv.SubstFile('Makefile', 'Makefile.in')

install('$inst_sampledir/f90', makefile)
install('$inst_sampledir/f90', sconstruct)
install('$inst_sampledir/f90', cmakelists)
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 6bce1da

Please sign in to comment.