From dad4a542320c1d7fb51f31ad88bc3af60c9a937d Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Thu, 20 Oct 2005 03:39:59 +0200 Subject: [PATCH] Fix the magic linking of subdir lib.o files Make will 'expand' all variables at initialization so we cannot rely on checking subdir/lib.o since it might not have been build yet. Instead use 'test && echo' on the ld command line. --- Makefile.lib | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) 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)