-
Notifications
You must be signed in to change notification settings - Fork 1
/
meson.build
107 lines (93 loc) · 2.46 KB
/
meson.build
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
project(
'sm3-fortran',
'fortran', 'c',
version: '1.0.0',
license: 'MIT',
default_options: [
'buildtype=debugoptimized',
'fortran_std=f2008',
'default_library=both',
'c_std=c11',
],
)
# add source files
src = files(
'src/SM3.f90',
'GmSSL/src/sm3.c',
'GmSSL/src/md5.c',
'GmSSL/src/hex.c',
)
sm3_fortran_inc = include_directories(
'GmSSL/include',
)
sm3_fortran_lib = library(
meson.project_name(),
src,
include_directories: sm3_fortran_inc,
install: true,
version: meson.project_version(),
)
# declare dependency
sm3_fortran_dep = declare_dependency(
include_directories: sm3_fortran_lib.private_dir_include(),
link_with: sm3_fortran_lib,
)
# add example
example_md5 = executable(
'example_md5',
'example/example_md5.f90',
dependencies: sm3_fortran_dep,
)
example_sm3 = executable(
'example_sm3',
'example/example_sm3.f90',
dependencies: sm3_fortran_dep,
)
example_md5test = executable(
'example_md5test',
'GmSSL/example/md5test.c',
dependencies: sm3_fortran_dep,
include_directories: sm3_fortran_inc,
)
# copy LICENSE file
sm3_fortran_lic = files('LICENSE')
GmSSL_lic = files('GmSSL/LICENSE')
install_data(
sm3_fortran_lic,
install_dir: join_paths(get_option('prefix'), 'licenses', meson.project_name()),
)
install_data(
GmSSL_lic,
install_dir: join_paths(get_option('prefix'), 'licenses', meson.project_name(), 'GmSSL'),
)
# install fortran module
if host_machine.system() == 'windows'
symbols_file = 'lib'+meson.project_name()+'-'+meson.project_version().split('.')[0]+'.dll.symbols'
obj_suffix = '.obj'
else
symbols_file = 'lib'+meson.project_name()+'.so.'+meson.project_version()+'.symbols'
obj_suffix = '.o'
endif
install_subdir(sm3_fortran_lib.full_path()+'.p',
install_dir: 'include'/meson.project_name(),
strip_directory: true,
exclude_files: [
'depscan.dd',
meson.project_name()+'-deps.json',
symbols_file,
meson.project_name()+'.dat',
'src_SM3.f90'+obj_suffix,
'GmSSL_src_md5.c'+obj_suffix,
'GmSSL_src_sm3.c'+obj_suffix,
'GmSSL_src_hex.c'+obj_suffix,
]
)
# install pkg-config file
pkg = import('pkgconfig')
pkg.generate(
sm3_fortran_lib,
name: meson.project_name(),
description: 'The SM3 password hashing algorithm is a hash algorithm similar to SHA-256',
version: meson.project_version(),
subdirs: meson.project_name(),
)