Skip to content

Commit 9a1ee1b

Browse files
progvaldwfreed
authored andcommitted
build: add Meson buildsystem
1 parent 0cadd2e commit 9a1ee1b

File tree

18 files changed

+1095
-11
lines changed

18 files changed

+1095
-11
lines changed

.github/workflows/ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,54 @@ jobs:
8787
run: make check
8888
- name: make install
8989
run: make install
90+
91+
linux-meson:
92+
name: Linux (meson)
93+
runs-on: ${{ matrix.os }}
94+
strategy:
95+
fail-fast: false
96+
matrix:
97+
include:
98+
# can't check Debian 11 Bullseye because Ubuntu 22.04 Jammy's Meson is too old
99+
# Debian 12 Bookworm
100+
- os: ubuntu-24.04
101+
compiler: gcc-12
102+
- os: ubuntu-24.04
103+
compiler: clang-14
104+
# Debian 13 Trixie
105+
- os: ubuntu-24.04
106+
compiler: gcc-14
107+
- os: ubuntu-24.04
108+
compiler: clang-19
109+
# Ubuntu 22.04 Jammy's Meson is too old
110+
# Ubuntu 24.04 Noble
111+
- os: ubuntu-24.04
112+
compiler: gcc-13
113+
- os: ubuntu-24.04
114+
compiler: clang-18
115+
env:
116+
CC: ${{ matrix.compiler }}
117+
RUNNING_IN_CI: yes
118+
119+
steps:
120+
- name: Install dependencies
121+
run: |
122+
sudo apt-get update
123+
sudo apt-get install -y --no-install-recommends \
124+
${CC} \
125+
meson \
126+
ninja-build \
127+
libltdl-dev \
128+
libsqlite3-dev \
129+
libhyperscan-dev \
130+
# EOF
131+
- uses: actions/checkout@main
132+
with:
133+
persist-credentials: false
134+
submodules: recursive
135+
- name: meson setup
136+
run: meson setup --buildtype debugoptimized --warnlevel 2 build/
137+
- name: meson compile
138+
run: meson compile -C build/
139+
- name: meson test
140+
run: meson test -C build/

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,26 @@ These are known issues and workarounds for various platforms.
3737
# building
3838

3939
```bash
40-
sudo apt install build-essential pkg-config automake libtool libsqlite3-dev # or equivalent for your distribution
41-
./autogen.sh
42-
./configure --prefix=/path/to/installation
43-
make
44-
make check # run tests
45-
make install
40+
sudo apt install build-essential pkg-config meson ninja-build libsqlite3-dev flex bison # or equivalent for your distribution
41+
meson setup build --optimization 2 --prefix=/path/to/installation
42+
meson compile -C build/
43+
meson test -C build/
44+
meson install -C build/
4645
```
4746

48-
See `./configure --help` for build options.
47+
See `meson configure build/` for build options.
4948

5049
# feature specific requirements
5150

5251
* For SSL/TLS client and server connections, one of:
5352

54-
* OpenSSL 1.1.0 or newer (`--enable-openssl`)
55-
* LibreSSL (`--enable-openssl`)
56-
* mbedTLS (`--enable-mbedtls`)
57-
* GnuTLS (`--enable-gnutls`)
53+
* OpenSSL 1.1.0 or newer (`-Dopenssl=enabled`)
54+
* LibreSSL (`-Dopenssl=enabled`)
55+
* mbedTLS (`-Dmbedtls=enabled`)
56+
* GnuTLS (`-Dgnutls=enabled`)
57+
58+
If multiple TLS libraries are available, the build system will prefer mbedTLS > OpenSSL > GnuTLS.
59+
Use `=enabled` instead of `=auto` to force a specific library.
5860

5961
* For certificate-based oper CHALLENGE, OpenSSL 1.1.0 or newer.
6062
(Using CHALLENGE is not recommended for new deployments, so if you want to use a different TLS library,

authd/meson.build

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
authd_sources = files(
2+
'authd.c',
3+
'dns.c',
4+
'notice.c',
5+
'provider.c',
6+
'res.c',
7+
'reslib.c',
8+
'providers/dnsbl.c',
9+
'providers/ident.c',
10+
'providers/opm.c',
11+
'providers/rdns.c',
12+
)
13+
14+
authd = executable('authd',
15+
authd_sources,
16+
dependencies: [librb_dep],
17+
include_directories: include_directories('../include'),
18+
install: true,
19+
install_dir: pkglibexecdir,
20+
install_rpath: rpath,
21+
)

bandb/meson.build

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
bandb_common_sources = files(
2+
'rsdb_sqlite3.c',
3+
'rsdb_snprintf.c',
4+
)
5+
6+
bandb = executable('bandb',
7+
['bandb.c'] + bandb_common_sources,
8+
dependencies: [librb_dep, sqlite3_dep],
9+
include_directories: include_directories('../include'),
10+
install: true,
11+
install_dir: pkglibexecdir,
12+
install_rpath: rpath,
13+
)
14+
15+
bantool = executable('solanum-bantool',
16+
['bantool.c'] + bandb_common_sources,
17+
dependencies: [librb_dep, sqlite3_dep],
18+
include_directories: include_directories('../include'),
19+
install: true,
20+
install_rpath: rpath,
21+
)

doc/meson.build

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
install_data(
2+
'ircd.conf.example',
3+
'reference.conf',
4+
'ircd.motd',
5+
install_dir: confdir
6+
)

extensions/meson.build

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
extension_modules = [
2+
'cap_oper',
3+
'cap_realhost',
4+
'chantype_dummy',
5+
'chm_adminonly',
6+
'chm_operonly',
7+
'chm_insecure',
8+
'chm_nonotice',
9+
'chm_operpeace',
10+
'chm_regmsg',
11+
'chm_sslonly',
12+
'createauthonly',
13+
'createoperonly',
14+
'drain',
15+
'extb_account',
16+
'extb_canjoin',
17+
'extb_channel',
18+
'extb_guest',
19+
'extb_hostmask',
20+
'extb_oper',
21+
'extb_server',
22+
'extb_ssl',
23+
'extb_realname',
24+
'extb_usermode',
25+
'extb_extgecos',
26+
'extb_combi',
27+
'force_user_invis',
28+
'helpops',
29+
'hide_uncommon_channels',
30+
'hurt',
31+
'identify_msg',
32+
'invex_regonly',
33+
'invite_notify',
34+
'ip_cloaking',
35+
'ip_cloaking_old',
36+
'ip_cloaking_3.0',
37+
'ip_cloaking_4.0',
38+
'm_adminwall',
39+
'm_echotags',
40+
'm_extendchans',
41+
'm_findforwards',
42+
'm_identify',
43+
'm_locops',
44+
'm_mkpasswd',
45+
'm_ojoin',
46+
'm_okick',
47+
'm_omode',
48+
'm_opme',
49+
'm_remove',
50+
'm_sendbans',
51+
'm_shedding',
52+
'm_webirc',
53+
'no_kill_services',
54+
'no_locops',
55+
'no_oper_invis',
56+
'override',
57+
'override_kick_immunity',
58+
'restrict-unauthenticated',
59+
'sasl_usercloak',
60+
'sno_channelcreate',
61+
'sno_farconnect',
62+
'sno_globalnickchange',
63+
'sno_globaloper',
64+
'tag_message_id',
65+
'tag_typing',
66+
'umode_hide_idle_time',
67+
'umode_noctcp',
68+
'example_module',
69+
]
70+
71+
foreach mod : extension_modules
72+
shared_module(mod,
73+
mod + '.c',
74+
name_prefix: '',
75+
name_suffix: 'so',
76+
dependencies: [libircd_dep, librb_dep, global_include_dep],
77+
install: true,
78+
install_dir: moduledir / 'extensions'
79+
)
80+
endforeach
81+
82+
if have_hyperscan
83+
shared_module('filter',
84+
'filter.c',
85+
name_prefix: '',
86+
name_suffix: 'so',
87+
dependencies: [libircd_dep, librb_dep, global_include_dep, hyperscan_dep],
88+
install: true,
89+
install_dir: moduledir / 'extensions'
90+
)
91+
endif

help/meson.build

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Generate help index files
2+
meson.add_install_script(files('make_index.SH'), meson.current_source_dir(), helpdir)
3+
4+
# Symlinks from users -> opers for shared help topics
5+
user_symlinks = [
6+
'topic', 'accept', 'cmode', 'admin', 'names', 'links', 'away', 'whowas',
7+
'version', 'kick', 'who', 'invite', 'quit', 'join', 'list', 'nick',
8+
'oper', 'part', 'time', 'credits', 'motd', 'userhost', 'users', 'whois',
9+
'ison', 'lusers', 'user', 'help', 'pass', 'error', 'challenge', 'knock',
10+
'ping', 'pong', 'map', 'trace', 'chantrace', 'extban', 'monitor', 'batch'
11+
]
12+
13+
install_subdir('users',
14+
install_dir: helpdir,
15+
exclude_files: ['index.tmp'] + user_symlinks
16+
)
17+
18+
install_subdir('opers',
19+
install_dir: helpdir,
20+
exclude_files: ['index.tmp']
21+
)
22+
23+
foreach link : user_symlinks
24+
install_symlink(link,
25+
pointing_to: '../opers/' + link,
26+
install_dir: helpdir / 'users'
27+
)
28+
endforeach

include/meson.build

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
setup_h = configure_file(
2+
output: 'setup.h',
3+
configuration: conf_data,
4+
install: false
5+
)
6+
7+
serno_h = vcs_tag(
8+
command: ['git', 'rev-list', '-1', '--no-commit-header', '--date=format:%Y%m%d', '--format=%cd-%h', 'HEAD'],
9+
input: 'serno.h.in',
10+
output: 'serno.h',
11+
replace_string: '@SERNO@',
12+
fallback: 'unknown',
13+
)
14+
15+
datecode_h = vcs_tag(
16+
command: ['git', 'rev-list', '-1', '--no-commit-header', '--format=%ct', 'HEAD'],
17+
input: 'datecode.h.in',
18+
output: 'datecode.h',
19+
replace_string: '@DATECODE@',
20+
fallback: '0',
21+
)
22+
23+
global_include_dep = declare_dependency(
24+
sources: [setup_h, serno_h, datecode_h],
25+
include_directories: include_directories('.'),
26+
)

ircd/meson.build

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
ircd_parser = custom_target('ircd_parser',
2+
input: 'ircd_parser.y',
3+
output: ['ircd_parser.c', 'ircd_parser.h'],
4+
command: [bison, '-d', '@INPUT@', '--output=@OUTPUT0@', '--defines=@OUTPUT1@']
5+
)
6+
7+
ircd_lexer = custom_target('ircd_lexer',
8+
input: 'ircd_lexer.l',
9+
output: 'ircd_lexer.c',
10+
command: [flex, '-o', '@OUTPUT@', '@INPUT@']
11+
)
12+
13+
credits_result = run_command('sed', 's/^$/ /;s/.*/ "&",/', meson.project_source_root() / 'CREDITS', check: true)
14+
ircd_version_conf = configuration_data()
15+
ircd_version_conf.set('GENERATION', '0')
16+
ircd_version_conf.set('CREATION', '__DATE__ at __TIME__')
17+
ircd_version_conf.set('CREDITS', credits_result.stdout())
18+
ircd_version_conf.set('PACKAGE', meson.project_name())
19+
ircd_version = configure_file(
20+
input: 'version.c.in',
21+
output: 'version.c',
22+
configuration: ircd_version_conf
23+
)
24+
25+
libircd_sources = files(
26+
'authproc.c',
27+
'bandbi.c',
28+
'batch.c',
29+
'cache.c',
30+
'capability.c',
31+
'channel.c',
32+
'chmode.c',
33+
'class.c',
34+
'client.c',
35+
'client_tags.c',
36+
'dns.c',
37+
'extban.c',
38+
'getopt.c',
39+
'hash.c',
40+
'hook.c',
41+
'hostmask.c',
42+
'ircd.c',
43+
'ircd_signal.c',
44+
'listener.c',
45+
'logger.c',
46+
'match.c',
47+
'modules.c',
48+
'monitor.c',
49+
'msgbuf.c',
50+
'newconf.c',
51+
'operhash.c',
52+
'packet.c',
53+
'parse.c',
54+
'privilege.c',
55+
'ratelimit.c',
56+
'reject.c',
57+
'restart.c',
58+
's_conf.c',
59+
's_newconf.c',
60+
's_serv.c',
61+
's_user.c',
62+
'scache.c',
63+
'send.c',
64+
'snomask.c',
65+
'sslproc.c',
66+
'substitution.c',
67+
'supported.c',
68+
'tgchange.c',
69+
'whowas.c',
70+
)
71+
72+
libircd_inc = include_directories('../include')
73+
74+
libircd = shared_library('ircd',
75+
[libircd_sources, ircd_parser, ircd_lexer, ircd_version, serno_h],
76+
dependencies: [librb_dep, ltdl_dep],
77+
include_directories: libircd_inc,
78+
install: true,
79+
install_rpath: rpath,
80+
)
81+
82+
libircd_dep = declare_dependency(
83+
link_with: libircd,
84+
include_directories: libircd_inc,
85+
dependencies: [librb_dep, ltdl_dep]
86+
)
87+
88+
solanum = executable('solanum',
89+
'main.c',
90+
dependencies: [libircd_dep],
91+
export_dynamic: true,
92+
install: true,
93+
install_rpath: rpath,
94+
)

librb/include/meson.build

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Create a copy of serno.h in librb's include directory for version.c
2+
librb_include_dir = meson.current_build_dir() / 'include'
3+
4+
# replace with fs.copyfile if we bump the minimal Meson version to 1.64
5+
librb_serno_h = custom_target('librb_serno.h',
6+
input: serno_h,
7+
output: 'serno_librb.h',
8+
command: ['sh', '-c', 'cp $0 $1', '@INPUT@', '@OUTPUT@'],
9+
depends: serno_h
10+
)

0 commit comments

Comments
 (0)