mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-26 22:52:34 +02:00
Remove dependency on C23 __has_include()
Use build system to check header presence: * getopt.h (from include/cli_classic.h) * pciutils/pci.h (from include/platform/pci.h) Tested with <getopt.h> and <pci/pci.h> using GNU Make 4.1, 4.2.1, 4.4.1 and Meson 0.56.0, 1.2.1 against GCC 13.2.1 and GCC 5.5-, 7.3-compatible (EDG 4.14-, 5.1-based) on openSuSE Tumbleweed and a custom LFS distro. Change-Id: Ic544963ffd29626ae0a21bdddb1c78850cc43ec6 Signed-off-by: Anton Samsonov <devel@zxlab.ru> Reviewed-on: https://review.coreboot.org/c/flashrom/+/77089 Reviewed-by: Alexander Goncharov <chat@joursoir.net> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
bda8361453
commit
8efe4fb708
12
Makefile
12
Makefile
@ -242,6 +242,7 @@ HAS_LIBJAYLINK := $(call find_dependency, libjaylink)
|
||||
HAS_LIBUSB1 := $(call find_dependency, libusb-1.0)
|
||||
HAS_LIBPCI := $(call find_dependency, libpci)
|
||||
|
||||
HAS_GETOPT := $(call c_compile_test, Makefile.d/getopt_test.c)
|
||||
HAS_FT232H := $(call c_compile_test, Makefile.d/ft232h_test.c, $(CONFIG_LIBFTDI1_CFLAGS))
|
||||
HAS_UTSNAME := $(call c_compile_test, Makefile.d/utsname_test.c)
|
||||
HAS_CLOCK_GETTIME := $(call c_compile_test, Makefile.d/clock_gettime_test.c)
|
||||
@ -249,6 +250,7 @@ HAS_EXTERN_LIBRT := $(call c_link_test, Makefile.d/clock_gettime_test.c, , -l
|
||||
HAS_LINUX_MTD := $(call c_compile_test, Makefile.d/linux_mtd_test.c)
|
||||
HAS_LINUX_SPI := $(call c_compile_test, Makefile.d/linux_spi_test.c)
|
||||
HAS_LINUX_I2C := $(call c_compile_test, Makefile.d/linux_i2c_test.c)
|
||||
HAS_PCIUTILS := $(call c_compile_test, Makefile.d/pciutils_test.c)
|
||||
HAS_SERIAL := $(strip $(if $(filter $(TARGET_OS), DOS libpayload), no, yes))
|
||||
HAS_SPHINXBUILD := $(shell command -v $(SPHINXBUILD) >/dev/null 2>/dev/null && echo yes || echo no)
|
||||
EXEC_SUFFIX := $(strip $(if $(filter $(TARGET_OS), DOS MinGW), .exe))
|
||||
@ -945,6 +947,14 @@ override LDFLAGS += -lrt
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(HAS_GETOPT), yes)
|
||||
override CFLAGS += -D'HAVE_GETOPT_H=1'
|
||||
endif
|
||||
|
||||
ifeq ($(HAS_PCIUTILS), yes)
|
||||
override CFLAGS += -D'HAVE_PCIUTILS_PCI_H=1'
|
||||
endif
|
||||
|
||||
OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
|
||||
|
||||
|
||||
@ -994,11 +1004,13 @@ config:
|
||||
echo " CFLAGS: $(CONFIG_LIBFTDI1_CFLAGS)"; \
|
||||
echo " LDFLAGS: $(CONFIG_LIBFTDI1_LDFLAGS)"; \
|
||||
fi
|
||||
@echo "Checking for header \"getopt.h\": $(HAS_GETOPT)"
|
||||
@echo "Checking for header \"mtd/mtd-user.h\": $(HAS_LINUX_MTD)"
|
||||
@echo "Checking for header \"linux/spi/spidev.h\": $(HAS_LINUX_SPI)"
|
||||
@echo "Checking for header \"linux/i2c-dev.h\": $(HAS_LINUX_I2C)"
|
||||
@echo "Checking for header \"linux/i2c.h\": $(HAS_LINUX_I2C)"
|
||||
@echo "Checking for header \"sys/utsname.h\": $(HAS_UTSNAME)"
|
||||
@echo "Checking for header \"pciutils/pci.h\": $(HAS_PCIUTILS)"
|
||||
@echo "Checking for function \"clock_gettime\": $(HAS_CLOCK_GETTIME)"
|
||||
@echo "Checking for external \"librt\": $(HAS_EXTERN_LIBRT)"
|
||||
@if ! [ "$(PROGRAMMER_OBJS)" ]; then \
|
||||
|
8
Makefile.d/getopt_test.c
Normal file
8
Makefile.d/getopt_test.c
Normal file
@ -0,0 +1,8 @@
|
||||
#include <getopt.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
return 0;
|
||||
}
|
8
Makefile.d/pciutils_test.c
Normal file
8
Makefile.d/pciutils_test.c
Normal file
@ -0,0 +1,8 @@
|
||||
#include <pciutils/pci.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
return 0;
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
#ifndef CLI_CLASSIC_H
|
||||
#define CLI_CLASSIC_H
|
||||
|
||||
#if __has_include(<getopt.h>)
|
||||
#ifdef HAVE_GETOPT_H
|
||||
#include <getopt.h>
|
||||
#else
|
||||
|
||||
@ -39,5 +39,5 @@ int getopt_long (int argc, char *const *argv, const char *shortopts,
|
||||
int getopt_long_only (int argc, char *const *argv, const char *shortopts,
|
||||
const struct option *longopts, int *longind);
|
||||
|
||||
#endif /* __has_include() */
|
||||
#endif /* HAVE_GETOPT_H */
|
||||
#endif /* CLI_CLASSIC_H */
|
||||
|
@ -22,10 +22,10 @@
|
||||
* e.g. NetBSD 9.0 on sparc64 pciutils-3.7.0nb2.
|
||||
* Other NetBSD platforms and versions uses the default path under pci/pci.h
|
||||
*/
|
||||
#if __has_include(<pciutils/pci.h>)
|
||||
#ifdef HAVE_PCIUTILS_PCI_H
|
||||
#include <pciutils/pci.h>
|
||||
#else
|
||||
#include <pci/pci.h>
|
||||
#endif
|
||||
#endif /* HAVE_PCIUTILS_PCI_H */
|
||||
|
||||
#endif /* __PLATFORM_PCI_H__ */
|
||||
|
@ -114,6 +114,12 @@ endif
|
||||
if cc.has_function('strnlen')
|
||||
add_project_arguments('-DHAVE_STRNLEN=1', language : 'c')
|
||||
endif
|
||||
if cc.check_header('getopt.h')
|
||||
add_project_arguments('-DHAVE_GETOPT_H=1', language : 'c')
|
||||
endif
|
||||
if cc.check_header('pciutils/pci.h')
|
||||
add_project_arguments('-DHAVE_PCIUTILS_PCI_H=1', language : 'c')
|
||||
endif
|
||||
if cc.check_header('sys/utsname.h')
|
||||
add_project_arguments('-DHAVE_UTSNAME=1', language : 'c')
|
||||
endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user