Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
| 4 | * Copyright (C) 2011 Carl-Daniel Hailfinger |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | /* |
| 21 | * Header file for OS checking. |
| 22 | */ |
| 23 | |
Stefan Tauner | b0eee9b | 2015-01-10 09:32:50 +0000 | [diff] [blame] | 24 | #include "platform.h" |
| 25 | |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 26 | // Solaris |
| 27 | #if defined (__sun) && (defined(__i386) || defined(__amd64)) |
| 28 | #define __FLASHROM_OS__ "SunOS" |
| 29 | // OS X |
| 30 | #elif defined(__MACH__) && defined(__APPLE__) |
| 31 | #define __FLASHROM_OS__ "Darwin" |
| 32 | // FreeBSD |
| 33 | #elif defined(__FreeBSD__) |
| 34 | #define __FLASHROM_OS__ "FreeBSD" |
Carl-Daniel Hailfinger | a5eecda | 2012-02-25 22:50:21 +0000 | [diff] [blame] | 35 | // FreeBSD with glibc-based userspace (e.g. Debian/kFreeBSD) |
| 36 | #elif defined(__FreeBSD_kernel__) && defined(__GLIBC__) |
| 37 | #define __FLASHROM_OS__ "FreeBSD-glibc" |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 38 | // DragonFlyBSD |
| 39 | #elif defined(__DragonFly__) |
| 40 | #define __FLASHROM_OS__ "DragonFlyBSD" |
| 41 | // NetBSD |
| 42 | #elif defined(__NetBSD__) |
| 43 | #define __FLASHROM_OS__ "NetBSD" |
| 44 | // OpenBSD |
| 45 | #elif defined(__OpenBSD__) |
| 46 | #define __FLASHROM_OS__ "OpenBSD" |
| 47 | // DJGPP |
| 48 | #elif defined(__DJGPP__) |
| 49 | #define __FLASHROM_OS__ "DOS" |
| 50 | // MinGW (always has _WIN32 available) |
| 51 | #elif defined(__MINGW32__) |
| 52 | #define __FLASHROM_OS__ "MinGW" |
| 53 | // Cygwin (usually without _WIN32) |
| 54 | #elif defined( __CYGWIN__) |
| 55 | #define __FLASHROM_OS__ "Cygwin" |
| 56 | // libpayload |
| 57 | #elif defined(__LIBPAYLOAD__) |
| 58 | #define __FLASHROM_OS__ "libpayload" |
Stefan Tauner | 8e65654 | 2016-03-06 22:32:16 +0000 | [diff] [blame] | 59 | // GNU Hurd |
| 60 | #elif defined(__gnu_hurd__) |
| 61 | #define __FLASHROM_OS__ "Hurd" |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 62 | // Linux |
| 63 | #elif defined(__linux__) |
Stefan Tauner | 23e10b8 | 2016-01-23 16:16:49 +0000 | [diff] [blame] | 64 | // There are various flags in use on Android apparently. __ANDROID__ seems to be the most trustworthy. |
| 65 | #if defined(__ANDROID__) |
| 66 | #define __FLASHROM_OS__ "Android" |
| 67 | #else |
| 68 | #define __FLASHROM_OS__ "Linux" |
| 69 | #endif |
Carl-Daniel Hailfinger | 33a65a0 | 2011-12-20 00:51:44 +0000 | [diff] [blame] | 70 | #endif |
| 71 | __FLASHROM_OS__ |