From c462bbafa1ce9b8e55bbe3ea711fccf3bdc6b6c9 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Wed, 13 Mar 2024 14:40:10 +0100 Subject: [PATCH] Makefile: compile the applications only when a file changed. --- bin/should-update | 17 +++++++++++++++++ makefile | 7 +++++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100755 bin/should-update diff --git a/bin/should-update b/bin/should-update new file mode 100755 index 0000000..b49e3a0 --- /dev/null +++ b/bin/should-update @@ -0,0 +1,17 @@ +#!/bin/sh + +# Should we run the build? + +if [ $# -lt 1 ]; then + exec >& 2 + echo "Usage: $0 " + exit 1 +fi + +exe=$1 + +# If the binary hasn't already be compiled. +[ -f "${exe}" ] || exit 0 + +v=`find src/ -type f -newer "${exe}" | wc -l` +test "${v}" != "0" diff --git a/makefile b/makefile index 7d30a0e..309728f 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,8 @@ all: build +Q ?= @ +SHOULD_UPDATE = ./bin/should-update + NAME ?= John EMAIL ?= john@example.com @@ -61,9 +64,9 @@ permission-set: ################### build-server: - shards build authd + $(Q)-$(SHOULD_UPDATE) bin/authd && shards build authd build-client: - shards build authc + $(Q)-$(SHOULD_UPDATE) bin/authc && shards build authc build: build-server build-client