Skip to content

Commit 9bc87d7

Browse files
committed
Makefile: improve Jansson-is-missing error handling
Rather than letting the compiler fail due to the Jansson header file missing, check if it is installed, and, if it is not, provide an informative error message for installing it or building without it. Change-Id: I6bf6195e9c27faa6096a3ca41223c41a4da8c6c5 Signed-off-by: jty2 <46021128+jty2@users.noreply.github.com>
1 parent 9cc9fb6 commit 9bc87d7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

benchmarks/lockhammer/Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,39 @@ LOCK_DEPS = $(addprefix $(BUILD_DIR)/,$(addsuffix .d,$(addprefix $(LOCK_BASENAME
408408
LOCK_I = $(addprefix $(BUILD_DIR)/,$(addsuffix .i,$(addprefix $(LOCK_BASENAME).,$(TEST_TARGETS))))
409409

410410

411+
# ---------------------
412+
# early dependency checking
413+
414+
define no_libjansson_message
415+
416+
417+
Jansson (for JSON result output) does not appear to be installed.
418+
419+
To build without JSON output, rerun make with NO_JSON=1, e.g.:
420+
421+
make $(MAKECMDGOALS) NO_JSON=1
422+
423+
Or install Jansson development headers, perhaps using:
424+
425+
sudo apt install libjansson-dev
426+
427+
and then run 'make clean' before trying to rebuild
428+
endef
429+
430+
# This variable is only for the header existience check. Modify this and
431+
# CFLAGS/LDFLAGS if Jansson is installed in another location.
432+
433+
JANSSON_HEADER_FILE=/usr/include/jansson.h
434+
435+
ifneq ($(NO_JSON),1)
436+
ifeq ($(filter $(ALL_CLEAN_TARGETS),$(MAKECMDGOALS)),)
437+
ifeq (,$(wildcard $(JANSSON_HEADER_FILE)))
438+
$(error $(no_libjansson_message))
439+
endif
440+
endif
441+
endif
442+
443+
411444
# ---------------------
412445
# info for debugging make
413446

0 commit comments

Comments
 (0)