-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
146 lines (118 loc) · 3.75 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
project('libdvi', 'c',
version: '0.0.1',
default_options : [
'buildtype=debugoptimized',
'b_ndebug=if-release',
'warning_level=3',
'werror=true',
'c_std=c99'
],
license : 'LGPL-2.1',
meson_version : '>=0.53'
)
v_arr = meson.project_version().split('.')
v_maj = v_arr[0]
v_min = v_arr[1]
v_mic = v_arr[2]
# install paths
dir_prefix = get_option('prefix')
dir_include = join_paths(dir_prefix, get_option('includedir'))
dir_pkginclude = join_paths(dir_include, meson.project_name())
dir_bin = join_paths(dir_prefix, get_option('bindir'))
dir_lib = join_paths(dir_prefix, get_option('libdir'))
dir_data = join_paths(dir_prefix, get_option('datadir'))
dir_pkgdata = join_paths(dir_data, meson.project_name())
dir_locale = join_paths(dir_prefix, get_option('localedir'))
# host
windows = import('windows')
host_os = host_machine.system()
win = ['windows', 'cygwin']
#bsd for meson 0.46 and 0.47
bsd = ['bsd', 'freebsd', 'dragonfly', 'netbsd', 'openbsd']
linux = ['linux']
osx = ['darwin']
sun = ['sunos']
sys_linux = linux.contains(host_machine.system())
sys_bsd = bsd.contains(host_machine.system())
sys_windows = win.contains(host_machine.system())
sys_osx = osx.contains(host_machine.system())
sys_sun = sun.contains(host_machine.system())
# compiler
cc = meson.get_compiler('c')
dev_cflags = []
dev_cflags_try = [
'-Wcomment',
'-Wdeclaration-after-statement',
'-Wfloat-compare',
'-Wformat',
'-Wmissing-declarations',
'-Wmissing-prototypes',
'-Wno-long-long',
'-Wno-missing-field-initializers',
'-Wpointer-arith',
'-Wredundant-decls',
'-Wshadow',
'-Wsign-compare',
'-Wstrict-prototypes',
'-Wuninitialized',
'-fno-omit-frame-pointer'
]
if sys_windows
if cc.get_id() != 'msvc'
dev_cflags_try += '-Wno-pedantic-ms-format'
endif
else
dev_cflags_try += '-fvisibility=hidden'
endif
foreach cf: dev_cflags_try
if cc.has_argument(cf)
dev_cflags += cf
endif
endforeach
inc_config_dir = include_directories('.')
# configuration
config_h = configuration_data()
config_h.set_quoted('PACKAGE_NAME', meson.project_name())
config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
config_h.set_quoted('PACKAGE_BIN_DIR', dir_bin)
config_h.set_quoted('PACKAGE_LIB_DIR', dir_lib)
config_h.set_quoted('PACKAGE_DATA_DIR', dir_data)
config_h.set_quoted('LOCALEDIR', dir_locale)
subdir('src/lib')
subdir('src/bin')
# Use config_h after all subdirs have set values
configure_file(output : 'config.h', configuration : config_h)
# pc file
pkgconf = configuration_data()
pkgconf.set('prefix', get_option('prefix'))
pkgconf.set('exec_prefix', '${prefix}')
pkgconf.set('libdir', '${prefix}/@0@'.format(get_option('libdir')))
pkgconf.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
pkgconf.set('pkgincludedir', '${prefix}/@0@'.format(get_option('includedir')) + '/libdvi')
pkgconf.set('VMAJ', v_maj)
pkgconf.set('PACKAGE_VERSION', meson.project_version())
pkgconf.set('PACKAGE_NAME', meson.project_name())
pkg_install_dir = '@0@/pkgconfig'.format(get_option('libdir'))
configure_file(
input : 'libdvi.pc.in',
output : 'libdvi.pc',
configuration : pkgconf,
install_dir : pkg_install_dir
)
# output
summary({'OS': host_os,
'license': meson.project_license(),
'release mode': get_option('buildtype') == 'release' ? 'yes' : 'no',
'kpathsea dist.': have_texlive ? 'TeXLive' : 'MIKTeX',
}, section: 'Configuration Options Summary:')
summary({'prefix': dir_prefix,
'bindir': dir_bin,
'libdir': dir_lib,
'incdir': dir_include,
'pkgincdir': dir_pkginclude,
'datadir': dir_data,
'pkgdatadir': dir_pkgdata,
}, section: 'Directories:')
summary({'compilation': 'ninja',
'installation': 'ninja install',
}, section: 'Compilation')