Skip to content
Advertisement

How to check the OS with automake

I have a project that uses automake to create the configure and all related files (I’m using autoreconf command to make all this stuff). So, I’m trying to set some conditional files to compile when the project is compiling for macOS (OS X), Windows or Linux. But it fails with the following:

JavaScript

And the part containing the error in that Makefile.am is the following:

JavaScript

My question is, how can I check if the OS is Linux? And if it’s possible, is there a better way to check the OS in automake?

Advertisement

Answer

You can detect it directly in the Makefile, or define the conditionals in the configure source file (probably configure.ac), since you are using autoreconf:

JavaScript

Note: host_os refers to the target system, so if you are cross-compiling it sets the OS conditional of the system you are compiling to.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement