Thomas Heijligen has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/58627 )
Change subject: Makefile: Revise build options for Linux specific headers ......................................................................
Makefile: Revise build options for Linux specific headers
Clean up the feature target by outsourcing the test to an own variable. Change the print output and don't write to the build-details file.
This is in preparation for further changes.
Change-Id: I18fc27252afb49fa7d1f2787faee2b5b669275aa Signed-off-by: Thomas Heijligen thomas.heijligen@secunet.com --- M Makefile A Makefile.d/linux_i2c_test.c A Makefile.d/linux_mtd_test.c A Makefile.d/linux_spi_test.c M Makefile.include 5 files changed, 50 insertions(+), 78 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/27/58627/1
diff --git a/Makefile b/Makefile index a5e3d92..a19897c 100644 --- a/Makefile +++ b/Makefile @@ -170,6 +170,9 @@
HAS_UTSNAME := $(call c_compile_test, Makefile.d/utsname_test.c) HAS_CLOCK_GETTIME := $(call c_compile_test, Makefile.d/clock_gettime_test.c) +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)
ifeq ($(TARGET_OS), $(filter $(TARGET_OS), FreeBSD OpenBSD DragonFlyBSD)) override CPPFLAGS += -I/usr/local/include @@ -245,15 +248,23 @@ $(call mark_unsupported,CONFIG_MSTARDDC_SPI CONFIG_LSPCON_I2C_SPI CONFIG_REALTEK_MST_I2C_SPI) endif
+ifeq ($(HAS_LINUX_MTD), no) +$(call mark_unsupported,CONFIG_LINUX_MTD) +endif + +ifeq ($(HAS_LINUX_SPI), no) +$(call mark_unsupported,CONFIG_LINUX_SPI) +endif + +ifeq ($(HAS_LINUX_I2C), no) +$(call mark_unsupported,CONFIG_MSTARDDC_SPI) +endif + ifeq ($(TARGET_OS), Android) # Android on x86 (currently) does not provide raw PCI port I/O operations. $(call mark_unsupported,CONFIG_RAYER_SPI) endif
-ifeq ($(TARGET_OS), Linux) -CONFIG_LINUX_I2C_HELPER = yes -endif - # Disable the internal programmer on unsupported architectures (everything but x86 and mipsel) ifneq ($(ARCH)-little, $(filter $(ARCH), x86 mips)-$(ENDIAN)) $(call mark_unsupported,CONFIG_INTERNAL) @@ -679,21 +690,18 @@ endif
ifeq ($(CONFIG_LINUX_MTD), yes) -# This is a totally ugly hack. -FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_MTD_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_LINUX_MTD=1'") +FEATURE_CFLAGS += -D'CONFIG_LINUX_MTD=1' PROGRAMMER_OBJS += linux_mtd.o endif
ifeq ($(CONFIG_LINUX_SPI), yes) # This is a totally ugly hack. -FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_SPI_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_LINUX_SPI=1'") +FEATURE_CFLAGS += -D'CONFIG_LINUX_SPI=1' PROGRAMMER_OBJS += linux_spi.o endif
ifeq ($(CONFIG_MSTARDDC_SPI), yes) -# This is a totally ugly hack. -FEATURE_CFLAGS += $(call debug_shell,grep -q "LINUX_I2C_SUPPORT := yes" .features && printf "%s" "-D'CONFIG_MSTARDDC_SPI=1'") -NEED_LINUX_I2C += CONFIG_MSTARDDC_SPI +FEATURE_CFLAGS += -D'CONFIG_MSTARDDC_SPI=1' PROGRAMMER_OBJS += mstarddc_spi.o endif
@@ -741,7 +749,7 @@ PROGRAMMER_OBJS += ni845x_spi.o endif
-ifeq ($(CONFIG_LINUX_I2C_HELPER), yes) +ifeq ($(HAS_LINUX_I2C), yes) LIB_OBJS += i2c_helper_linux.o FEATURE_CFLAGS += -D'CONFIG_I2C_SUPPORT=1' endif @@ -1025,33 +1033,6 @@ ( echo "not found."; echo "FTDISUPPORT := no" >> .features.tmp ) } \ 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE) endif -ifeq ($(CONFIG_LINUX_MTD), yes) - @printf "Checking if Linux MTD headers are present... " | tee -a $(BUILD_DETAILS_FILE) - @echo "$$LINUX_MTD_TEST" > .featuretest.c - @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE) - @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \ - ( echo "yes."; echo "LINUX_MTD_SUPPORT := yes" >> .features.tmp ) || \ - ( echo "no."; echo "LINUX_MTD_SUPPORT := no" >> .features.tmp ) } \ - 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE) -endif -ifeq ($(CONFIG_LINUX_SPI), yes) - @printf "Checking if Linux SPI headers are present... " | tee -a $(BUILD_DETAILS_FILE) - @echo "$$LINUX_SPI_TEST" > .featuretest.c - @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE) - @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \ - ( echo "yes."; echo "LINUX_SPI_SUPPORT := yes" >> .features.tmp ) || \ - ( echo "no."; echo "LINUX_SPI_SUPPORT := no" >> .features.tmp ) } \ - 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE) -endif -ifneq ($(NEED_LINUX_I2C), ) - @printf "Checking if Linux I2C headers are present... " | tee -a $(BUILD_DETAILS_FILE) - @echo "$$LINUX_I2C_TEST" > .featuretest.c - @printf "\nexec: %s\n" "$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX)" >>$(BUILD_DETAILS_FILE) - @ { $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .featuretest.c -o .featuretest$(EXEC_SUFFIX) >&2 && \ - ( echo "yes."; echo "LINUX_I2C_SUPPORT := yes" >> .features.tmp ) || \ - ( echo "no."; echo "LINUX_I2C_SUPPORT := no" >> .features.tmp ) } \ - 2>>$(BUILD_DETAILS_FILE) | tee -a $(BUILD_DETAILS_FILE) -endif ifeq ($(CONFIG_NI845X_SPI), yes) @printf "Checking for NI USB-845x installation... " | tee -a $(BUILD_DETAILS_FILE) @echo "$$NI845X_TEST" > .featuretest.c @@ -1068,10 +1049,14 @@ exit 1; }; } \ 2>>$(BUILD_DETAILS_FILE); echo $? >&3 ; } | tee -a $(BUILD_DETAILS_FILE) >&4; } 3>&1;} | { read rc ; exit ${rc}; } } 4>&1 endif - @echo "Checking for header "sys/utsname.h": $(HAS_UTSNAME)" - @echo "Checking for function "clock_gettime": $(HAS_CLOCK_GETTIME)" @$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features @rm -f .featuretest.c .featuretest$(EXEC_SUFFIX) + @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 function "clock_gettime": $(HAS_CLOCK_GETTIME)"
$(PROGRAM).8.html: $(PROGRAM).8 @groff -mandoc -Thtml $< >$@ diff --git a/Makefile.d/linux_i2c_test.c b/Makefile.d/linux_i2c_test.c new file mode 100644 index 0000000..7456ef5 --- /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; +} \ No newline at end of file diff --git a/Makefile.d/linux_mtd_test.c b/Makefile.d/linux_mtd_test.c new file mode 100644 index 0000000..56eaea5 --- /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; +} \ No newline at end of file diff --git a/Makefile.d/linux_spi_test.c b/Makefile.d/linux_spi_test.c new file mode 100644 index 0000000..be41988 --- /dev/null +++ b/Makefile.d/linux_spi_test.c @@ -0,0 +1,8 @@ +#include <linux/spi/spidev.h> + +int main(int argc, char **argv) +{ + (void)argc; + (void)argv; + return 0; +} \ No newline at end of file diff --git a/Makefile.include b/Makefile.include index 0ea1234..dccc69d 100644 --- a/Makefile.include +++ b/Makefile.include @@ -130,44 +130,6 @@ endef export FTDI_232H_TEST
-define LINUX_MTD_TEST -#include <mtd/mtd-user.h> - -int main(int argc, char **argv) -{ - (void) argc; - (void) argv; - return 0; -} -endef -export LINUX_MTD_TEST - -define LINUX_SPI_TEST -#include <linux/types.h> -#include <linux/spi/spidev.h> - -int main(int argc, char **argv) -{ - (void) argc; - (void) argv; - return 0; -} -endef -export LINUX_SPI_TEST - -define LINUX_I2C_TEST -#include <linux/i2c-dev.h> -#include <linux/i2c.h> - -int main(int argc, char **argv) -{ - (void) argc; - (void) argv; - return 0; -} -endef -export LINUX_I2C_TEST - define NI845X_TEST #include <ni845x.h>