-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
86 lines (73 loc) · 2.65 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
# Copyright (c) 2023 Guilherme Janczak <[email protected]>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
project('punycode', 'c', version: '0.1', license: 'ISC',
meson_version: '>= 0.58.0',
default_options : ['c_std=c99', 'warning_level=2', 'b_lto=true'])
# Library
#
add_global_arguments('-D_GNU_SOURCE', language: 'c')
libpunycode = library('punycode', 'src/libpunycode.c',
install: true)
incdir = include_directories('src')
libpunycode_dep = declare_dependency(link_with: libpunycode,
include_directories: incdir)
install_man('src/punycode.3')
pkg = import('pkgconfig')
pkg.generate(libpunycode,
name: 'libpunycode',
description: 'Punycode encoder and decoder',
filebase: 'libpunycode',
url: 'https://github.com/guijan/punycode')
# Command-line utility and tests.
#
cc = meson.get_compiler('c')
funcs = {
'err': '#include <err.h>',
'errx': '#include <err.h>',
'getprogname': '#include <stdlib.h>',
'warnx': '#include <err.h>',
}
libbsd_dep = []
foreach func, header : funcs
if not cc.has_function(func, prefix: header)
libbsd_dep = dependency('libbsd-overlay')
break
endif
endforeach
if get_option('utility')
pkgpaths_dict = {
'openbsd': ['/usr/local/lib', '/usr/local/include'],
'netbsd': ['/usr/pkg/lib', '/usr/pkg/include'],
}
pkgpaths_dict += {'freebsd': pkgpaths_dict['openbsd']}
pkgpaths = get_option('pkg_paths')
if pkgpaths.length() == 0
if host_machine.system() in pkgpaths_dict
pkgpaths = pkgpaths_dict[host_machine.system()]
else
pkgpaths = [[], []]
endif
endif
libunistring_dep = declare_dependency(
dependencies: cc.find_library('unistring', dirs: pkgpaths[0]),
include_directories: pkgpaths[1]
)
punycode_exe = executable(
'punycode', 'src/punycode.c',
dependencies: [libbsd_dep, libpunycode_dep, libunistring_dep],
install: true
)
install_man('src/punycode.1')
endif
subdir('test')