Improve scripts change detection in Makefile
authorVirgil Dupras <hsoft@hardcoded.net>
Wed, 18 Jul 2018 12:14:41 +0000 (08:14 -0400)
committerVirgil Dupras <hsoft@hardcoded.net>
Wed, 18 Jul 2018 12:14:41 +0000 (08:14 -0400)
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.

src/Makefile
src/scripts/Makefile [deleted file]

index 6ca4e5e..f368d23 100644 (file)
@@ -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 (file)
index e28955e..0000000
+++ /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