Anastasia Klimchuk submitted this change.
2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
Makefile: Build man-page only when sphinx is available
Currently, it's not possible to compile the upstream branch using the
`make' command without sphinx beeing installed.
Check if sphinx-build is installed and only then build or install the
man-page.
The problem was noticed from commit
f4f2f3dd19784efa26fd5619b7a44b4cdf14b04c move manpage to sphinx.
Change-Id: If1b81d9bc25ecac19d493b44b00a7c42d0643fe6
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/74519
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M Makefile
M Makefile.include
2 files changed, 42 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index e6d4554..da5203e 100644
--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,7 @@
RANLIB ?= ranlib
PKG_CONFIG ?= pkg-config
BUILD_DETAILS_FILE ?= build_details.txt
+SPHINXBUILD ?= sphinx-build
# The following parameter changes the default programmer that will be used if there is no -p/--programmer
# argument given when running flashrom. The predefined setting does not enable any default so that every
@@ -259,6 +260,7 @@
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_SERIAL := $(strip $(if $(filter $(TARGET_OS), DOS libpayload), no, yes))
+HAS_SPHINXBUILD := $(shell command -v $(SPHINXBUILD) &>/dev/null && echo yes || echo no)
EXEC_SUFFIX := $(strip $(if $(filter $(TARGET_OS), DOS MinGW), .exe))
override CFLAGS += -Iinclude
@@ -956,7 +958,7 @@
OBJS = $(CHIP_OBJS) $(PROGRAMMER_OBJS) $(LIB_OBJS)
-all: $(PROGRAM)$(EXEC_SUFFIX) man8/$(PROGRAM).8
+all: $(PROGRAM)$(EXEC_SUFFIX) $(call has_dependency, $(HAS_SPHINXBUILD), man8/$(PROGRAM).8)
ifeq ($(ARCH), x86)
@+$(MAKE) -C util/ich_descriptors_tool/ HOST_OS=$(HOST_OS) TARGET_OS=$(TARGET_OS)
endif
@@ -1017,6 +1019,7 @@
echo "The following features are unavailable on your machine: $(UNSUPPORTED_FEATURES)" \
exit 1; \
fi
+ @echo "Checking for program \"sphinx-build\": $(HAS_SPHINXBUILD)"
%.o: %.c | config
$(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FLASHROM_CFLAGS) $(FEATURE_FLAGS) -D'FLASHROM_VERSION=$(VERSION)' -o $@ -c $<
@@ -1028,9 +1031,13 @@
$(AR) rcs $@ $^
$(RANLIB) $@
-SPHINXBUILD ?= sphinx-build
man8/$(PROGRAM).8: doc/*
- @FLASHROM_VERSION=$(VERSION) $(SPHINXBUILD) -b man doc .
+ @if [ "$(HAS_SPHINXBUILD)" = "yes" ]; then \
+ $(SPHINXBUILD) -Drelease=$(VERSION) -b man doc .; \
+ else \
+ echo "$(SPHINXBUILD) not found. Can't build man-page"; \
+ exit 1; \
+ fi
$(PROGRAM).bash: util/$(PROGRAM).bash-completion.tmpl
@# Add to the bash completion file a list of enabled programmers.
@@ -1047,13 +1054,15 @@
man8 .doctrees $(PROGRAM).bash $(BUILD_DETAILS_FILE)
@+$(MAKE) -C util/ich_descriptors_tool/ clean
-install: $(PROGRAM)$(EXEC_SUFFIX) man8/$(PROGRAM).8 $(PROGRAM).bash
+install: $(PROGRAM)$(EXEC_SUFFIX) $(call has_dependency, $(HAS_SPHINXBUILD), man8/$(PROGRAM).8) $(PROGRAM).bash
mkdir -p $(DESTDIR)$(PREFIX)/sbin
- mkdir -p $(DESTDIR)$(MANDIR)/man8
- mkdir -p $(DESTDIR)$(BASHCOMPDIR)
$(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
- $(INSTALL) -m 0644 man8/$(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
+ mkdir -p $(DESTDIR)$(BASHCOMPDIR)
$(INSTALL) -m 0644 $(PROGRAM).bash $(DESTDIR)$(BASHCOMPDIR)
+ifeq ($(HAS_SPHINXBUILD), yes)
+ mkdir -p $(DESTDIR)$(MANDIR)/man8
+ $(INSTALL) -m 0644 man8/$(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
+endif
libinstall: libflashrom.a include/libflashrom.h
mkdir -p $(DESTDIR)$(PREFIX)/lib
diff --git a/Makefile.include b/Makefile.include
index a55f6f5..5f81ccc 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -52,6 +52,10 @@
$(call debug_shell, $(if $(PKG_CONFIG_LIBDIR),PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR),) $(PKG_CONFIG) --modversion $1 2>/dev/null)
endef
+define has_dependency # $1: dependency, $2: action/target
+$(if $(findstring $(strip $1),yes), $(strip $2))
+endef
+
define dependency_cflags
$(call debug_shell, $(if $(PKG_CONFIG_LIBDIR),PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR),) $(PKG_CONFIG) --cflags $1 2>/dev/null)
endef
To view, visit change 74519. To unsubscribe, or for help writing mail filters, visit settings.