You are not logged in.

#1 2017-09-18 05:40:21

PhilippD
Member
Registered: 2015-02-06
Posts: 40

[SOLVED] Makefile how to distinguish Arch Linux and other Linux OS

For a software project that relies on the numpy utility f2py, I want to have a Makefile that is compatible with both Arch Linux, where the default python is python3, and Ubuntu / Red Hat where the default python is python2.
This is a problem in case of the f2py utility, since f2py is for python3 or python2 depending on the Linux distribution.

The code below is usable, it looks for the command mkinitcpio, normally only available on Arch Linux.
But certainly there is a more fail safe and elegant way to detect the operating system.
Thanks for your help.

ARCH_LINUX := $(shell command -v mkinitcpio 2>/dev/null)

ifdef ARCH_LINUX
		F2PY_py2 = f2py2
		F2PY_py3 = f2py
else
		F2PY_py2 = f2py
		F2PY_py3 = f2py3
endif

Last edited by PhilippD (2017-09-18 06:15:51)

Offline

#2 2017-09-18 05:58:52

IrvineHimself
Member
From: Scotland
Registered: 2016-08-21
Posts: 275

Re: [SOLVED] Makefile how to distinguish Arch Linux and other Linux OS

I am not sure how to put it in a Makefile, but

grep -i "PRETTY_NAME=" /etc/os-release | cut  -d'"' -f2

Et voilà, elle arrive. La pièce, le sous, peut-être qu'il arrive avec vous!

Offline

#3 2017-09-18 06:15:30

PhilippD
Member
Registered: 2015-02-06
Posts: 40

Re: [SOLVED] Makefile how to distinguish Arch Linux and other Linux OS

Thanks!

ARCH_LINUX := $(shell grep "Arch Linux" /etc/os-release 2>/dev/null)

Offline

#4 2017-09-18 12:05:07

mrunion
Member
From: Jonesborough, TN
Registered: 2007-01-26
Posts: 1,938
Website

Re: [SOLVED] Makefile how to distinguish Arch Linux and other Linux OS

Instead of trying to detect the OS, why not just try to detect what Python version is installed and act accordingly? That would make the most sense.


Matt

"It is very difficult to educate the educated."

Offline

Board footer

Powered by FluxBB