On 12/08/2016 09:25 AM, Paul Boddie wrote:
I don't want to get into an argument about systemd, but one way of detecting systemd would to be for things to test for a file that always gets installed as part of the systemd packages. This file could even have zero content and be explicitly added by the package maintainers (if the systemd people kept renaming everything), and nothing would ever need to link to anything. You could call this magic file libsystemd.so if you wanted, and it could actually be libsystemd.so if you really wanted. That would be a very Unix-like way of dealing with this.
That would not be a portable way to do it. Very bad idea. What if the system you're on uses that directory for something else? It could be that it just has to not support systemd at all. Or what if that turns out to be the file name of something else? You can make this unlikely, but not impossible.
And how would it be Unix-like? OK, I'm much younger than Unix and only a video game programmer who mostly uses Python, so maybe this is just because of that, but I have never heard of any Unix-like system telling programs about its capabilities by having or not having a particular file. Usually you use a simple function for that. Checking for the existence of a particular file would be esoteric.
Of course, that's all assuming you don't need to link to libsystemd, since that's something you decide at compile-time, not at runtime. If you need to link to libsystemd anyway, then the whole idea is pointless.