Powoli
Powoli

Reputation: 23

How in 'make' check the current operating system is?

I have two different options in gcc. In linux is one in Mac other

How check in makefile what system current is? Windows, Linux, or OSX

Upvotes: 0

Views: 213

Answers (3)

Powoli
Powoli

Reputation: 23

Simple add this in Makefile:

ifeq ($(UNAME_S),Linux)
 OPCJE = -Wall -Wno-unused-const-variable
else
 OPCJE = -Wall
endif

Upvotes: 0

Norman Gray
Norman Gray

Reputation: 12514

If you're doing this with the intention of distributing software, then rather than tweak Makefiles internally (there is no good solution to this; I wouldn't even try), you should investigate a build system which allows users to configure the build dynamically.

The most common mechanism for that is autoconf. Autoconf is a little tricky to get started with – there's a non-trivial learning curve, but it's in reality somewhat simpler than it looks at first – but it has the advantage that use of autoconf is very widespread. If people are building a bit of software from source, they're rarely surprised to see a configure script, at which point their fingers automatically tap out ./configure; make; make install.

The Wikipedia page on autoconf actually makes it look rather harder than it is, because the diagram displays the full-blown autoconf+automake+autoheader+aclocal ecosystem (what, they missed out libtool?!). That page also rather goes to town on its ‘Criticism’ of autoconf. While none of the points it makes are actually false, their importance is rather overstated.

Upvotes: 0

Matt O
Matt O

Reputation: 1346

You can use built in shell commands such as uname (on Unix systems) and parse the output. There's no built in functionality for it.

Upvotes: 1

Related Questions