Makefile: compile the applications only when a file changed.

master
Philippe Pittoli 2024-03-13 14:40:10 +01:00
parent 95b7b76f6c
commit c462bbafa1
2 changed files with 22 additions and 2 deletions

17
bin/should-update Executable file
View File

@ -0,0 +1,17 @@
#!/bin/sh
# Should we run the build?
if [ $# -lt 1 ]; then
exec >& 2
echo "Usage: $0 <exe>"
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"

View File

@ -1,5 +1,8 @@
all: build all: build
Q ?= @
SHOULD_UPDATE = ./bin/should-update
NAME ?= John NAME ?= John
EMAIL ?= john@example.com EMAIL ?= john@example.com
@ -61,9 +64,9 @@ permission-set:
################### ###################
build-server: build-server:
shards build authd $(Q)-$(SHOULD_UPDATE) bin/authd && shards build authd
build-client: build-client:
shards build authc $(Q)-$(SHOULD_UPDATE) bin/authc && shards build authc
build: build-server build-client build: build-server build-client