X-Git-Url: http://sigaev.ru/git/gitweb.cgi?p=ftsbench.git;a=blobdiff_plain;f=Makefile.global;fp=Makefile.global;h=601c037b8b2e567ee310a00422c102c999c1e248;hp=5232a3208e9250efbb9060ef3b745a526c4c8a1e;hb=4dac833f9fc978646c9202f789e437f175db7215;hpb=e99b1c226598475b5ec6034775139b628bc715e1 diff --git a/Makefile.global b/Makefile.global index 5232a32..601c037 100644 --- a/Makefile.global +++ b/Makefile.global @@ -35,10 +35,6 @@ ifdef SUBDIRS SUBDIROBJS := $(SUBDIRS:%=%/SUBSYS.o) endif -ifdef PROGRAM -PROGRAMOBJ := $(PROGRAM:%=%.o) -endif - .SUFFIXES: .o.c .c.o: @@ -46,13 +42,19 @@ endif all: $(SUBSYS) $(LIBRARY) $(PROGRAM) +define prog_dep + $(1): $$(PROGRAMOBJ_$(1)) +endef + +$(foreach prog,$(PROGRAM),$(eval $(call prog_dep,$(prog)))) + ifdef PROGRAM ifdef LIBRARY $(PROGRAM): $(LIBRARY) endif $(PROGRAM): %: %.o - $(CC) -o $@ $< $(LIBRARY) $(LIB) + $(CC) -o $@ $< $(PROGRAMOBJ_$(@)) $(LIBRARY) $(LIB) endif ifdef LIBRARY @@ -70,18 +72,17 @@ ifdef SUBDIRS $(SUBDIROBJS): $(SUBDIRS:%=%-recursive) ; $(SUBDIRS:%=%-recursive): - $(MAKE) -C $(subst -recursive,,$@) -f Makefile SUBSYS.o + $(MAKE) -C $(subst -recursive,,$@) -f Makefile OS=$(OS) SUBSYS.o endif clean: -ifdef OBJ - rm -rf $(OBJ) -endif ifdef LIBOBJ rm -rf $(LIBOBJ) endif ifdef PROGRAM - rm -rf $(PROGRAM) $(PROGRAMOBJ) *core core.* + rm -rf $(PROGRAM) + rm -rf $(foreach P, $(PROGRAM), $P.o $(PROGRAMOBJ_$(P))) + rm -rf *core core.* endif ifdef LIBRARY rm -rf $(LIBRARY) @@ -90,5 +91,5 @@ ifdef SUBOBJ rm -rf $(SUBOBJ) $(SUBSYS) endif ifdef SUBDIRS - for dir in $(SUBDIRS); do $(MAKE) -f Makefile -C $$dir clean || exit; done + for dir in $(SUBDIRS); do $(MAKE) -f Makefile -C $$dir OS=$(OS) clean || exit; done endif