From 3be53356a2af0416a369c28a4e760f8083a01f0d Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 9 Mar 2012 22:59:50 +0000 Subject: [PATCH] Updated sample build scripts to include pthread where necessary --- SConstruct | 13 ++++++++----- platform/posix/Cantera.mak.in | 6 ++++-- platform/posix/SConscript | 4 ++++ samples/cxx/SConscript | 2 ++ samples/cxx/SConstruct.in | 3 ++- samples/f77/SConscript | 3 ++- samples/f77/SConstruct.in | 3 ++- samples/f90/SConscript | 2 ++ samples/f90/SConstruct.in | 3 ++- 9 files changed, 28 insertions(+), 11 deletions(-) diff --git a/SConstruct b/SConstruct index d81db1408..8bd7dbeaa 100644 --- a/SConstruct +++ b/SConstruct @@ -112,6 +112,9 @@ env = Environment(tools=toolchain+['textfile', 'subst', 'recursiveInstall', 'wix toolchain=toolchain, **extraEnvArgs) +env['OS'] = platform.system() +env['OS_BITS'] = int(platform.architecture()[0][:2]) + # Fixes a linker error in Windows if os.name == 'nt' and 'TMP' in os.environ: env['ENV']['TMP'] = os.environ['TMP'] @@ -196,11 +199,14 @@ elif env['CC'] == 'clang': else: print "WARNING: Unrecognized C compiler '%s'" % env['CC'] -defaults.threadFlags = '-pthread' if os.name != 'nt' else '' - # TODO: Once deprecated functions have been removed, remove the # compiler options: -Wno-deprecated-declarations and /wd4996 +if env['OS'] in ('Windows', 'Darwin'): + defaults.threadFlags = '' +else: + defaults.threadFlags = '-pthread' + # ************************************** # *** Read user-configurable options *** # ************************************** @@ -602,9 +608,6 @@ of this file is: # ******************************************** # *** Configure system-specific properties *** # ******************************************** -env['OS'] = platform.system() - -env['OS_BITS'] = int(platform.architecture()[0][:2]) # Copy in external environment variables if env['env_vars'] == 'all': diff --git a/platform/posix/Cantera.mak.in b/platform/posix/Cantera.mak.in index 1f3aa32ea..3a2c6c95a 100644 --- a/platform/posix/Cantera.mak.in +++ b/platform/posix/Cantera.mak.in @@ -28,12 +28,14 @@ CANTERA_VERSION=@cantera_version@ CANTERA_CORE_INCLUDES=-I@ct_incroot@ # Required Cantera libraries -CANTERA_CORE_LIBS=-L@ct_libdir@ -lcantera +CANTERA_CORE_LIBS=@mak_threadflags@ -L@ct_libdir@ -lcantera CANTERA_CORE_FTN=-L@ct_libdir@ -lcantera_fortran -lcantera CANTERA_FORTRAN_MODS=@ct_incroot@/cantera +CANTERA_FORTRAN_SYSLIBS=@mak_fort_threadflags@ -lstdc++ + ############################################################################### # BOOST ############################################################################### @@ -75,7 +77,7 @@ CANTERA_LIBS=$(CANTERA_CORE_LIBS) $(CANTERA_SUNDIALS_LIBS) \ CANTERA_FORTRAN_LIBS=$(CANTERA_CORE_FTN) $(CANTERA_SUNDIALS_LIBS) \ $(CANTERA_BLAS_LAPACK_LIBS) $(CANTERA_BOOST_LIBS) \ - -lstdc++ + $(CANTERA_FORTRAN_SYSLIBS) ############################################################################### # END diff --git a/platform/posix/SConscript b/platform/posix/SConscript index 30d6ae4f1..8b3b4e700 100644 --- a/platform/posix/SConscript +++ b/platform/posix/SConscript @@ -36,9 +36,13 @@ localenv['mak_boost_libdir'] = ('-L' + localenv['boost_lib_dir'] localenv['mak_boost_libs'] = ' '.join('-l%s' % s for s in localenv['boost_libs']) + localenv['mak_have_blas_lapack_dir'] = '1' if localenv['blas_lapack_dir'] else '0' localenv['mak_blas_lapack_libs'] = ' '.join('-l%s' % s for s in localenv['blas_lapack_libs']) +localenv['mak_threadflags'] = localenv['thread_flags'] +if '-pthread' in localenv['thread_flags']: + localenv['mak_fort_threadflags'] = '-lpthread' mak = build(localenv.SubstFile('Cantera.mak', 'Cantera.mak.in')) install('$inst_sampledir', mak) diff --git a/samples/cxx/SConscript b/samples/cxx/SConscript index ca17f96a4..401b4289a 100644 --- a/samples/cxx/SConscript +++ b/samples/cxx/SConscript @@ -32,9 +32,11 @@ for subdir, name, extensions in samples: localenv['boost_libs'] + localenv['blas_lapack_libs']) libdirs = (localenv['ct_libdir'], localenv['sundials_libdir'], localenv['blas_lapack_dir'], localenv['boost_lib_dir']) + linkflags = ('-g', localenv['thread_flags']) localenv['tmpl_cantera_incdirs'] = repr([x for x in incdirs if x]) localenv['tmpl_cantera_libs'] = repr([x for x in libs if x]) localenv['tmpl_cantera_libdirs'] = repr([x for x in libdirs if x]) + localenv['tmpl_cantera_linkflags'] = repr([x for x in linkflags if x]) localenv['tmpl_progname'] = name localenv['tmpl_sourcename'] = name + '.cpp' diff --git a/samples/cxx/SConstruct.in b/samples/cxx/SConstruct.in index e27ce9705..898e4c7f2 100644 --- a/samples/cxx/SConstruct.in +++ b/samples/cxx/SConstruct.in @@ -3,7 +3,8 @@ env = Environment() env.Append(CCFLAGS='-g', CPPPATH=@tmpl_cantera_incdirs@, LIBS=@tmpl_cantera_libs@, - LIBPATH=@tmpl_cantera_libdirs@) + LIBPATH=@tmpl_cantera_libdirs@, + LINKFLAGS=@tmpl_cantera_linkflags@) program = env.Program('@tmpl_progname@', '@tmpl_sourcename@') Default(program) diff --git a/samples/f77/SConscript b/samples/f77/SConscript index 7d7e11ba7..638ebc9f4 100644 --- a/samples/f77/SConscript +++ b/samples/f77/SConscript @@ -24,10 +24,11 @@ libs = (['cantera_fortran', 'cantera'] + localenv['sundials_libs'] + localenv['boost_libs'] + localenv['blas_lapack_libs'] + ['stdc++']) libdirs = (localenv['ct_libdir'], localenv['sundials_libdir'], localenv['blas_lapack_dir'], localenv['boost_lib_dir']) +linkflags = ('-g', localenv['thread_flags']) localenv['tmpl_cantera_incdirs'] = repr([x for x in incdirs if x]) localenv['tmpl_cantera_libs'] = repr([x for x in libs if x]) localenv['tmpl_cantera_libdirs'] = repr([x for x in libdirs if x]) - +localenv['tmpl_cantera_linkflags'] = repr([x for x in linkflags if x]) sconstruct = localenv.SubstFile('SConstruct', 'SConstruct.in') # Generate Makefile to be installed diff --git a/samples/f77/SConstruct.in b/samples/f77/SConstruct.in index f4ab96f82..6b5fbfd0e 100644 --- a/samples/f77/SConstruct.in +++ b/samples/f77/SConstruct.in @@ -6,7 +6,8 @@ env.Append(FFLAGS='-g', CCFLAGS='-g', CPPPATH=@tmpl_cantera_incdirs@, LIBS=@tmpl_cantera_libs@, - LIBPATH=@tmpl_cantera_libdirs@) + LIBPATH=@tmpl_cantera_libdirs@, + LINKFLAGS=@tmpl_cantera_linkflags@) ctlib = env.Object('demo_ftnlib.cpp') diff --git a/samples/f90/SConscript b/samples/f90/SConscript index 9bec322a9..039e528f0 100644 --- a/samples/f90/SConscript +++ b/samples/f90/SConscript @@ -18,9 +18,11 @@ for programName, sources in samples: localenv['boost_libs'] + localenv['blas_lapack_libs'] + ['stdc++']) libdirs = (localenv['ct_libdir'], localenv['sundials_libdir'], localenv['blas_lapack_dir'], localenv['boost_lib_dir']) + linkflags = ('-g', localenv['thread_flags']) localenv['tmpl_cantera_incdirs'] = repr([x for x in incdirs if x]) localenv['tmpl_cantera_libs'] = repr([x for x in libs if x]) localenv['tmpl_cantera_libdirs'] = repr([x for x in libdirs if x]) + localenv['tmpl_cantera_linkflags'] = repr([x for x in linkflags if x]) localenv['tmpl_progname'] = programName localenv['tmpl_sourcename'] = programName + '.f90' diff --git a/samples/f90/SConstruct.in b/samples/f90/SConstruct.in index b1c030e89..bdc087434 100644 --- a/samples/f90/SConstruct.in +++ b/samples/f90/SConstruct.in @@ -4,7 +4,8 @@ env['F90'] = '@F90@' env.Append(FFLAGS='-g', F90PATH=@tmpl_cantera_incdirs@, LIBS=@tmpl_cantera_libs@, - LIBPATH=@tmpl_cantera_libdirs@) + LIBPATH=@tmpl_cantera_libdirs@, + LINKFLAGS=@tmpl_cantera_linkflags@) program = env.Program('@tmpl_progname@', '@tmpl_sourcename@') Default(program)