11project (
22 ' htslib' ,
33 ' c' ,
4- version : ' 1.22' ,
5- default_options : [' warning_level=0' , ' c_std=c99' , ' b_ndebug=if-release' ],
4+ version : ' 1.22.1' ,
65 license : ' MIT' ,
7- meson_version : ' >= 0.50 .0' ,
6+ meson_version : ' >= 0.54 .0' ,
87)
98
109cc = meson .get_compiler(' c' )
1110if cc.get_argument_syntax() == ' msvc'
1211 error (' MSVC is unsupported. Only MinGW.' )
1312endif
1413
15- # htslib uses
16- # - usleep()
17- # - strdup()
18- # - M_LN10/M_LN2
19- add_project_arguments (
20- ' -D_XOPEN_SOURCE=600' ,
21- language : ' c' ,
22- )
14+ thread_dep = dependency (' threads' )
15+ zlib_dep = dependency (' zlib' )
2316
2417if meson .version().version_compare(' >= 0.62' )
2518 dl_dep = dependency (' dl' )
2619else
2720 dl_dep = cc.find_library (' dl' )
2821endif
29- libm_dep = cc.find_library (
30- ' m' ,
31- required : false ,
32- )
33- regex_dep = dependency (
34- ' regex' ,
35- required : host_machine .system() == ' windows' ,
36- )
37- thread_dep = dependency (' threads' )
38- ws_dep = cc.find_library (
39- ' ws2_32' ,
40- required : host_machine .system() == ' windows' ,
41- )
42- zlib_dep = dependency (' zlib' )
22+
23+ if cc.links(' #include <math.h>\n int main(){log(0);}' )
24+ libm_dep = declare_dependency ()
25+ else
26+ libm_dep = cc.find_library (' m' )
27+ endif
28+
29+ if cc.links(' #include <regex.h>\n int main(){regfree(0);}' )
30+ regex_dep = declare_dependency ()
31+ else
32+ regex_dep = dependency (' regex' )
33+ endif
34+
35+ if host_machine .system() == ' windows'
36+ ws_dep = cc.find_library (' ws2_32' )
37+ else
38+ if cc.has_function(' recv' )
39+ ws_dep = declare_dependency ()
40+ else
41+ ws_dep = cc.find_library (' socket' )
42+ endif
43+ endif
4344
4445htslib_sources = files (
4546 ' bcf_sr_sort.c' ,
@@ -130,22 +131,23 @@ configure_file(
130131 configuration : htslib_version_h_config,
131132)
132133
133- # install library if
134- # - either running as a proper project
135- # - or linking to shared libraries
136- htslib_lib_install = (not meson .is_subproject()) or (get_option (
137- ' default_library' ,
138- ) != ' static' )
139-
140134htslib_lib = library (
141135 ' hts' ,
142136 htslib_sources,
137+ c_args : ' -D_XOPEN_SOURCE=600' ,
143138 soversion : 3 ,
144139 version : meson .project_version(),
145- install : htslib_lib_install ,
140+ install : true ,
146141 dependencies : [dl_dep, libm_dep, regex_dep, thread_dep, ws_dep, zlib_dep],
147142 gnu_symbol_visibility : ' hidden' ,
148- override_options : [' warning_level=0' , ' c_std=c99' ],
143+ override_options : ' c_std=c99' ,
144+ )
145+
146+ pc = import (' pkgconfig' )
147+ pc.generate(
148+ htslib_lib,
149+ name : ' htslib' ,
150+ description : ' C library for high-throughput sequencing data format' ,
149151)
150152
151153###################
@@ -155,14 +157,28 @@ htslib_lib = library(
155157htslib_dep = declare_dependency (
156158 include_directories : ' .' ,
157159 link_with : htslib_lib,
158- version : meson .project_version(),
159160)
160161
162+ meson .override_dependency(' htslib' , htslib_dep)
163+
164+ subdir (' htslib' )
165+
166+ foreach e : [' annot-tsv' , ' bgzip' , ' htsfile' , ' tabix' ]
167+ executable (
168+ e,
169+ 170+ dependencies : htslib_dep,
171+ install : true ,
172+ )
173+ endforeach
174+
175+ subdir (' ref_cache' )
176+
177+ #mangix/usr/local/bin/ref-cache
178+
161179#########
162180# tests #
163181#########
164182
165- if get_option (' tests' )
166- htslib_source_root = meson .current_source_dir()
167- subdir (' test' )
168- endif
183+ htslib_source_root = meson .current_source_dir()
184+ subdir (' test' )
0 commit comments