forked from libarchive/bzip2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
170 lines (154 loc) · 4.2 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
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
project(
'bzip2',
['c'],
version : '1.0.7',
meson_version : '>= 0.48.0',
default_options : ['c_std=c89', 'warning_level=1'],
)
conf_data = configuration_data()
conf_data.set('BZ_VERSION', meson.project_version())
configure_file(
input: 'bz_version.h.in',
output: 'bz_version.h',
configuration: conf_data
)
cc = meson.get_compiler('c')
add_project_arguments(cc.get_supported_arguments([
# Please keep this list in sync with CMakeLists.txt
'-Wall',
'-Wextra',
'-Wmissing-prototypes',
'-Wstrict-prototypes',
'-Wmissing-declarations',
'-Wpointer-arith',
'-Wdeclaration-after-statement',
'-Wformat-security',
'-Wwrite-strings',
'-Wshadow',
'-Winline',
'-Wnested-externs',
'-Wfloat-equal',
'-Wundef',
'-Wendif-labels',
'-Wempty-body',
'-Wcast-align',
'-Wclobbered',
'-Wvla',
'-Wpragmas',
'-Wunreachable-code',
'-Waddress',
'-Wattributes',
'-Wdiv-by-zero',
'-Wshorten-64-to-32',
'-Wconversion',
'-Wextended-offsetof',
'-Wformat-nonliteral',
'-Wlanguage-extension-token',
'-Wmissing-field-initializers',
'-Wmissing-noreturn',
'-Wmissing-variable-declarations',
# '-Wpadded', # Not used because we cannot change public structs
'-Wsign-conversion',
# '-Wswitch-enum', # Not used because this basically disallows default case
'-Wunreachable-code-break',
'-Wunused-macros',
'-Wunused-parameter',
'-Wredundant-decls',
'-Wheader-guard',
'-Wno-format-nonliteral', # This is required because we pass format string as "const char*.
]),
language : 'c',
)
add_project_arguments('-D_GNU_SOURCE', language : 'c')
if host_machine.system() == 'windows'
add_project_arguments('-D_WIN32', language : 'c')
endif
c_args = []
# The or is a workaround for https://github.com/mesonbuild/meson/issues/5530
if cc.has_function_attribute('visibility') or (cc.get_id() == 'clang' and host_machine.system() == 'darwin')
c_args += '-DBZ_EXTERN=__attribute__((__visibility__("default")))'
endif
bz_sources = ['blocksort.c', 'huffman.c', 'crctable.c', 'randtable.c', 'compress.c', 'decompress.c', 'bzlib.c']
## Library versioning
##
## New package version:
## revision += 1
##
## New interfaces:
## current += 1
## revision = 0
## age += 1
##
## Deleted/changed interfaces:
## current += 1
## revision = 0
## age = 0
##
## KEEP THESE IN SYNC WITH CMakeLists.txt OR STUFF WILL BREAK!
bz2_lt_current = 1
bz2_lt_revision = 7
bz2_lt_age = 0
bz2_soversion = bz2_lt_current - bz2_lt_age
bz2_lt_version = '@0@.@1@.@2@'.format(bz2_soversion, bz2_lt_age, bz2_lt_revision)
if ['msvc', 'clang-cl', 'intel-cl'].contains(cc.get_id())
libbzip2 = library(
'bz2',
bz_sources,
c_args : c_args,
vs_module_defs : 'libbz2.def',
version : bz2_lt_version,
soversion : bz2_soversion,
install : true,
)
else
libbzip2 = library(
'bz2',
bz_sources,
c_args : c_args,
gnu_symbol_visibility : 'hidden',
version : bz2_lt_version,
soversion : bz2_soversion,
install : true,
)
endif
bzip2 = executable(
'bzip2',
['bzip2.c'],
link_with : [libbzip2],
install : true,
)
executable(
'bzip2recover',
['bzip2recover.c'],
link_with : [libbzip2],
install : true,
)
## Install wrapper scripts
install_data(
'bzgrep', 'bzmore', 'bzdiff',
install_dir : get_option('bindir'),
install_mode : 'rwxr-xr-x',
)
## Create aliases. Use links if possible, but copies if not.
# Copies are mainly meant for windows, which doesn't have symlinks.
bindir = get_option('bindir')
targets = [['bzmore', 'bzless'], ['bzdiff', 'bzcmp'], ['bzgrep', 'bzegrep', 'bzfgrep'],
['bzip2', 'bunzip2', 'bzcat']]
extra_args = []
if host_machine.system() != 'windows' and build_machine.system() != 'windows'
extra_args = '--use-links'
endif
foreach t : targets
meson.add_install_script('install_links.py', get_option('bindir'), t, extra_args)
endforeach
## Generate pkg-config automaically from built library information
pkg = import('pkgconfig')
pkg.generate(
libbzip2,
description : 'Lossless, block-sorting data compression',
)
## install headers
install_headers('bzlib.h')
subdir('man')
subdir('docs')
subdir('tests')