Skip to content

Commit

Permalink
meson: Print system paths + use always use prefix
Browse files Browse the repository at this point in the history
Before prefix was used only for systemd builds.
Now it's used also for non-systemd builds.

+ simplify code with reusing variables.

Reviewed-by: Sami Kerola <[email protected]>
Signed-off-by: Petr Vorel <[email protected]>
  • Loading branch information
pevik committed Nov 4, 2019
1 parent 7217c44 commit 1f5a2a9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 23 deletions.
42 changes: 26 additions & 16 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ build_traceroute6 = get_option('BUILD_TRACEROUTE6')
build_mans = get_option('BUILD_MANS')
build_html_mans = get_option('BUILD_HTML_MANS')

prefix = get_option('prefix')
bindir = join_paths(prefix, get_option('bindir'))
localedir = join_paths(prefix, get_option('localedir'))
sbindir = join_paths(prefix, get_option('sbindir'))

systemd = dependency('systemd', required : false)
systemdunitdir = get_option('systemdunitdir')
if systemdunitdir == '' and systemd.found()
systemdunitdir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
endif

setcap_arping = false
setcap_clockdiff = false
setcap_ping = false
Expand All @@ -45,12 +56,6 @@ if (not get_option('NO_SETCAP_OR_SUID'))
setcap_traceroute6 = get_option('SETCAP_OR_SUID_TRACEROUTE6')
endif

systemd = dependency('systemd', required : false)
systemdunitdir = get_option('systemdunitdir')
if systemdunitdir == '' and systemd.found()
systemdunitdir = systemd.get_pkgconfig_variable('systemdsystemunitdir')
endif

# Check functions.
foreach f : '''
__fpending
Expand Down Expand Up @@ -115,12 +120,10 @@ endif
intl_dep = []
gettext = get_option('USE_GETTEXT')
if gettext == true
prefix = get_option('prefix')
localedir = get_option('localedir')
add_project_arguments(['-DGETTEXT_PACKAGE="iputils"'], language: 'c')

conf.set('ENABLE_NLS', 1, description : 'If set enable I18N.')
conf.set_quoted('LOCALEDIR', join_paths(prefix, localedir))
conf.set_quoted('LOCALEDIR', localedir)
subdir ('po')
intl_dep += cc.find_library('intl', required : false)
endif
Expand Down Expand Up @@ -272,7 +275,7 @@ if build_traceroute6 == true
install: true)
if (setcap_traceroute6)
meson.add_install_script('build-aux/setcap-setuid.sh',
join_paths(get_option('prefix'), get_option('bindir')),
bindir,
'traceroute6',
perm_type,
setcap_path
Expand All @@ -287,7 +290,7 @@ if build_clockdiff == true
install: true)
if (setcap_clockdiff)
meson.add_install_script('build-aux/setcap-setuid.sh',
join_paths(get_option('prefix'), get_option('bindir')),
bindir,
'clockdiff',
perm_type,
setcap_path
Expand All @@ -297,12 +300,12 @@ endif

if build_rdisc == true
executable('rdisc', ['rdisc.c', git_version_h],
install_dir: get_option('sbindir'),
install_dir: sbindir,
link_with : [libcommon],
install: true)
if systemd.found()
subs = configuration_data()
subs.set('sbindir', join_paths(get_option('prefix'), get_option('sbindir')))
subs.set('sbindir', sbindir)
unit_file = configure_file(
input: 'systemd/rdisc.service.in',
output: 'rdisc.service',
Expand All @@ -319,7 +322,7 @@ if build_arping == true
install: true)
if (setcap_arping)
meson.add_install_script('build-aux/setcap-setuid.sh',
join_paths(get_option('prefix'), get_option('bindir')),
bindir,
'arping',
perm_type,
setcap_path
Expand All @@ -333,12 +336,12 @@ endif

if build_rarpd == true
executable('rarpd', ['rarpd.c', git_version_h],
install_dir: get_option('sbindir'),
install_dir: sbindir,
link_with : [libcommon],
install: true)
if systemd.found()
subs = configuration_data()
subs.set('sbindir', join_paths(get_option('prefix'), get_option('sbindir')))
subs.set('sbindir', sbindir)
unit_file = configure_file(
input: 'systemd/rarpd.service.in',
output: '[email protected]',
Expand Down Expand Up @@ -382,6 +385,13 @@ output += 'IDN (with libidn2): ' + idn.to_string() + '\n'
output += 'I18N (with gettext): ' + gettext.to_string() + '\n'
output += 'systemd: ' + systemd.found().to_string() + '\n'

output += '\nSYSTEM PATHS\n'
output += 'prefix: ' + prefix + '\n'
output += 'bindir: ' + bindir + '\n'
output += 'localedir: ' + localedir + '\n'
output += 'sbindir: ' + sbindir + '\n'
output += 'systemdunitdir: ' + systemdunitdir + '\n'

message(output)

############################################################
Expand Down
6 changes: 3 additions & 3 deletions ninfod/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ executable('ninfod', [ninfod_sources, git_version_h],
link_with : [libcommon],
include_directories : inc,
install: true,
install_dir: get_option('sbindir'))
install_dir: sbindir)
conf_data = configuration_data()
conf_data.set('prefix', get_option('prefix'))
conf_data.set('prefix', prefix)

if systemd.found()
subs = configuration_data()
subs.set('sbindir', join_paths(get_option('prefix'), get_option('sbindir')))
subs.set('sbindir', sbindir)
unit_file = configure_file(
input: '../systemd/ninfod.service.in',
output: 'ninfod.service',
Expand Down
2 changes: 1 addition & 1 deletion ping/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ executable('ping', [

if (setcap_ping)
meson.add_install_script('../build-aux/setcap-setuid.sh',
join_paths(get_option('prefix'), get_option('bindir')),
bindir,
'ping',
perm_type,
setcap_path
Expand Down
6 changes: 3 additions & 3 deletions tftpd/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ executable('tftpd', ['tftpd.c', 'tftpsubs.c', git_version_h],
install: true)

subs = configuration_data()
subs.set('sbindir', join_paths(get_option('prefix'), get_option('sbindir')))
subs.set('tftpdatadir', join_paths(get_option('prefix'), get_option('localstatedir')))
subs.set('sbindir', sbindir)
subs.set('tftpdatadir', join_paths(prefix, get_option('localstatedir')))
unit_file = configure_file(
input: 'xinetd.conf.in',
output: 'tftp',
configuration: subs
)
etcdir = join_paths(get_option('prefix'), get_option('sysconfdir'))
etcdir = join_paths(prefix, get_option('sysconfdir'))
xinetdir = join_paths(etcdir, 'xinetd.d')
install_data(unit_file, install_dir: xinetdir)

0 comments on commit 1f5a2a9

Please sign in to comment.