diff --git a/platform/posix/Cantera.mak.in b/platform/posix/Cantera.mak.in index d549cabac..1f3aa32ea 100644 --- a/platform/posix/Cantera.mak.in +++ b/platform/posix/Cantera.mak.in @@ -8,9 +8,11 @@ # Main Variables: # # CANTERA_INCLUDES = Variable containing the include path -# # CANTERA_LIBS = List of libraries to include on the link line # +# CANTERA_FORTRAN_LIBS = list of libraries to link for Fortran programs +# CANTERA_FORTRAN_MODS = Directory containing the F90 .mod files +# CANTERA_VERSION=@cantera_version@ @@ -28,6 +30,10 @@ CANTERA_CORE_INCLUDES=-I@ct_incroot@ # Required Cantera libraries CANTERA_CORE_LIBS=-L@ct_libdir@ -lcantera +CANTERA_CORE_FTN=-L@ct_libdir@ -lcantera_fortran -lcantera + +CANTERA_FORTRAN_MODS=@ct_incroot@/cantera + ############################################################################### # BOOST ############################################################################### @@ -67,6 +73,10 @@ CANTERA_DEFINES = -DCANTERA_VERSION=@cantera_version@ CANTERA_LIBS=$(CANTERA_CORE_LIBS) $(CANTERA_SUNDIALS_LIBS) \ $(CANTERA_BLAS_LAPACK_LIBS) $(CANTERA_BOOST_LIBS) +CANTERA_FORTRAN_LIBS=$(CANTERA_CORE_FTN) $(CANTERA_SUNDIALS_LIBS) \ + $(CANTERA_BLAS_LAPACK_LIBS) $(CANTERA_BOOST_LIBS) \ + -lstdc++ + ############################################################################### # END ############################################################################### diff --git a/samples/f77/Makefile.in b/samples/f77/Makefile.in new file mode 100644 index 000000000..1ebd11793 --- /dev/null +++ b/samples/f77/Makefile.in @@ -0,0 +1,21 @@ +include ../Cantera.mak + +FC=@F77@ +RM=rm -f +FFLAGS=-g +LDFLAGS= +LDLIBS=$(CANTERA_FORTRAN_LIBS) +CPPFLAGS=$(CANTERA_INCLUDES) + +OBJS=isentropic.o demo_ftnlib.o + +all: isentropic + +isentropic: $(OBJS) + $(F77) $(LDFLAGS) -o isentropic $(OBJS) $(LDLIBS) + +clean: + $(RM) $(OBJS) + +dist-clean: clean + $(RM) *~ diff --git a/samples/f77/SConscript b/samples/f77/SConscript index dcdca8f47..7c5275e9f 100644 --- a/samples/f77/SConscript +++ b/samples/f77/SConscript @@ -30,3 +30,6 @@ localenv['tmpl_cantera_libs'] = repr([x for x in libs if x]) localenv['tmpl_cantera_libdirs'] = repr([x for x in libdirs if x]) sconstruct = localenv.SubstFile('SConstruct', 'SConstruct.in') + +# Generate Makefile to be installed +makefile = localenv.SubstFile('Makefile', 'Makefile.in') diff --git a/samples/f77/SConstruct.in b/samples/f77/SConstruct.in index fd901d736..f4ab96f82 100644 --- a/samples/f77/SConstruct.in +++ b/samples/f77/SConstruct.in @@ -10,12 +10,9 @@ env.Append(FFLAGS='-g', ctlib = env.Object('demo_ftnlib.cpp') -demo_obj = env.Object('demo.f') -isentropic_obj = env.Object('isentropic.f') - -demo = env.Program('demo', [ctlib, demo_obj], +demo = env.Program('demo', [ctlib, 'demo.f'], LINK='$F77') -isentropic = env.Program('isentropic', [ctlib, isentropic_obj], +isentropic = env.Program('isentropic', [ctlib, 'isentropic.f'], LINK='$F77') Default(demo) diff --git a/samples/f90/Makefile.in b/samples/f90/Makefile.in new file mode 100644 index 000000000..da79d7126 --- /dev/null +++ b/samples/f90/Makefile.in @@ -0,0 +1,26 @@ +include ../Cantera.mak + +F90=@F90@ +RM=rm -f +F90FLAGS=-g +FORTRANMODDIRPREFIX=@FORTRANMODDIRPREFIX@ +F90MODDIR=$(CANTERA_FORTRAN_MODS) +LDFLAGS= +LDLIBS=$(CANTERA_FORTRAN_LIBS) + +SRCS=@make_sourcefile@ +OBJS=$(subst .f90,.o,$(SRCS)) + +all: @make_target@ + +@make_target@: $(OBJS) + $(F90) $(LDFLAGS) -o @make_target@ $(OBJS) $(LDLIBS) + +%.o : %.f90 + $(F90) -c $< $(FORTRANMODDIRPREFIX)$(F90MODDIR) $(F90FLAGS) + +clean: + $(RM) $(OBJS) + +dist-clean: clean + $(RM) *~ diff --git a/samples/f90/SConscript b/samples/f90/SConscript new file mode 100644 index 000000000..f37b585b2 --- /dev/null +++ b/samples/f90/SConscript @@ -0,0 +1,34 @@ +from buildutils import * + +Import('env', 'installTargets', 'sampleTargets') +localenv = env.Clone() + +# (program name, [source files]) +samples = [('demo', ['demo.f90'])] + +for programName, sources in samples: + if 'samples' in COMMAND_LINE_TARGETS: + prog = localenv.Program(programName, sources, + CPPPATH=['#build/src/fortran', '#include'], + LIBS=env['cantera_libs']+['cantera_fortran']+['stdc++'], + LIBPATH=[env['sundials_libdir'], '#build/lib']) + sampleTargets.extend(prog) + + # Generate SConstruct files to be installed + incdirs = [pjoin(localenv['ct_incroot'], 'cantera')] + 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']) + 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_progname'] = programName + localenv['tmpl_sourcename'] = programName + '.f90' + + sconstruct = localenv.SubstFile('SConstruct', 'SConstruct.in') + + # Generate Makefile to be installed + localenv['make_target'] = programName + localenv['make_sourcefile'] = programName + '.f90' + makefile = localenv.SubstFile('Makefile', 'Makefile.in')