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:
parent
90e03d4f95
commit
1548e7327a
@ -6,10 +6,14 @@ CDEPS := $(COBJS:.o=.dep)
|
||||
CXXDEPS := $(CXXOBJS:.o=.dep)
|
||||
OUTPUT_FILE := $(SUBDIR)_all.o
|
||||
|
||||
ifdef SUBDIRS
|
||||
SUBDIRS_clean := $(SUBDIRS:%=%.clean)
|
||||
endif
|
||||
|
||||
all: $(OUTPUT_FILE)
|
||||
|
||||
$(OUTPUT_FILE): $(ASMOBJS) $(COBJS) $(CXXOBJS)
|
||||
$(LD) -r -o $@ $^
|
||||
$(OUTPUT_FILE): $(ASMOBJS) $(COBJS) $(CXXOBJS) $(SUBDIRS)
|
||||
$(LD) -r -o $@ $(ASMOBJS) $(COBJS) $(CXXOBJS) $(foreach subdir,$(SUBDIRS),$(subdir)/$(subdir)_all.o)
|
||||
|
||||
%.o: %.asm
|
||||
$(NASM) -f elf -o $@ $<
|
||||
@ -20,14 +24,25 @@ $(OUTPUT_FILE): $(ASMOBJS) $(COBJS) $(CXXOBJS)
|
||||
%.o: %.cc
|
||||
$(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $<
|
||||
|
||||
ifdef SUBDIRS
|
||||
.PHONY: $(SUBDIRS)
|
||||
$(SUBDIRS):
|
||||
$(MAKE) -C $@ SUBDIR=$@
|
||||
endif
|
||||
|
||||
# Make dependency files
|
||||
%.dep: %.c
|
||||
@set -e; rm -f $@; \
|
||||
$(CC) -MM $(CPPFLAGS) $< | sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@
|
||||
|
||||
clean:
|
||||
clean: $(SUBDIRS_clean)
|
||||
-rm -f *.o *.dep *~
|
||||
|
||||
ifdef SUBDIRS
|
||||
%.clean:
|
||||
$(MAKE) -C $* clean clean=1
|
||||
endif
|
||||
|
||||
# Include dependency files
|
||||
ifndef clean
|
||||
-include $(DEPS)
|
||||
|
Loading…
x
Reference in New Issue
Block a user