-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathmeson.build
181 lines (166 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
171
172
173
174
175
176
177
178
179
180
181
project(
'mrsh',
'c',
version: '0.0.0',
license: 'MIT',
meson_version: '>=0.47.0',
default_options: [
'c_std=c99',
'warning_level=3',
'werror=true',
],
)
cc = meson.get_compiler('c')
add_project_arguments(cc.get_supported_arguments([
'-Wundef',
'-Wlogical-op',
'-Wmissing-include-dirs',
'-Wold-style-definition',
'-Wpointer-arith',
'-Winit-self',
'-Wfloat-equal',
'-Wstrict-prototypes',
'-Wredundant-decls',
'-Wimplicit-fallthrough=2',
'-Wendif-labels',
'-Wstrict-aliasing=2',
'-Woverflow',
'-Wformat=2',
'-Wmissing-prototypes',
'-Wno-missing-braces',
'-Wno-missing-field-initializers',
'-Wno-unused-parameter',
'-Wno-unused-result', # fuck you glibc, and gcc, and the little dog, too
'-Wno-format-overflow', # causes false positives with gcc
]), language: 'c')
if get_option('readline-provider') == 'readline'
readline = cc.find_library('readline', required: get_option('readline'))
if readline.found()
add_project_arguments('-DHAVE_READLINE', language: 'c')
endif
if cc.has_function('rl_replace_line', prefix: '#include <stdio.h>\n #include <readline/readline.h>', dependencies: [readline])
add_project_arguments('-DHAVE_READLINE_REPLACE_LINE', language: 'c')
endif
else # editline
readline = dependency('libedit', required: get_option('readline'))
if readline.found()
add_project_arguments('-DHAVE_EDITLINE', language: 'c')
endif
endif
mrsh_inc = include_directories('include')
install_subdir('include/mrsh', install_dir: get_option('includedir'))
libmrsh_gnu_sym_path = join_paths(meson.current_source_dir(), 'libmrsh.gnu.sym')
libmrsh_gnu_sym_ldflag = '-Wl,--version-script=' + libmrsh_gnu_sym_path
libmrsh_darwin_sym_path = join_paths(meson.current_source_dir(), 'libmrsh.darwin.sym')
# On FreeBSD, -Wl,--version-script only works with -shared
if cc.links('', name: '-Wl,--version-script', args: ['-shared', libmrsh_gnu_sym_ldflag])
# GNU ld
link_args = [libmrsh_gnu_sym_ldflag]
elif host_machine.system() == 'darwin' and cc.has_multi_link_arguments('-Wl,-exported_symbols_list', libmrsh_darwin_sym_path)
# Clang on Darwin
link_args = ['-Wl,-exported_symbols_list', libmrsh_darwin_sym_path]
else
error('Linker doesn\'t support --version-script or -exported_symbols_list')
endif
lib_mrsh = library(
meson.project_name(),
files(
'arithm.c',
'array.c',
'ast_print.c',
'ast.c',
'buffer.c',
'builtin/alias.c',
'builtin/bg.c',
'builtin/break.c',
'builtin/builtin.c',
'builtin/cd.c',
'builtin/colon.c',
'builtin/command.c',
'builtin/dot.c',
'builtin/eval.c',
'builtin/exec.c',
'builtin/exit.c',
'builtin/export.c',
'builtin/false.c',
'builtin/fg.c',
'builtin/getopts.c',
'builtin/hash.c',
'builtin/jobs.c',
'builtin/pwd.c',
'builtin/read.c',
'builtin/return.c',
'builtin/set.c',
'builtin/shift.c',
'builtin/times.c',
'builtin/trap.c',
'builtin/true.c',
'builtin/type.c',
'builtin/ulimit.c',
'builtin/umask.c',
'builtin/unalias.c',
'builtin/unset.c',
'builtin/unspecified.c',
'builtin/wait.c',
'getopt.c',
'hashtable.c',
'parser/arithm.c',
'parser/parser.c',
'parser/program.c',
'parser/word.c',
'shell/arithm.c',
'shell/entry.c',
'shell/job.c',
'shell/path.c',
'shell/process.c',
'shell/redir.c',
'shell/shell.c',
'shell/task/pipeline.c',
'shell/task/simple_command.c',
'shell/task/task.c',
'shell/task/word.c',
'shell/trap.c',
'shell/word.c',
),
include_directories: mrsh_inc,
version: meson.project_version(),
link_args: link_args,
install: true,
)
mrsh = declare_dependency(
link_with: lib_mrsh,
include_directories: mrsh_inc,
)
shell_deps = [mrsh]
shell_files = [
'main.c'
]
if readline.found()
shell_deps += [readline]
shell_files += ['frontend/readline.c']
else
shell_files += ['frontend/basic.c']
endif
mrsh_exe = executable(
'mrsh',
files(shell_files),
dependencies: shell_deps,
install: true,
)
subdir('example')
subdir('test')
pkgconfig = import('pkgconfig')
pkgconfig.generate(
libraries: lib_mrsh,
version: meson.project_version(),
filebase: meson.project_name(),
name: meson.project_name(),
description: 'POSIX shell library',
)
status = [
'',
'Features:',
' readline: @0@'.format(readline.found()),
' examples: @0@'.format(get_option('examples')),
]
message('\n'.join(status))