forked from ProteoWizard/pwiz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ext-hdf5.jam
211 lines (187 loc) · 7.06 KB
/
ext-hdf5.jam
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#
# $Id$
#
#
# Original author: Matt Chambers <matt.chambers .@. vanderbilt.edu>
#
# Copyright 2011 Vanderbilt University - Nashville, TN 37232
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import extension ;
import property ;
import project ;
import feature ;
import common ;
import tar ;
import path ;
extension.declare hdf5 ;
.posix_usage_defines = _LARGEFILE_SOURCE _LARGEFILE64_SOURCE _BSD_SOURCE ;
.posix_build_defines = $(.posix_usage_defines) NDEBUG ;
rule init ( version ? : location : options * )
{
if ! $(.initialized)
{
.initialized = true ;
path-constant HDF5_SRC : $(location) ;
.usage-requirements = <include>$(location)/src <use>H5pubconf.h/<extension>hdf5 ;
.requirements = $(.usage-requirements) <warnings>off [ extension.static-with-fpic ] ;
if [ path.exists $(location).tar.bz2 ]
{
tar.extract $(location).tar.bz2 : *.c *.h : : : <check-last-file-only>true ;
}
else if ! [ path.exists $(location) ]
{
import errors ;
errors.user-error "HDF5 source tree not found at $(location)" ;
}
local zlib-src-location = [ feature.get-values <zlib-src-location> : $(options) ] ;
zlib-src-location ?= $(location)/../zlib-1.2.3 ;
path-constant ZLIB_SOURCE : $(zlib-src-location[1]) ;
using ext-zlib : 1.2.3 : $(ZLIB_SOURCE) ;
local boost-src-location = [ feature.get-values <boost-src-location> : $(options) ] ;
boost-src-location ?= $(location)/../boost_1_67_0 ;
path-constant BOOST_SOURCE : $(boost-src-location[1]) ;
using ext-boost : 1.67.0 : $(BOOST_SOURCE) ;
alias H5pubconf.h : $(location)/src/posix/H5pubconf.h : <location>$(location) <conditional>@H5pubconf-requirements : : <conditional>@H5pubconf-requirements ;
alias H5pubconf.h : $(location)/src/windows/H5pubconf.h : <location>$(location) <conditional>@H5pubconf-requirements <toolset>msvc : : <conditional>@H5pubconf-requirements ;
alias H5pubconf.h : $(location)/src/darwin/H5pubconf.h : <location>$(location) <conditional>@H5pubconf-requirements <toolset>darwin : : <conditional>@H5pubconf-requirements ;
exe H5detect : $(location)/src/H5detect.c : $(.requirements) ;
actions make_init { "$(>[1]:P)/H5detect" > "$(<)" }
make H5Tinit.c : H5detect : @make_init ;
actions copy_libsettings { cp -f "$(>)" "$(<)" }
make libhdf5.settings : $(location)/src/posix/libhdf5.settings : @copy_libsettings : <dependency>H5make_libsettings ;
make libhdf5.settings : $(location)/src/darwin/libhdf5.settings : @copy_libsettings : <toolset>darwin <dependency>H5make_libsettings ;
exe H5make_libsettings : $(location)/src/H5make_libsettings.c : $(.requirements) ;
actions make_libsettings
{
cd $(>[1]:P)
"$(>[1]:P)/H5make_libsettings" > "$(<)"
}
make H5lib_settings.c : H5make_libsettings : @make_libsettings ;
make init_once_workaround.cpp : : @init_once_workaround_cpp ;
local .excluded-src = *szip.c *mpi*.c H5make_libsettings.c H5detect.c H5FDdirect.c H5FDwindows.c ;
lib hdf5
: # sources
[ path.glob $(location)/src : *.c : $(.excluded-src) ]
init_once_workaround.cpp
H5Tinit.c
H5lib_settings.c
: # requirements
$(.requirements)
<conditional>@hdf5-requirements
: # default-build
: # usage-requirements
$(.usage-requirements)
<conditional>@hdf5-usage-requirements
;
lib hdf5pp
: # sources
[ path.glob $(location)/c++/src : *.cpp ]
: # requirements
$(.requirements)
<include>$(location)/c++/src
<library>hdf5
: # default-build
: # usage-requirements
$(.usage-requirements)
<include>$(location)/c++/src
<library>hdf5
;
}
}
rule H5pubconf-requirements ( properties * )
{
if <target-os>windows in $(properties)
{
return <include>$(HDF5_SRC)/src/windows ;
}
else if <toolset>darwin in $(properties)
{
return <include>$(HDF5_SRC)/src/darwin ;
}
else
{
return <include>$(HDF5_SRC)/src/posix ;
}
}
rule link-requirements ( properties * )
{
# HACK: <link>shared isn't being passed in properties like I'd expect, so I also check the command-line
if <link>shared in $(properties) || "link=shared" in [ modules.peek : ARGV ]
{
return <library>/ext/boost//thread/<link>shared
<library>/ext/zlib//z/<link>shared ;
}
else
{
return <library>/ext/boost//thread
<library>/ext/zlib//z ;
}
}
rule hdf5-requirements ( properties * )
{
if <target-os>windows in $(properties)
{
return <source>$(HDF5_SRC)/src/H5FDwindows.c
<conditional>@link-requirements ;
}
else if <toolset>darwin in $(properties)
{
return <source>$(HDF5_SRC)/src/H5FDdirect.c
<define>$(.posix_build_defines)
<cflags> ;
}
else
{
local result = <source>$(HDF5_SRC)/src/H5FDdirect.c
<define>$(.posix_build_defines)
<define>_POSIX_SOURCE ;
if <toolset>gcc in $(properties)
{
result += <cflags>-std=c99 ;
}
return $(result) ;
}
}
rule hdf5-usage-requirements ( properties * )
{
if <target-os>windows in $(properties)
{
return <conditional>@link-requirements ;
}
else
{
return <define>$(.posix_usage_defines)
<dependency>libhdf5.settings/<extension>hdf5 ;
}
}
rule init_once_workaround_cpp ( targets + : sources * : properties * )
{
local content = "#ifdef _MSC_VER\n" ;
content += "#include <boost/thread.hpp>\n" ;
content += "extern \"C\" {\n" ;
content += "#include \"H5pubconf.h\"\n" ;
content += "#include \"H5private.h\"\n" ;
content += "#include \"H5TSprivate.h\"\n" ;
content += "#include <stdio.h>\n" ;
content += "void boost_first_thread_init_really() { H5TS_win32_first_thread_init(NULL, NULL, NULL); }\n" ;
content += "int boost_first_thread_init() { static struct {boost::once_flag flag;} flag = {BOOST_ONCE_INIT}; boost::call_once(flag.flag, boost_first_thread_init_really); return 1; }\n" ;
content += "}\n" ;
content += "#endif // _MSC_VER\n" ;
FILE_CONTENTS on $(<[1]) = $(content) ;
}
actions init_once_workaround_cpp
{
@($(STDOUT):E=$(FILE_CONTENTS:J=)) > "$(<)"
}