Nico Huber submitted this change.
buildsystem: evaluate the USE_IOPL, USE_DEV_IO, USE_IOPERM macros
Determine which macro has to be set for the target system.
Do this in the buildsystem instead of using preprocessor macros.
Change-Id: Ic41ea025e35feb93f07ce7a94c0d15e6e84f38b9
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58278
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M Makefile
M hwaccess.c
M meson.build
3 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/Makefile b/Makefile
index 31d4025..18651bc 100644
--- a/Makefile
+++ b/Makefile
@@ -278,6 +278,25 @@
$(call mark_unsupported,CONFIG_NICINTEL_EEPROM CONFIG_OGP_SPI CONFIG_IT8212)
endif
+ifeq ($(TARGET_OS), $(filter $(TARGET_OS), Linux Darwin NetBSD OpenBSD))
+FEATURE_CFLAGS += -D'USE_IOPL=1'
+else
+FEATURE_CFLAGS += -D'USE_IOPL=0'
+endif
+
+ifeq ($(TARGET_OS), $(filter $(TARGET_OS), FreeBSD FreeBSD-glibc DragonFlyBSD))
+FEATURE_CFLAGS += -D'USE_DEV_IO=1'
+else
+FEATURE_CFLAGS += -D'USE_DEV_IO=0'
+endif
+
+ifeq ($(TARGET_OS), $(filter $(TARGET_OS), Hurd))
+FEATURE_CFLAGS += -D'USE_IOPERM=1'
+else
+FEATURE_CFLAGS += -D'USE_IOPERM=0'
+endif
+
+
###############################################################################
# Flash chip drivers and bus support infrastructure.
diff --git a/hwaccess.c b/hwaccess.c
index aa35f4b..13bacd7 100644
--- a/hwaccess.c
+++ b/hwaccess.c
@@ -30,26 +30,6 @@
#include "programmer.h"
#include "hwaccess.h"
-#if !(defined(__gnu_linux__) || defined(__linux__) || defined(__APPLE__) && defined(__MACH__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__DJGPP__) || defined(__LIBPAYLOAD__) || defined(__sun) || defined(__gnu_hurd__))
-#error "Unknown operating system"
-#endif
-
-#if defined(__gnu_linux__) || defined(__linux__) || defined(__APPLE__) && defined(__MACH__) || defined(__NetBSD__) || defined(__OpenBSD__)
-#define USE_IOPL 1
-#else
-#define USE_IOPL 0
-#endif
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
-#define USE_DEV_IO 1
-#else
-#define USE_DEV_IO 0
-#endif
-#if defined(__gnu_hurd__)
-#define USE_IOPERM 1
-#else
-#define USE_IOPERM 0
-#endif
-
#if USE_IOPERM
#include <sys/io.h>
#endif
diff --git a/meson.build b/meson.build
index a971a6a..86657ce 100644
--- a/meson.build
+++ b/meson.build
@@ -42,6 +42,24 @@
add_project_arguments('-DIS_WINDOWS=0', language : 'c')
endif
+if host_machine.system() in ['linux', 'darwin', 'netbsd', 'openbsd']
+ add_project_arguments('-DUSE_IOPL=1', language : 'c')
+else
+ add_project_arguments('-DUSE_IOPL=0', language : 'c')
+endif
+
+if host_machine.system() in ['freebsd', 'dragonfly']
+ add_project_arguments('-DUSE_DEV_IO=1', language : 'c')
+else
+ add_project_arguments('-DUSE_DEV_IO=0', language : 'c')
+endif
+
+if host_machine.system() in ['gnu']
+ add_project_arguments('-DUSE_IOPERM=1', language : 'c')
+else
+ add_project_arguments('-DUSE_IOPERM=0', language : 'c')
+endif
+
# get defaults from configure
config_atahpt = get_option('config_atahpt')
config_atapromise = get_option('config_atapromise')
To view, visit change 58278. To unsubscribe, or for help writing mail filters, visit settings.