Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect OS in a make file?

Tags:

makefile

I have a command that works one way in OSX/Unix and another in Debian/Linux. I want to create a make file for my application but need to detect the OS and issue the command accordingly. How would I go about doing this?

like image 581
Usman Ismail Avatar asked Feb 14 '12 15:02

Usman Ismail


1 Answers

You could use uname to do this. In your Makefile, you could write something like:

OS := $(shell uname)
ifeq $(OS) Darwin
# Run MacOS commands 
else
# check for Linux and run other commands
endif
like image 60
flexlingie Avatar answered Oct 20 '22 05:10

flexlingie