在 Makefile 中检测它的 Ubuntu Linux 操作系统

RRR*_*RRR 14 makefile

我想创建一个 makefile 来编译我的对象并根据 Linux 发行版(例如 Suse、RedHat 或 Ubuntu)命名它们。如何检测操作系统是否为 Ubuntu?

Rin*_*ind 20

我们cat /etc/lsb-release用于识别 Ubuntu 版本:

sh-3.2$  cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04.4 LTS"
Run Code Online (Sandbox Code Playgroud)

对于其他版本,它可能是

ls /etc/*release
Run Code Online (Sandbox Code Playgroud)

Gentoo、RedHat、Arch 和 SuSE 都有一个发布文件:http : //linuxmafia.com/faq/Admin/release-files.html这些是链接中的完整脚本;)


Ubuntu类型系统的操作系统、架构和版本示例代码:

OS=$(shell lsb_release -si)
ARCH=$(shell uname -m | sed 's/x86_//;s/i[3-6]86/32/')
VER=$(shell lsb_release -sr)
Run Code Online (Sandbox Code Playgroud)