From: Virgil Dupras <hsoft@hardcoded.net>
Date: Wed, 18 Jul 2018 12:14:41 +0000 (-0400)
Subject: Improve scripts change detection in Makefile
X-Git-Url: https://git.owens.tech/wrapped.html/wrapped.html/git?a=commitdiff_plain;h=0eefdb9250f5a24df5ef86c380ec03f8918af68a;p=vimb.git

Improve scripts change detection in Makefile

When changing a script in `src/scripts`, `make` would need to be invoked
twice for a proper build: once for `scripts.h` and once for the `.o`
files depending on it.

This commit fixes this by integrating `src/scripts/Makefile` into
`src/Makefile` to allow for proper dependency update detection.
---

diff --git a/src/Makefile b/src/Makefile
index 6ca4e5e..f368d23 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,11 +1,14 @@
 include ../config.mk
 
 OBJ = $(patsubst %.c, %.o, $(wildcard *.c))
+JSFILES  = $(wildcard scripts/*.js)
+CSSFILES = $(wildcard scripts/*.css)
 
 all: vimb webextension.subdir-all
 
 clean: webextension.subdir-clean
 	$(RM) vimb $(OBJ)
+	$(RM) scripts/scripts.h
 
 vimb: $(OBJ)
 	@echo "${CC} $@"
@@ -22,7 +25,12 @@ normal.o: scripts/scripts.h
 
 setting.o: scripts/scripts.h
 
-scripts/scripts.h: scripts.subdir-all
+scripts/scripts.h: $(JSFILES) $(CSSFILES)
+	$(Q)$(RM) $@
+	@echo "create $@ from *.{css,js}"
+	$(Q)for file in $(JSFILES) $(CSSFILES); do \
+		./scripts/js2h.sh $$file >> $@; \
+	done
 
 config.h:
 	@echo create $@ from config.def.h
diff --git a/src/scripts/Makefile b/src/scripts/Makefile
deleted file mode 100644
index e28955e..0000000
--- a/src/scripts/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-include ../../config.mk
-
-JSFILES  = $(wildcard *.js)
-CSSFILES = $(wildcard *.css)
-
-all: scripts.h
-
-clean:
-	$(RM) scripts.h
-
-scripts.h: $(JSFILES) $(CSSFILES)
-	$(Q)$(RM) $@
-	@echo "create $@ from *.{css,js}"
-	$(Q)for file in $(JSFILES) $(CSSFILES); do \
-		./js2h.sh $$file >> $@; \
-	done
-
-.PHONY: all clean