1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 15:12:36 +02:00

Makefile: move determination test for OS to Makefile.d

Move the test code for OS detection in a extra directory to split it
from the main flashrom code.

Change-Id: Id911f17f4100f242e1fde10d23a8459ddf38b369
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/58015
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
Thomas Heijligen 2021-09-28 15:22:34 +02:00 committed by Nico Huber
parent 8da9a9acdf
commit ba275d8bdb
5 changed files with 15 additions and 12 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
*.d *.d
!Makefile.d/
*.o *.o
/.features /.features
/.dependencies /.dependencies

View File

@ -162,14 +162,12 @@ endif
# IMPORTANT: The following lines must be placed before TARGET_OS, ARCH or ENDIAN # IMPORTANT: The following lines must be placed before TARGET_OS, ARCH or ENDIAN
# is ever used (of course), but should come after any lines setting CC because # is ever used (of course), but should come after any lines setting CC because
# the lines below use CC itself. # the lines below use CC itself.
override TARGET_OS := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E os.h 2>/dev/null \ override TARGET_OS := $(call c_macro_test, Makefile.d/os_test.h)
| tail -1 | cut -f 2 -d'"'))
override ARCH := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E archtest.c 2>/dev/null \ override ARCH := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E archtest.c 2>/dev/null \
| tail -1 | cut -f 2 -d'"')) | tail -1 | cut -f 2 -d'"'))
override ENDIAN := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E endiantest.c 2>/dev/null \ override ENDIAN := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E endiantest.c 2>/dev/null \
| tail -1)) | tail -1))
ifeq ($(TARGET_OS), $(filter $(TARGET_OS), FreeBSD OpenBSD DragonFlyBSD)) ifeq ($(TARGET_OS), $(filter $(TARGET_OS), FreeBSD OpenBSD DragonFlyBSD))
override CPPFLAGS += -I/usr/local/include override CPPFLAGS += -I/usr/local/include
override LDFLAGS += -L/usr/local/lib override LDFLAGS += -L/usr/local/lib
@ -848,7 +846,7 @@ TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --
# This includes all frontends and libflashrom. # This includes all frontends and libflashrom.
# We don't use EXEC_SUFFIX here because we want to clean everything. # We don't use EXEC_SUFFIX here because we want to clean everything.
clean: clean:
rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d $(PROGRAM).8 $(PROGRAM).8.html $(BUILD_DETAILS_FILE) rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a $(filter-out Makefile.d, $(wildcard *.d *.o)) $(PROGRAM).8 $(PROGRAM).8.html $(BUILD_DETAILS_FILE)
@+$(MAKE) -C util/ich_descriptors_tool/ clean @+$(MAKE) -C util/ich_descriptors_tool/ clean
distclean: clean distclean: clean
@ -873,11 +871,8 @@ compiler: featuresavailable
@echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \ @echo $(ARCH)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
( echo "unknown (\"$(ARCH)\"). Aborting."; exit 1) ( echo "unknown (\"$(ARCH)\"). Aborting."; exit 1)
@printf "%s\n" '$(ARCH)' @printf "%s\n" '$(ARCH)'
@printf "Target OS is " @echo Target OS is $(TARGET_OS)
@# FreeBSD wc will output extraneous whitespace. @if [ $(TARGET_OS) = unknown ]; then echo Aborting.; exit 1; fi
@echo $(TARGET_OS)|wc -w|grep -q '^[[:blank:]]*1[[:blank:]]*$$' || \
( echo "unknown (\"$(TARGET_OS)\"). Aborting."; exit 1)
@printf "%s\n" '$(TARGET_OS)'
ifeq ($(TARGET_OS), libpayload) ifeq ($(TARGET_OS), libpayload)
@$(CC) --version 2>&1 | grep -q coreboot || \ @$(CC) --version 2>&1 | grep -q coreboot || \
( echo "Warning: It seems you are not using coreboot's reference compiler."; \ ( echo "Warning: It seems you are not using coreboot's reference compiler."; \

View File

@ -14,7 +14,7 @@
*/ */
/* /*
* Header file for OS checking. * This file determinate the target os. It should only be used my the Makefile
*/ */
// Solaris // Solaris
@ -61,5 +61,7 @@
#else #else
#define __FLASHROM_OS__ "Linux" #define __FLASHROM_OS__ "Linux"
#endif #endif
#else
#define __FLASHROM_OS__ "unknown"
#endif #endif
__FLASHROM_OS__ __FLASHROM_OS__

View File

@ -31,6 +31,10 @@ $(foreach p,$1, \
$(eval override $(p) := no)) $(eval override $(p) := no))
endef endef
# Run the C Preprocessor with file $1 and return the last line, removing quotes.
define c_macro_test
$(strip $(shell $(CC) -E $1 2>/dev/null | tail -1 | tr -d '"'))
endef
define COMPILER_TEST define COMPILER_TEST
int main(int argc, char **argv) int main(int argc, char **argv)

View File

@ -4,6 +4,8 @@
# This Makefile works standalone, but it is usually called from the main # This Makefile works standalone, but it is usually called from the main
# Makefile in the flashrom directory. # Makefile in the flashrom directory.
include ../../Makefile.include
PROGRAM=ich_descriptors_tool PROGRAM=ich_descriptors_tool
EXTRAINCDIRS = ../../ . EXTRAINCDIRS = ../../ .
DEPPATH = .dep DEPPATH = .dep
@ -32,8 +34,7 @@ EXEC_SUFFIX := .exe
FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 FLASHROM_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
endif endif
override TARGET_OS := $(shell $(CC) $(CPPFLAGS) -E $(SHAREDSRCDIR)/os.h | grep -v '^\#' | grep '"' | \ override TARGET_OS := $(call c_macro_test, ../../Makefile.d/os_test.h)
cut -f 2 -d'"')
ifeq ($(TARGET_OS), DOS) ifeq ($(TARGET_OS), DOS)
EXEC_SUFFIX := .exe EXEC_SUFFIX := .exe