Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to create a makefile that will compile my objects and name them according to the Linux distro (e.g. Suse, RedHat, or Ubuntu). How can I detect if the OS is Ubuntu or not?

share|improve this question
    
got it working? (since you deleted your comment :D) –  Rinzwind Apr 8 '13 at 10:03
    
yes, I changed the OS var to be "shell lsb_release -si" and now it works well :). Thanks you for your answer! –  RRR Apr 8 '13 at 11:04
    
+1 for the funny title. (hint: Makefile and Make file mean totally different things.) –  Mahesh Apr 8 '13 at 14:11
add comment

1 Answer

up vote 14 down vote accepted

We use cat /etc/lsb-release for identifying the Ubuntu release:

sh-3.2$  cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04.4 LTS"

For other releases it might be

ls /etc/*release

Gentoo, RedHat, Arch & SuSE all have a release file: http://linuxmafia.com/faq/Admin/release-files.html These is a complete script in the link ;)


Example code for operation system, architecture and version for Ubuntu type systems:

OS=$(lsb_release -si)
ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
VER=$(lsb_release -sr)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.