1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-27 02:56:18 -04:00

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.
This commit is contained in:
Jonas Fonseca 2005-10-20 03:39:59 +02:00 committed by Jonas Fonseca
parent a617d5b140
commit dad4a54232

View File

@ -30,7 +30,9 @@ quiet_cmd_compile = ' [CC] $(RELPATH)$<'
# Rule to compile a set of .o files into one .o file # Rule to compile a set of .o files into one .o file
quiet_cmd_ld_objs = " [LD] $(RELPATH)$@" 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)$@' quiet_cmd_link = ' [LINK] $(RELPATH)$@'
cmd_link = $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) cmd_link = $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
@ -74,16 +76,6 @@ ifdef OBJS-yes
OBJS += $(OBJS-yes) OBJS += $(OBJS-yes)
endif 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 ifdef OBJS
lib.o: $(sort $(OBJS)) lib.o: $(sort $(OBJS))
$(call cmd,ld_objs) $(call cmd,ld_objs)