--prefix and absolute paths

21 views
Skip to first unread message

Daniel Wagner

unread,
Mar 10, 2023, 4:23:21 AM3/10/23
to meson...@googlegroups.com
Hi,

I am trying to figure out how to use the --prefix argument correctly. My understanding
is that all paths (`bindir`, `sbindir`, `sysconfdir`, ...) should prepend the path provided
via the `--prefix` command line argument.

The issue I currently have is the Meson and muon do not agree how to handle this:
  project(
      'meson-test', ['c'],
      default_options: [
        'prefix=/usr/local',
      ]
  )

  prefixdir  = get_option('prefix')

  datadir     = join_paths(prefixdir, get_option('datadir'))
  sbindir     = join_paths(prefixdir, get_option('sbindir'))
  sysconfdir1 = join_paths(prefixdir, get_option('sysconfdir'))
  sysconfdir2 = prefixdir / get_option('sysconfdir')
  sysconfdir3 = prefixdir + get_option('sysconfdir')

  message('datadir: ' + datadir)
  message('sbindir: ' + sbindir)
  message('sysconfdir1: ' + sysconfdir1)
  message('sysconfdir2: ' + sysconfdir2)
  message('sysconfdir3: ' + sysconfdir3)


** with /etc as sysconfdir

$ muon setup .build-muon
detected compiler gcc '12.2.1' (['cc']), linker ld.bfd
configuring 'meson-test', version: undefined
message datadir: /usr/local/share
message sbindir: /usr/local/sbin
message sysconfdir1: /etc
message sysconfdir2: /etc
message sysconfdir3: /usr/local/etc


$ meson setup .build
The Meson build system
Version: 1.0.1
Source dir: /home/wagi/work/meson-test
Build dir: /home/wagi/work/meson-test/.build
Build type: native build
Project name: meson-test
Project version: undefined
C compiler for the host machine: cc (gcc 12.2.1 "cc (SUSE Linux) 12.2.1 20230124 [revision 193f7e62815b4089dfaed4c2bd34fd4f10209e27]")
C linker for the host machine: cc ld.bfd 2.40.20230127-2
Host machine cpu family: x86_64
Host machine cpu: x86_64
Message: datadir: /usr/local/share
Message: sbindir: /usr/local/sbin
Message: sysconfdir1: /usr/local/etc
Message: sysconfdir2: /usr/local/etc
Message: sysconfdir3: /usr/localetc
Build targets in project: 0

Found ninja-1.11.1 at /usr/bin/ninja

** with 'etc' as sysconfdir

$ muon setup -Dsysconfdir=etc .build-muon
detected compiler gcc '12.2.1' (['cc']), linker ld.bfd
configuring 'meson-test', version: undefined
message datadir: /usr/local/share
message sbindir: /usr/local/sbin
message sysconfdir1: /usr/local/etc
message sysconfdir2: /usr/local/etc
message sysconfdir3: /usr/localetc

setup complete

$ meson setup -Dsysconfdir=etc .build
The Meson build system
Version: 1.0.1
Source dir: /home/wagi/work/meson-test
Build dir: /home/wagi/work/meson-test/.build
Build type: native build
Project name: meson-test
Project version: undefined
C compiler for the host machine: cc (gcc 12.2.1 "cc (SUSE Linux) 12.2.1 20230124 [revision 193f7e62815b4089dfaed4c2bd34fd4f10209e27]")
C linker for the host machine: cc ld.bfd 2.40.20230127-2
Host machine cpu family: x86_64
Host machine cpu: x86_64
Message: datadir: /usr/local/share
Message: sbindir: /usr/local/sbin
Message: sysconfdir1: /usr/local/etc
Message: sysconfdir2: /usr/local/etc
Message: sysconfdir3: /usr/localetc
Build targets in project: 0

meson-test undefined

  User defined options
    sysconfdir: etc

Found ninja-1.11.1 at /usr/bin/ninja

I am a bit lost how to write a a meson.build file which works for Meson and
muon and give the correct result. Though I am not really sure what 'correct'
means here. When the sysconfdir is not absolut both tools do the same thing
but with the absolute path Meson is always prefixing whereas muon honors
the absolute path. I tend to say muon is more right.

I wasn't able to figure out this by looking at the documentation (maybe I just
missed the important part).

Thanks, 
Daniel
ps: Sorry for the HTML mess, writing this via a web interface

Eli Schwartz

unread,
Mar 10, 2023, 7:33:09 AM3/10/23
to Daniel Wagner, meson...@googlegroups.com
On 3/10/23 4:23 AM, Daniel Wagner wrote:
> ** with /etc as sysconfdir
>
> $ muon setup .build-muon
> [...]
>
> $ meson setup .build
> [...]


What makes you think that sysconfdir is /etc? You didn't define it as such.


> ** with 'etc' as sysconfdir
>
> $ muon setup -Dsysconfdir=etc .build-muon
> [...]
>
> $ meson setup -Dsysconfdir=etc .build
> [...]


Whereas here, you certainly did define it as "etc" and therefore that's
the value of sysconfdir.


> I am a bit lost how to write a a meson.build file which works for Meson and
> muon and give the correct result. Though I am not really sure what 'correct'
> means here. When the sysconfdir is not absolut both tools do the same thing
> but with the absolute path Meson is always prefixing whereas muon honors
> the absolute path. I tend to say muon is more right.
>
> I wasn't able to figure out this by looking at the documentation (maybe I just
> missed the important part).


Both meson and muon are doing the same thing here from the build
language perspective. Path joining works as documented, and string
concatenation (str + str) is flawed for use with paths, also as documented.

However, meson and muon differ in that the default sysconfdir in meson
depends on what your prefix is ("etc" most of the time, and "/etc" if
prefix is "/usr") and the default sysconfdir in muon is "/etc" no matter
what.


> ps: Sorry for the HTML mess, writing this via a web interface


Luckily my client only renders the plain text anyway. :D


--
Eli Schwartz

Daniel Wagner

unread,
Mar 10, 2023, 8:04:16 AM3/10/23
to Eli Schwartz, meson...@googlegroups.com
On 10.03.23 13:33, Eli Schwartz wrote:
> What makes you think that sysconfdir is /etc? You didn't define it as such.

I just assumed it because sysconfdir behaves differently to other
variables such as libdir.

> However, meson and muon differ in that the default sysconfdir in meson
> depends on what your prefix is ("etc" most of the time, and "/etc" if
> prefix is "/usr") and the default sysconfdir in muon is "/etc" no matter
> what.

Okay, my problem is due to the different defaults of sysconfdir. When I
set sysconfdir explicitly to either '/etc' or 'etc' I get a consistent
result using join_paths(). That means I will just set sysconfdir to
'etc' in the default_options.

>> ps: Sorry for the HTML mess, writing this via a web interface
>
> Luckily my client only renders the plain text anyway. :D

Hopefully this email is now only txt :)

Thanks!
Reply all
Reply to author
Forward
0 new messages