-
Notifications
You must be signed in to change notification settings - Fork 9
/
Sconstruct
81 lines (69 loc) · 2.12 KB
/
Sconstruct
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# -*- coding: utf-8 -*-
# -*- mode: python -*-
import os
if hasattr(os, "uname"):
system = os.uname()[0]
else:
system = "Windows"
# source files and libraries
src_files = ["#src/mtm.c", "#src/tfr.c"]
hdr_files = ["#include/tfr.h"]
libs = ["m"]
# install location
AddOption(
"--prefix",
dest="prefix",
type="string",
nargs=1,
action="store",
metavar="DIR",
help="installation prefix",
)
if not GetOption("prefix") == None:
install_prefix = GetOption("prefix")
else:
install_prefix = "/usr/local/"
Help(
"""
Type: 'scons' to build the library
'scons install' to install library and headers under %s
'scons matlab' to compile mex file
'scons test' to compile the test program
(use --prefix to change library installation location)
"""
% install_prefix
)
# build options
env = Environment(
ENV=os.environ,
LIBS=["m", "fftw3", "lapack"],
CPPPATH=["#include"],
CCFLAGS=["-O2", "-g", "-std=c99"],
tools=["default", "mex", "doxygen"],
)
# system-specific settings
if system == "Darwin":
# fftw is probably installed with macports; if elsewhere
# then adjust these paths
env.Append(
CPPPATH=["/opt/local/include", "/opt/homebrew/include", "/usr/local/include"],
LIBPATH=["/opt/local/lib", "/opt/homebrew/lib", "/usr/local/lib"],
)
elif system == "Linux":
# add additional items as needed (usually not required on modern debian)
pass
sharedobjs = env.SharedObject(src_files)
slib = env.StaticLibrary("#lib/libtfr", source=src_files)
dylib = env.SharedLibrary("#lib/libtfr", sharedobjs)
test_prog = env.Program("#test/test_tfr", ["test/test_tfr.c", slib])
env.Default(env.Alias("lib", [slib, dylib]))
env.Alias("test", test_prog)
env.Alias("install", env.Install(os.path.join(install_prefix, "include"), hdr_files))
env.Alias("install", env.Install(os.path.join(install_prefix, "lib"), [slib, dylib]))
# matlab mex-file
if hasattr(env, "MEX"):
mex = env.MEX("#matlab/tfrspec", ["#matlab/tfrspec.c", sharedobjs])
env.Alias("mex", mex)
if hasattr(env, "Doxygen"):
dox = env.Doxygen("doxy.cfg")
env.Alias("docs", dox)