Skip to content

Commit 2ad94ac

Browse files
committed
Added scons file. See Issue #26.
1 parent 8ffbed7 commit 2ad94ac

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ lib/
33
builds/
44
*.mod
55
*.o
6+
.sconsign.*
67
documentation/
78
visual_studio_2010/*.suo
89
visual_studio_2010/*.u2d

SConstruct

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# -*- python -*-
2+
#
3+
# SConstruct file for building json-fortran using scons
4+
#
5+
# This builds using the same commands as are used in json-fortran's
6+
# "build.sh" script, but with proper dependency checking. It also
7+
# deals gracefully with robodoc not being installed on the system.
8+
#
9+
10+
from distutils.spawn import find_executable
11+
import os
12+
from os.path import join
13+
14+
env = Environment()
15+
16+
if env['FORTRAN'] == 'gfortran':
17+
env = Environment(F90FLAGS = '-O2 -fbacktrace -g -Wall -Wextra -Wno-maybe-uninitialized -pedantic -std=f2008 -Jlib',)
18+
elif env['FORTRAN'] == 'ifort':
19+
env = Environment(F90FLAGS = '-O2 -warn -stand f08 -diag-disable 7601 -traceback -module lib',)
20+
21+
src = join('src','json_module.f90')
22+
obj = join('build','json_module.o')
23+
ar = join('lib','libjsonfortran.a')
24+
mod = join('lib','json_module.mod')
25+
exe = join('bin','json')
26+
27+
env.Library(ar, src,
28+
FORTRANMODDIR='lib', # this tells scons that we want the .mod file to be installed in to lib/
29+
LIBPREFIX='', # this tells scons /not/ to assume that the mod file should be libjson_module.mod
30+
)
31+
32+
33+
## this builds the example program and places it in bin/
34+
env.Program(exe, join('src','json_example.f90'), LIBS=['jsonfortran',], LIBPATH=['lib'])
35+
36+
env.Requires(exe, mod)
37+
38+
## ------ installation ----------
39+
40+
if os.name == 'nt':
41+
# these might not be the right place for your Windows machine....
42+
libinstall = 'C:\MinGW\lib'
43+
docinstall = 'C:\MinGW\share\doc\json-fortran'
44+
else:
45+
libinstall = '/usr/local/lib'
46+
docinstall = '/usr/local/share/doc/json-fortran'
47+
48+
env.Install(libinstall, [obj,ar,mod])
49+
env.Alias('install', libinstall)
50+
51+
52+
## ------ documentation ---------
53+
54+
if find_executable('robodoc'):
55+
56+
docfiles = [join('documentation','json_example_f90.html'),
57+
join('documentation','json_module_f90.html'),
58+
join('documentation','masterindex.html'),
59+
join('documentation','robo_classes.html'),
60+
join('documentation','robo_functions.html'),
61+
join('documentation','robo_modules.html'),
62+
join('documentation','robo_sourcefiles.html'),
63+
join('documentation','robo_unittests.html'),
64+
join('documentation','robodoc.css'),
65+
join('documentation','toc_index.html'), ]
66+
67+
bld = Builder(action='robodoc --src src/ --doc documentation/ --multidoc --html'+
68+
' --ignore_case_when_linking --syntaxcolors --source_line_numbers --index --tabsize 4 --documenttitle jsonfortran --sections')
69+
env = Environment(BUILDERS = {'RoboDoc' : bld})
70+
env.RoboDoc(docfiles, src)
71+
env.Depends(docfiles, src)
72+
env.Install(docinstall, docfiles)
73+
env.Alias('install', docinstall)

0 commit comments

Comments
 (0)