From 1523a830d88f61ebca6c6abcd90b51650576c2d2 Mon Sep 17 00:00:00 2001 From: steve-chavez Date: Thu, 3 Aug 2023 17:53:33 -0500 Subject: [PATCH 1/3] fix: make check always compiles dependencies Make is supposed to only compile dependencies when they change but `make check` always compiles them, making the test suite run slow. ``` $ make check cc ... build/mpc.o $ make check cc ... build/mpc.o ``` The same occurs for other targets like `build/test-dynamic` and `build/test-static`. This happens because these targets have the `$(DIST)` directory as a dependency, and directories always change whenever members are added, removed or renamed. Fix this by changing the `$(DIST)` directory dependency to a `$(DIST)/.dirstamp` file. Now `make check` compiles dependencies only once. --- .gitignore | 3 ++- Makefile | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 788a748..e2ce213 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ examples/maths examples/smallc examples/foobar examples/tree_traversal -build/* \ No newline at end of file +build/* +tags diff --git a/Makefile b/Makefile index 9affedd..39ec1d7 100644 --- a/Makefile +++ b/Makefile @@ -17,11 +17,12 @@ EXAMPLESEXE = $(EXAMPLES:.c=) all: $(EXAMPLESEXE) check libs $(DIST)/$(PROJ).pc -$(DIST): +$(DIST)/.dirstamp: $(MKDIR) $(DIST) $(MKDIR) $(DIST)/examples + touch $@ -check: $(DIST) $(DIST)/test-file $(DIST)/test-static $(DIST)/test-dynamic +check: $(DIST)/.dirstamp $(DIST)/test-file $(DIST)/test-static $(DIST)/test-dynamic ./$(DIST)/test-file ./$(DIST)/test-static LD_LIBRARY_PATH=$(DIST) ./$(DIST)/test-dynamic @@ -35,23 +36,23 @@ $(DIST)/test-dynamic: $(TESTS) $(DIST)/lib$(PROJ).so $(PROJ).h tests/ptest.h $(DIST)/test-static: $(TESTS) $(DIST)/lib$(PROJ).a $(PROJ).h tests/ptest.h $(CC) $(filter-out -Werror, $(CFLAGS)) $(TESTS) -lm -L$(DIST) -l$(PROJ) -static -o $(DIST)/test-static -examples/%: $(DIST) examples/%.c $(PROJ).c $(PROJ).h +examples/%: $(DIST)/.dirstamp examples/%.c $(PROJ).c $(PROJ).h $(CC) $(CFLAGS) $(filter-out $(DIST) $(PROJ).h, $^) -lm -o $(DIST)/$@ -$(DIST)/lib$(PROJ).so: $(DIST) $(PROJ).c $(PROJ).h +$(DIST)/lib$(PROJ).so: $(DIST)/.dirstamp $(PROJ).c $(PROJ).h ifneq ($(OS),Windows_NT) $(CC) $(CFLAGS) -fPIC -shared $(PROJ).c -o $(DIST)/lib$(PROJ).so else $(CC) $(CFLAGS) -shared $(PROJ).c -o $(DIST)/lib$(PROJ).so endif -$(DIST)/lib$(PROJ).a: $(DIST) $(PROJ).c $(PROJ).h +$(DIST)/lib$(PROJ).a: $(DIST)/.dirstamp $(PROJ).c $(PROJ).h $(CC) $(CFLAGS) -c $(PROJ).c -o $(DIST)/$(PROJ).o $(AR) rcs $(DIST)/lib$(PROJ).a $(DIST)/$(PROJ).o libs: $(DIST)/lib$(PROJ).so $(DIST)/lib$(PROJ).a -$(DIST)/$(PROJ).pc: $(DIST) $(PROJ).pc +$(DIST)/$(PROJ).pc: $(DIST)/.dirstamp $(PROJ).pc cp $(PROJ).pc $(DIST)/$(PROJ).pc sed -i '1i\prefix=$(PREFIX)/' $(DIST)/$(PROJ).pc From c2feb361dc7f75c310d2b337f7ceea6aa5fd7a43 Mon Sep 17 00:00:00 2001 From: steve-chavez Date: Thu, 3 Aug 2023 20:44:26 -0500 Subject: [PATCH 2/3] remove tags --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index e2ce213..be09b56 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,3 @@ examples/smallc examples/foobar examples/tree_traversal build/* -tags From 57ce9be86888daa96848da1be92a5d79ea2e0783 Mon Sep 17 00:00:00 2001 From: steve-chavez Date: Thu, 3 Aug 2023 20:46:54 -0500 Subject: [PATCH 3/3] add .dirstamp to examples --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 39ec1d7..128b2d8 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ $(DIST)/test-static: $(TESTS) $(DIST)/lib$(PROJ).a $(PROJ).h tests/ptest.h $(CC) $(filter-out -Werror, $(CFLAGS)) $(TESTS) -lm -L$(DIST) -l$(PROJ) -static -o $(DIST)/test-static examples/%: $(DIST)/.dirstamp examples/%.c $(PROJ).c $(PROJ).h - $(CC) $(CFLAGS) $(filter-out $(DIST) $(PROJ).h, $^) -lm -o $(DIST)/$@ + $(CC) $(CFLAGS) $(filter-out $(DIST)/.dirstamp $(PROJ).h, $^) -lm -o $(DIST)/$@ $(DIST)/lib$(PROJ).so: $(DIST)/.dirstamp $(PROJ).c $(PROJ).h ifneq ($(OS),Windows_NT)