From c329fd800fa3aa5ce46e116f8060032deb974e76 Mon Sep 17 00:00:00 2001 From: Moti Cohen Date: Mon, 9 Sep 2024 15:41:41 +0300 Subject: [PATCH] Build hiredis only for 'make test' rule --- Makefile | 35 +++++++++++++++++++++-------------- deps/Makefile | 11 ++++++----- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 621b36c..3ab5c3b 100644 --- a/Makefile +++ b/Makefile @@ -17,25 +17,26 @@ else PKGCONFIGDIR = $(LIBDIR)/pkgconfig endif +HIREDIS_VERSION := $(shell git submodule status deps/hiredis | grep -oP "\(v[0-9]+\.[0-9]+\.[0-9]-[0-9]*-[a-z0-9]*\)" || true) LIBRDB_VERSION = $(shell grep -oP '(?<=LIBRDB_VERSION_STRING ")[0-9]+\.[0-9]+\.[0-9]+' ./src/lib/version.h) export LIBRDB_VERSION # ------------------------- ALL -------------------------------------- all: - $(MAKE) -C deps -f Makefile all - $(MAKE) -C src/lib -f Makefile all - $(MAKE) -C src/ext -f Makefile all - $(MAKE) -C src/cli -f Makefile all - $(MAKE) -C examples -f Makefile all + $(MAKE) -C deps all + $(MAKE) -C src/lib all + $(MAKE) -C src/ext all + $(MAKE) -C src/cli all + $(MAKE) -C examples all clean: - $(MAKE) -C deps -f Makefile clean - $(MAKE) -C src/lib -f Makefile clean - $(MAKE) -C src/ext -f Makefile clean - $(MAKE) -C src/cli -f Makefile clean - $(MAKE) -C examples -f Makefile clean - $(MAKE) -C test -f Makefile clean + $(MAKE) -C deps clean + $(MAKE) -C src/lib clean + $(MAKE) -C src/ext clean + $(MAKE) -C src/cli clean + $(MAKE) -C examples clean + $(MAKE) -C test clean rm -f librdb.pc rm -f librdb-ext.pc @@ -50,9 +51,15 @@ debug: OPTIMIZATION="-O0" LIBRDB_DEBUG=1 $(MAKE) # ------------------------- TEST -------------------------------------- - -build_test: all - $(MAKE) -C test -f Makefile all +hiredis_submodule: + @if [ -z "$(HIREDIS_VERSION)" ]; then \ + echo "Submodule 'hiredis' is not up to date. Run 'git submodule update --init' to update it."; \ + exit 1; \ + fi + +build_test: all hiredis_submodule + $(MAKE) -C deps all + $(MAKE) -C test all test: build_test ./runtests diff --git a/deps/Makefile b/deps/Makefile index c41cd3f..9185276 100644 --- a/deps/Makefile +++ b/deps/Makefile @@ -1,10 +1,11 @@ all: - $(MAKE) -C redis -f Makefile all - $(MAKE) -C hiredis -f Makefile all + $(MAKE) -C redis all clean: - $(MAKE) -C redis -f Makefile clean - $(MAKE) -C hiredis -f Makefile all + $(MAKE) -C redis clean + $(MAKE) -C hiredis all +test: + $(MAKE) -C hiredis all -.PHONY: all clean \ No newline at end of file +.PHONY: all clean test \ No newline at end of file