added SUBDIRS support to subdir.mak for recursive building

git-svn-id: svn://anubis/hos/trunk@23 5b3e749e-e535-0410-8002-a9bb6afbdfca
This commit is contained in:
josh 2009-06-30 17:54:09 +00:00
parent 90e03d4f95
commit 1548e7327a

View File

@ -6,10 +6,14 @@ CDEPS := $(COBJS:.o=.dep)
CXXDEPS := $(CXXOBJS:.o=.dep) CXXDEPS := $(CXXOBJS:.o=.dep)
OUTPUT_FILE := $(SUBDIR)_all.o OUTPUT_FILE := $(SUBDIR)_all.o
ifdef SUBDIRS
SUBDIRS_clean := $(SUBDIRS:%=%.clean)
endif
all: $(OUTPUT_FILE) all: $(OUTPUT_FILE)
$(OUTPUT_FILE): $(ASMOBJS) $(COBJS) $(CXXOBJS) $(OUTPUT_FILE): $(ASMOBJS) $(COBJS) $(CXXOBJS) $(SUBDIRS)
$(LD) -r -o $@ $^ $(LD) -r -o $@ $(ASMOBJS) $(COBJS) $(CXXOBJS) $(foreach subdir,$(SUBDIRS),$(subdir)/$(subdir)_all.o)
%.o: %.asm %.o: %.asm
$(NASM) -f elf -o $@ $< $(NASM) -f elf -o $@ $<
@ -20,14 +24,25 @@ $(OUTPUT_FILE): $(ASMOBJS) $(COBJS) $(CXXOBJS)
%.o: %.cc %.o: %.cc
$(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $< $(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $<
ifdef SUBDIRS
.PHONY: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@ SUBDIR=$@
endif
# Make dependency files # Make dependency files
%.dep: %.c %.dep: %.c
@set -e; rm -f $@; \ @set -e; rm -f $@; \
$(CC) -MM $(CPPFLAGS) $< | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@ $(CC) -MM $(CPPFLAGS) $< | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@
clean: clean: $(SUBDIRS_clean)
-rm -f *.o *.dep *~ -rm -f *.o *.dep *~
ifdef SUBDIRS
%.clean:
$(MAKE) -C $* clean clean=1
endif
# Include dependency files # Include dependency files
ifndef clean ifndef clean
-include $(DEPS) -include $(DEPS)