diff --git a/Makefile.lib b/Makefile.lib index a78ca8a1..d635e4bf 100644 --- a/Makefile.lib +++ b/Makefile.lib @@ -30,7 +30,9 @@ quiet_cmd_compile = ' [CC] $(RELPATH)$<' # Rule to compile a set of .o files into one .o file quiet_cmd_ld_objs = " [LD] $(RELPATH)$@" - cmd_ld_objs = $(LD) -r -o $@ $(filter $(OBJS), $^) + cmd_ld_objs = $(LD) -r -o $@ $(filter $(OBJS), $^) \ + $(foreach subdir,$(sort $(filter-out src,$(SUBDIRS))), \ + `test -e $(subdir)/lib.o && echo $(subdir)/lib.o`) quiet_cmd_link = ' [LINK] $(RELPATH)$@' cmd_link = $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) @@ -74,16 +76,6 @@ ifdef OBJS-yes OBJS += $(OBJS-yes) endif -ifdef SUBDIRS -# Apparently wildcard won't expand *.o files so check if there are any *.c -# files and use that to magically add the lib.o file of the subdirectory. -subobjs := $(strip $(foreach subdir,$(sort $(filter-out src,$(SUBDIRS))), \ - $(if $(wildcard $(subdir)/*.c),$(subdir)/lib.o))) -endif -ifneq ($(subobjs),) -OBJS += $(subobjs) -endif - ifdef OBJS lib.o: $(sort $(OBJS)) $(call cmd,ld_objs)