diff options
Diffstat (limited to 'Makefile.d')
-rw-r--r-- | Makefile.d/arch_test.h | 55 | ||||
-rw-r--r-- | Makefile.d/cc_test.c | 6 | ||||
-rw-r--r-- | Makefile.d/clock_gettime_test.c | 9 | ||||
-rw-r--r-- | Makefile.d/endian_test.h | 89 | ||||
-rw-r--r-- | Makefile.d/ft232h_test.c | 3 | ||||
-rw-r--r-- | Makefile.d/linux_i2c_test.c | 9 | ||||
-rw-r--r-- | Makefile.d/linux_mtd_test.c | 8 | ||||
-rw-r--r-- | Makefile.d/linux_spi_test.c | 9 | ||||
-rw-r--r-- | Makefile.d/os_test.h | 67 | ||||
-rw-r--r-- | Makefile.d/utsname_test.c | 9 |
10 files changed, 264 insertions, 0 deletions
diff --git a/Makefile.d/arch_test.h b/Makefile.d/arch_test.h new file mode 100644 index 000000000..654f8e562 --- /dev/null +++ b/Makefile.d/arch_test.h @@ -0,0 +1,55 @@ +/* + * This file is part of the flashrom project. + * + * Copyright (C) 2011 Carl-Daniel Hailfinger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/* + * This file determinate the target architecture. It should only be used + * by the Makefile + */ + +#if defined (__i386__) || defined (__x86_64__) || defined(__amd64__) + #define __FLASHROM_ARCH__ "x86" +#elif defined (__mips) || defined (__mips__) || defined (__MIPS__) || defined (mips) + #define __FLASHROM_ARCH__ "mips" +#elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) || defined(__POWERPC__) || \ + defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC) || defined(_ARCH_PPC) || \ + defined(_ARCH_PPC64) || defined(__ppc) + #define __FLASHROM_ARCH__ "ppc" +#elif defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_ARM) || defined(_M_ARM) || defined(__arm) || \ + defined(__aarch64__) + #define __FLASHROM_ARCH__ "arm" +#elif defined (__sparc__) || defined (__sparc) + #define __FLASHROM_ARCH__ "sparc" +#elif defined (__alpha__) + #define __FLASHROM_ARCH__ "alpha" +#elif defined (__hppa__) || defined (__hppa) + #define __FLASHROM_ARCH__ "hppa" +#elif defined (__m68k__) + #define __FLASHROM_ARCH__ "m68k" +#elif defined (__riscv) + #define __FLASHROM_ARCH__ "riscv" +#elif defined (__sh__) + #define __FLASHROM_ARCH__ "sh" +#elif defined(__s390__) || defined(__s390x__) || defined(__zarch__) + #define __FLASHROM_ARCH__ "s390" +#elif defined(__arc__) + #define __FLASHROM_ARCH__ "arc" +#elif defined(__ARC64__) + #define __FLASHROM_ARCH__ "arc64" +#elif defined(__e2k__) + #define __FLASHROM_ARCH__ "e2k" +#else + #define __FLASHROM_ARCH__ "unknown" +#endif +__FLASHROM_ARCH__ diff --git a/Makefile.d/cc_test.c b/Makefile.d/cc_test.c new file mode 100644 index 000000000..0610964d8 --- /dev/null +++ b/Makefile.d/cc_test.c @@ -0,0 +1,6 @@ +int main(int argc, char **argv) +{ + (void)argc; + (void)argv; + return 0; +} diff --git a/Makefile.d/clock_gettime_test.c b/Makefile.d/clock_gettime_test.c new file mode 100644 index 000000000..000aa425f --- /dev/null +++ b/Makefile.d/clock_gettime_test.c @@ -0,0 +1,9 @@ +#include <time.h> +int main(int argc, char **argv) +{ + (void)argc; + (void)argv; + struct timespec res; + clock_gettime(CLOCK_REALTIME, &res); + return 0; +} diff --git a/Makefile.d/endian_test.h b/Makefile.d/endian_test.h new file mode 100644 index 000000000..36658b318 --- /dev/null +++ b/Makefile.d/endian_test.h @@ -0,0 +1,89 @@ +/* + * This file is part of the flashrom project. + * + * Copyright (C) 2011 Carl-Daniel Hailfinger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/* + * This file determinate the target endian. It should only be used my the Makefile + */ + +#if defined (__i386__) || defined (__x86_64__) || defined(__amd64__) +/* All x86 is little-endian. */ +#define __FLASHROM_LITTLE_ENDIAN__ 1 +#elif defined (__mips) || defined (__mips__) || defined (__MIPS__) || defined (mips) +/* MIPS can be either endian. */ +#if defined (__MIPSEL) || defined (__MIPSEL__) || defined (_MIPSEL) || defined (MIPSEL) +#define __FLASHROM_LITTLE_ENDIAN__ 1 +#elif defined (__MIPSEB) || defined (__MIPSEB__) || defined (_MIPSEB) || defined (MIPSEB) +#define __FLASHROM_BIG_ENDIAN__ 1 +#endif +#elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) || defined(__POWERPC__) || \ + defined(__ppc__) || defined(__ppc64__) || defined(_M_PPC) || defined(_ARCH_PPC) || \ + defined(_ARCH_PPC64) || defined(__ppc) +/* PowerPC can be either endian. */ +#if defined (_BIG_ENDIAN) || defined (__BIG_ENDIAN__) +#define __FLASHROM_BIG_ENDIAN__ 1 +#elif defined (_LITTLE_ENDIAN) || defined (__LITTLE_ENDIAN__) +#define __FLASHROM_LITTLE_ENDIAN__ 1 +#endif +#elif defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_ARM) || defined(_M_ARM) || defined(__arm) || \ + defined(__aarch64__) +/* ARM can be either endian. */ +#if defined (__ARMEB__) || defined (__BIG_ENDIAN__) +#define __FLASHROM_BIG_ENDIAN__ 1 +#elif defined (__ARMEL__) || defined (__LITTLE_ENDIAN__) +#define __FLASHROM_LITTLE_ENDIAN__ 1 +#endif +#elif defined (__sparc__) || defined (__sparc) +/* SPARC is big endian in general (but allows to access data in little endian too). */ +#define __FLASHROM_BIG_ENDIAN__ 1 +#elif defined(__arc__) +#if defined(__BIG_ENDIAN__) +#define __FLASHROM_BIG_ENDIAN__ 1 +#else +#define __FLASHROM_LITTLE_ENDIAN__ 1 +#endif +#endif + +#if !defined (__FLASHROM_BIG_ENDIAN__) && !defined (__FLASHROM_LITTLE_ENDIAN__) +/* If architecture-specific approaches fail try generic variants. First: BSD (works about everywhere). */ +#if !(defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__WINDOWS__)) +#include <sys/param.h> +#if defined (__BYTE_ORDER) +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define __FLASHROM_LITTLE_ENDIAN__ +#elif __BYTE_ORDER == __BIG_ENDIAN +#define __FLASHROM_BIG_ENDIAN__ +#else +#error Unknown byte order! +#endif +#endif /* defined __BYTE_ORDER */ +#endif /* !IS_WINDOWS */ +#if !defined (__FLASHROM_BIG_ENDIAN__) && !defined (__FLASHROM_LITTLE_ENDIAN__) +/* Nonstandard libc-specific macros for determining endianness. */ +/* musl provides an endian.h as well... but it can not be detected from within C. */ +#if defined(__GLIBC__) +#include <endian.h> +#if BYTE_ORDER == LITTLE_ENDIAN +#define __FLASHROM_LITTLE_ENDIAN__ 1 +#elif BYTE_ORDER == BIG_ENDIAN +#define __FLASHROM_BIG_ENDIAN__ 1 +#endif +#endif +#endif +#endif +#if defined(__FLASHROM_LITTLE_ENDIAN__) +"little" +#else +"big" +#endif diff --git a/Makefile.d/ft232h_test.c b/Makefile.d/ft232h_test.c new file mode 100644 index 000000000..21bc99589 --- /dev/null +++ b/Makefile.d/ft232h_test.c @@ -0,0 +1,3 @@ +#include <ftdi.h> + +enum ftdi_chip_type type = TYPE_232H;
\ No newline at end of file diff --git a/Makefile.d/linux_i2c_test.c b/Makefile.d/linux_i2c_test.c new file mode 100644 index 000000000..768226bab --- /dev/null +++ b/Makefile.d/linux_i2c_test.c @@ -0,0 +1,9 @@ +#include <linux/i2c-dev.h> +#include <linux/i2c.h> + +int main(int argc, char **argv) +{ + (void)argc; + (void)argv; + return 0; +} diff --git a/Makefile.d/linux_mtd_test.c b/Makefile.d/linux_mtd_test.c new file mode 100644 index 000000000..d254e242c --- /dev/null +++ b/Makefile.d/linux_mtd_test.c @@ -0,0 +1,8 @@ +#include <mtd/mtd-user.h> + +int main(int argc, char **argv) +{ + (void)argc; + (void)argv; + return 0; +} diff --git a/Makefile.d/linux_spi_test.c b/Makefile.d/linux_spi_test.c new file mode 100644 index 000000000..a4d265786 --- /dev/null +++ b/Makefile.d/linux_spi_test.c @@ -0,0 +1,9 @@ +#include <linux/types.h> +#include <linux/spi/spidev.h> + +int main(int argc, char **argv) +{ + (void)argc; + (void)argv; + return 0; +} diff --git a/Makefile.d/os_test.h b/Makefile.d/os_test.h new file mode 100644 index 000000000..17045b254 --- /dev/null +++ b/Makefile.d/os_test.h @@ -0,0 +1,67 @@ +/* + * This file is part of the flashrom project. + * + * Copyright (C) 2011 Carl-Daniel Hailfinger + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +/* + * This file determinate the target os. It should only be used my the Makefile + */ + +// Solaris +#if defined (__sun) && (defined(__i386) || defined(__amd64)) +#define __FLASHROM_OS__ "SunOS" +// OS X +#elif defined(__MACH__) && defined(__APPLE__) +#define __FLASHROM_OS__ "Darwin" +// FreeBSD +#elif defined(__FreeBSD__) +#define __FLASHROM_OS__ "FreeBSD" +// FreeBSD with glibc-based userspace (e.g. Debian/kFreeBSD) +#elif defined(__FreeBSD_kernel__) && defined(__GLIBC__) +#define __FLASHROM_OS__ "FreeBSD-glibc" +// DragonFlyBSD +#elif defined(__DragonFly__) +#define __FLASHROM_OS__ "DragonFlyBSD" +// NetBSD +#elif defined(__NetBSD__) +#define __FLASHROM_OS__ "NetBSD" +// OpenBSD +#elif defined(__OpenBSD__) +#define __FLASHROM_OS__ "OpenBSD" +// DJGPP +#elif defined(__DJGPP__) +#define __FLASHROM_OS__ "DOS" +// MinGW (always has _WIN32 available) +#elif defined(__MINGW32__) +#define __FLASHROM_OS__ "MinGW" +// Cygwin (usually without _WIN32) +#elif defined( __CYGWIN__) +#define __FLASHROM_OS__ "Cygwin" +// libpayload +#elif defined(__LIBPAYLOAD__) +#define __FLASHROM_OS__ "libpayload" +// GNU Hurd +#elif defined(__gnu_hurd__) +#define __FLASHROM_OS__ "Hurd" +// Linux +#elif defined(__linux__) + // There are various flags in use on Android apparently. __ANDROID__ seems to be the most trustworthy. + #if defined(__ANDROID__) + #define __FLASHROM_OS__ "Android" + #else + #define __FLASHROM_OS__ "Linux" + #endif +#else +#define __FLASHROM_OS__ "unknown" +#endif +__FLASHROM_OS__ diff --git a/Makefile.d/utsname_test.c b/Makefile.d/utsname_test.c new file mode 100644 index 000000000..7bc666527 --- /dev/null +++ b/Makefile.d/utsname_test.c @@ -0,0 +1,9 @@ +#include <sys/utsname.h> +struct utsname osinfo; +int main(int argc, char **argv) +{ + (void)argc; + (void)argv; + uname(&osinfo); + return 0; +} |