[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cdi-devel] [PATCH v2 1/9] Makefile: Heed Makefile.conf



+ Apparently it is allowed to specify additional CFLAGS (as "CC_FLAGS")
  in a file named Makefile.conf (formatted as a shell script) in a
  driver's root directory; or at least ext2 just does this.
  This patch makes the CDI Makefile take the additional flags from that
  file into account, if present.
  Thanks to this, the ext2 driver can be compiled.

Signed-off-by: Max Reitz <max@xxxxxxxxxx>
---
 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 5360efb..bc04e58 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,9 @@ run_command = $(if $(V),$(2),@echo $(1);$(2))
 all: $(OBJS)
 
 %.o: %.c
-	$(call run_command,"CC $^",$(CC) $(CFLAGS) $(addprefix -I,$(addprefix $(dir $^),. include)) -c -o $@ $^)
+	$(call run_command,"CC $^",$(CC) $(CFLAGS) \
+		$(if $(shell if [ -f $(dir $^)/Makefile.conf ]; then echo .; fi),$(shell cd $(dir $^); echo -e "$$(< Makefile.conf)\necho \$$CC_FLAGS" | sh -s),) \
+		$(addprefix -I,$(addprefix $(dir $^),. include)) -c -o $@ $^)
 
 clean:
 	-rm $(OBJS) 2> /dev/null
-- 
2.3.5