Skip to content

Commit

Permalink
meson: build systemd using meson
Browse files Browse the repository at this point in the history
It's crucial that we can build systemd using VS2010!

... er, wait, no, that's not the official reason. We need to shed old systems
by requring python 3! Oh, no, it's something else. Maybe we need to throw out
345 years of knowlege accumulated in autotools? Whatever, this new thing is
cool and shiny, let's use it.

This is not complete, I'm throwing it out here for your amusement and critique.

- rules for sd-boot are missing. Those might be quite complicated.

- rules for tests are missing too. Those are probably quite simple and
  repetitive, but there's lots of them.

- it's likely that I didn't get all the conditions right, I only tested "full"
  compilation where most deps are provided and nothing is disabled.

- busname.target and all .busname units are skipped on purpose.

  Otherwise, installation into $DESTDIR has the same list of files and the
  autoconf install, except for .la files.

It'd be great if people had a careful look at all the library linking options.
I added stuff until things compiled, and in the end there's much less linking
then in the old system. But it seems that there's still a lot of unnecessary
deps.

meson has a `shared_module` statement, which sounds like something appropriate
for our nss and pam modules. Unfortunately, I couldn't get it to work. For the
nss modules, we need an .so version of '2', but `shared_module` disallows the
version argument. For the pam module, it also didn't work, I forgot the reason.

The handling of .m4 and .in and .m4.in files is rather awkward. It's likely
that this could be simplified. If make support is ever dropped, I think it'd
make sense to switch to a different templating system so that two different
languages and not required, which would make everything simpler yet.

v2:
- use get_pkgconfig_variable
- use sh not bash
- use add_project_arguments

v3:
- drop required:true and fix progs/prog typo

v4:
- use find_library('bz2')
- add TTY_GID definition
- define __SANE_USERSPACE_TYPES__
- use join_paths(prefix, ...) is used on all paths to make them all absolute

v5:
- replace all declare_dependency's with []
- add more conf.get guards around optional components

v6:
- drop -pipe, -Wall which are the default in meson
- use compiler.has_function() and compiler.has_header_symbol instead of the
  hand-rolled checks.
- fix duplication in 'liblibsystemd' library name
- use the right .sym file for pam_systemd
- rename 'compiler' to 'cc': shorter, and more idiomatic.
  • Loading branch information
keszybz committed Apr 9, 2017
1 parent b345f0c commit d29c4b2
Show file tree
Hide file tree
Showing 59 changed files with 5,425 additions and 2 deletions.
29 changes: 29 additions & 0 deletions catalog/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- mode: meson -*-

in_files = '''
systemd.bg.catalog
systemd.be.catalog
systemd.be@latin.catalog
systemd.fr.catalog
systemd.it.catalog
systemd.pl.catalog
systemd.pt_BR.catalog
systemd.ru.catalog
systemd.zh_CN.catalog
systemd.zh_TW.catalog
systemd.catalog
'''.split()

support_url = get_option('support-url')
support_sed = 's~%SUPPORT_URL%~@0@~'.format(support_url)

foreach file : in_files
custom_target(
file,
input : file + '.in',
output: file,
command : [sed, support_sed, '@INPUT@'],
capture : true,
install : true,
install_dir : catalogdir)
endforeach
8 changes: 8 additions & 0 deletions docs/sysvinit/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- mode: meson -*-

file = configure_file(
input : 'README.in',
output : 'README',
configuration : substs)
install_data(file,
install_dir : sysvinit_path)
8 changes: 8 additions & 0 deletions docs/var-log/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- mode: meson -*-

file = configure_file(
input : 'README.in',
output : 'README',
configuration : substs)
install_data(file,
install_dir : varlogdir)
25 changes: 25 additions & 0 deletions hwdb/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- mode: meson -*-

hwdb_files = files('''
20-pci-vendor-model.hwdb
20-pci-classes.hwdb
20-usb-vendor-model.hwdb
20-usb-classes.hwdb
20-sdio-vendor-model.hwdb
20-sdio-classes.hwdb
20-bluetooth-vendor-product.hwdb
20-acpi-vendor.hwdb
20-OUI.hwdb
20-net-ifname.hwdb
60-evdev.hwdb
60-keyboard.hwdb
60-sensor.hwdb
70-mouse.hwdb
70-pointingstick.hwdb
70-touchpad.hwdb
'''.split())

if conf.get('ENABLE_HWDB', 0) == 1
install_data(hwdb_files,
install_dir : udevhwdbdir)
endif
109 changes: 109 additions & 0 deletions man/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# -*- mode: meson -*-

# This is lame, I know, but meson has no other include mechanism
subdir('rules')

# TODO: add regeneration rule:
# python3 tools/make-man-rules.py --meson man/*xml > man/rules/meson.build

xsltproc = find_program('xsltproc')
xsltproc_flags = [
'--nonet',
'--xinclude',
'--stringparam', 'man.output.quietly', '1',
'--stringparam', 'funcsynopsis.style', 'ansi',
'--stringparam', 'man.authors.section.enabled', '0',
'--stringparam', 'man.copyright.section.enabled', '0',
'--stringparam', 'systemd.version', '@0@'.format(meson.project_version()),
'--path',
'@0@:@1@'.format(meson.current_build_dir(), meson.current_source_dir())]

custom_man_xsl = files('custom-man.xsl')
custom_html_xsl = files('custom-man.xsl')
custom_entities_ent = files('custom-entities.ent')

foreach tuple : manpages
stem = tuple[0]
section = tuple[1]
aliases = tuple[2]
condition = tuple[3]

xml = stem + '.xml'
html = stem + '.html'
man = stem + '.' + section

manaliases = []
htmlaliases = []
foreach alias : aliases
manaliases += [alias + '.' + section]
htmlaliases += [alias + '.html']
endforeach

mandirn = get_option('mandir') + '/man' + section

install = condition == '' or conf.get(condition, 0) == 1

custom_target(
man,
input : xml,
output : [man] + manaliases,
command : [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags + [custom_man_xsl, '@INPUT@'],
install : install,
install_dir : mandirn)

custom_target(
html,
input : xml,
output : [html] + htmlaliases,
command : [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags + [custom_html_xsl, '@INPUT@'])

if not install
message('Skipping @0@.@1@ because @2@ is @3@'.format(stem, section, condition, install))
endif
endforeach

############################################################

source_xml_files = files()
foreach tuple : manpages
source_xml_files += files(tuple[0] + '.xml')
endforeach

systemd_directives_xml = custom_target(
'systemd.directives.xml',
input : source_xml_files,
output : 'systemd.directives.xml',
command : [make_directive_index_py, '@OUTPUT@'] + source_xml_files)

nonindex_xml_files = source_xml_files + [systemd_directives_xml]
systemd_index_xml = custom_target(
'systemd.index.xml',
input : nonindex_xml_files,
output : 'systemd.index.xml',
command : [make_man_index_py, '@OUTPUT@'] + nonindex_xml_files)

foreach tuple : [['systemd.directives', '7', systemd_directives_xml],
['systemd.index', '7', systemd_index_xml]]
stem = tuple[0]
section = tuple[1]
xml = tuple[2]

html = stem + '.html'
man = stem + '.' + section

mandirn = get_option('mandir') + '/man' + section

custom_target(
man,
input : xml,
output : man,
command : [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags + [custom_man_xsl, '@INPUT@'],
install : install,
install_dir : mandirn)

custom_target(
html,
input : xml,
output : html,
command : [xsltproc, '-o', '@OUTPUT0@'] + xsltproc_flags + [custom_html_xsl, '@INPUT@'])
endforeach
Loading

0 comments on commit d29c4b2

Please sign in to comment.