os-detection

Makefile that distincts between Windows and Unix-like systems

半城伤御伤魂 提交于 2019-11-27 17:12:58
I would like to have the same Makefile for building on Linux and on Windows. I use the default GNU make on Linux and the mingw32-make (also GNU make ) on Windows. I want the Makefile to detect whether it operates on Windows or Linux. For example make clean command on Windows looks like: clean: del $(DESTDIR_TARGET) But on Linux: clean: rm $(DESTDIR_TARGET) Also I would like to use different directory separator on Windows ( \ ) and Linux ( / ). It is possible to detect Windows operating system in Makefile? PS: I do not want to emulate Linux on Windows (cygwin etc.) There is similiar question:

Get users OS and version number

假装没事ソ 提交于 2019-11-27 02:49:17
问题 I've spent a day on and off Googeling for this; no luck so far. How can I get the users OS and version. Mine would me Mac OS X 10.6.4, the spare PC in the office would be Windows XP SP3. You see what I'm getting at. I've seen a million and one methods to get the users platform alone, just not the version. JS would be ideal, but a server-side (PHP) solution is OK too. 回答1: <?php $user_agent = $_SERVER['HTTP_USER_AGENT']; function getOS() { global $user_agent; $os_platform = "Unknown OS

Makefile that distincts between Windows and Unix-like systems

限于喜欢 提交于 2019-11-26 18:56:30
问题 I would like to have the same Makefile for building on Linux and on Windows. I use the default GNU make on Linux and the mingw32-make (also GNU make ) on Windows. I want the Makefile to detect whether it operates on Windows or Linux. For example make clean command on Windows looks like: clean: del $(DESTDIR_TARGET) But on Linux: clean: rm $(DESTDIR_TARGET) Also I would like to use different directory separator on Windows ( \ ) and Linux ( / ). It is possible to detect Windows operating system

How to detect the OS from a Bash script?

混江龙づ霸主 提交于 2019-11-26 01:09:47
问题 I would like to keep my .bashrc and .bash_login files in version control so that I can use them between all the computers I use. The problem is I have some OS specific aliases so I was looking for a way to determine if the script is running on Mac OS X, Linux or Cygwin. What is the proper way to detect the operating system in a Bash script? 回答1: I think the following should work. I'm not sure about win32 though. if [[ "$OSTYPE" == "linux-gnu" ]]; then # ... elif [[ "$OSTYPE" == "darwin"* ]];

OS detecting makefile

老子叫甜甜 提交于 2019-11-26 00:56:27
问题 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 repository. I like to be able to work on my projects regardless of which terminal I\'m at. So far, I\'ve found ways to get around the OS changes by changing the makefile every time I switch computers. However, this is tedious and causes a bunch of headaches. How can I modify my makefile so that it

How to detect reliably Mac OS X, iOS, Linux, Windows in C preprocessor? [duplicate]

时光总嘲笑我的痴心妄想 提交于 2019-11-26 00:24:32
问题 This question already has answers here : How do I check OS with a preprocessor directive? (16 answers) Closed 6 months ago . If there\'s some cross-platform C/C++ code that should be compiled on Mac OS X, iOS, Linux, Windows, how can I detect them reliably during preprocessor process? 回答1: There are predefined macros that are used by most compilers, you can find the list here. GCC compiler predefined macros can be found here. Here is an example for gcc: #if defined(WIN32) || defined(_WIN32) |