Answer by LucasJ for OS detecting makefile
An alternate way that I have not seen anyone talking about is using the built-in variable SHELL. The program used as the shell is taken from the variable SHELL. On MS-Windows systems, it is most likely...
View ArticleAnswer by Patrick B Warren for OS detecting makefile
I had a case where I had to detect the difference between two versions of Fedora, to tweak the command-line options for inkscape: - in Fedora 31, the default inkscape is 1.0beta which uses...
View ArticleAnswer by Ken Jackson for OS detecting makefile
I finally found the perfect solution that solves this problem for me.ifeq '$(findstring ;,$(PATH))'';' UNAME := Windowselse UNAME := $(shell uname 2>/dev/null || echo Unknown) UNAME := $(patsubst...
View ArticleAnswer by Samuel for OS detecting makefile
Here's a simple solution that checks if you are in a Windows or posix-like (Linux/Unix/Cygwin/Mac) environment:ifeq ($(shell echo "check_quotes"),"check_quotes") WINDOWS := yeselse WINDOWS := noendifIt...
View ArticleAnswer by oHo for OS detecting makefile
Detect the operating system using two simple tricks:First the environment variable OSThen the uname commandifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10... detected_OS :=...
View ArticleAnswer by phsym for OS detecting makefile
I was recently experimenting in order to answer this question I was asking myself. Here are my conclusions:Since in Windows, you can't be sure that the uname command is available, you can use gcc...
View ArticleAnswer by Trevor Robinson for OS detecting makefile
There are many good answers here already, but I wanted to share a more complete example that both:doesn't assume uname exists on Windowsalso detects the processorThe CCFLAGS defined here aren't...
View ArticleAnswer by Ken Jackson for OS detecting makefile
Update: I now consider this answer to be obsolete. I posted a new perfect solution further down.If your makefile may be running on non-Cygwin Windows, uname may not be available. That's awkward, but...
View ArticleAnswer by Huckle for OS detecting makefile
I ran into this problem today and I needed it on Solaris so here is a POSIX standard way to do (something very close to) this. #Detect OSUNAME = `uname`# Build based on OS nameDetectOS: -@make...
View ArticleAnswer by Sean for OS detecting makefile
Another way to do this is by using a "configure" script. If you are already using one with your makefile, you can use a combination of uname and sed to get things to work out. First, in your script,...
View ArticleAnswer by ChrisInEdmonton for OS detecting makefile
Note that Makefiles are extremely sensitive to spacing. Here's an example of a Makefile that runs an extra command on OS X and which works on OS X and Linux. Overall, though, autoconf/automake is the...
View ArticleAnswer by JesperE for OS detecting makefile
The git makefile contains numerous examples of how to manage without autoconf/automake, yet still work on a multitude of unixy platforms.
View ArticleAnswer by dbrown0708 for OS detecting makefile
The uname command (http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/uname.1.html) with no parameters should tell you the operating system name. I'd use that, then make...
View ArticleAnswer by Douglas Leeder for OS detecting makefile
That's the job that GNU's automake/autoconf are designed to solve. You might want to investigate them.Alternatively you can set environment variables on your different platforms and make you Makefile...
View ArticleOS detecting makefile
I routinely work on several different computers and several different operating systems, which are Mac OS X, Linux, or Solaris. For the project I'm working on, I pull my code from a remote git...
View Article