From f103b71ed6f684b042473b5d0e70805ebb360b5d Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 13 Mar 2009 19:26:12 +0000 Subject: [PATCH] added SUBDIRS to top-level Makefile to make adding subdirectories easier git-svn-id: svn://anubis/fart/trunk@214 7f9b0f55-74a9-4bce-be96-3c2cd072584d --- Makefile | 22 +++++++++++++--------- main/Makefile | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index fd9bd0d..fbf65fc 100644 --- a/Makefile +++ b/Makefile @@ -9,19 +9,23 @@ export CXXFLAGS := -Wall -O2 LDFLAGS := -lfl +SUBDIRS := util shapes main parser + all: $(TARGET) .PHONY: $(TARGET) $(TARGET): - make -C util - make -C shapes - make -C main - make -C parser - $(CXX) -o $@ main/*.o util/*.o shapes/*.o parser/*.o $(CXXFLAGS) $(LDFLAGS) + @for d in $(SUBDIRS); \ + do $(MAKE) -C $$d; \ + ret=$$?; \ + if [[ $$ret != 0 ]]; then \ + exit $$ret; \ + fi; \ + done + $(CXX) -o $@ $(patsubst %,%/*.o,$(SUBDIRS)) $(CXXFLAGS) $(LDFLAGS) clean: - make -C parser clean CLEAN=1 - make -C main clean CLEAN=1 - make -C shapes clean CLEAN=1 - make -C util clean CLEAN=1 + @for d in $(SUBDIRS); \ + do $(MAKE) -C $$d clean CLEAN=1; \ + done -rm -f $(TARGET) diff --git a/main/Makefile b/main/Makefile index b26680d..a210eec 100644 --- a/main/Makefile +++ b/main/Makefile @@ -18,6 +18,6 @@ clean: -$(RM) -f *.o *.dep # Include dependency files -ifndef clean +ifndef CLEAN -include $(DEPS) endif