1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

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>
This commit is contained in:
Thomas Heijligen 2023-04-19 12:58:23 +02:00 committed by Anastasia Klimchuk
parent 5ebdfb891f
commit fc7810e087
2 changed files with 20 additions and 7 deletions

View File

@ -36,6 +36,7 @@ EXPORTDIR ?= .
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_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_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 @@ endif
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 @@ config:
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 @@ libflashrom.a: $(OBJS)
$(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 @@ clean:
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

View File

@ -52,6 +52,10 @@ define dependency_version
$(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