# This is here so things in sysdep Makefiles can easily depend on foo.h as
# appropriate and not worry about where foo.h comes from, which may be
# system dependent and not known by that Makefile.
-vpath %.h $(subst $(empty) ,:,$(strip $(common-objpfx) \
+vpath %.h $(subst $(empty) ,:,$(strip $(common-objpfx) $(objpfx) \
$(addprefix $(sysdep_dir)/,$(sysdirs)) \
$(..)))
# have source in .s files, and thus do not in fact need a .d file.
# So we must define rules to make .d files for .s files.
define make-dummy-dep
-$(addprefix ln $(objpfx)dummy.d ,$(filter-out $(wildcard $@),$@))
+$(addprefix ln $(common-objpfx)dummy.d ,$(filter-out $(wildcard $@),$@))
endef
-$(objpfx)dummy.d:
+$(common-objpfx)dummy.d:
echo '# .s files cannot contain includes, so they need no deps.' > $@
# It matters that this set of rules, for compiling from sources in
$(objpfx)%.so: %.s $(before-compile); $(compile-command.s)
$(objpfx)%.po: %.s $(before-compile); $(compile-command.s)
$(objpfx)%.go: %.s $(before-compile); $(compile-command.s)
-$(objpfx)%.d: %.s $(objpfx)dummy.d; $(make-dummy-dep)
+$(objpfx)%.d: %.s $(common-objpfx)dummy.d; $(make-dummy-dep)
$(objpfx)%.o: %.c $(before-compile); $(compile-command.c)
$(objpfx)%.so: %.c $(before-compile); $(compile-command.c)
$(objpfx)%.po: %.c $(before-compile); $(compile-command.c)
$(objpfx)%.so: $(objpfx)%.s $(before-compile); $(compile-command.s)
$(objpfx)%.po: $(objpfx)%.s $(before-compile); $(compile-command.s)
$(objpfx)%.go: $(objpfx)%.s $(before-compile); $(compile-command.s)
-$(objpfx)%.d: $(objpfx)%.s $(objpfx)dummy.d; $(make-dummy-dep)
+$(objpfx)%.d: $(objpfx)%.s $(common-objpfx)dummy.d; $(make-dummy-dep)
$(objpfx)%.o: $(objpfx)%.c $(before-compile); $(compile-command.c)
$(objpfx)%.so: $(objpfx)%.c $(before-compile); $(compile-command.c)
$(objpfx)%.po: $(objpfx)%.c $(before-compile); $(compile-command.c)
\$$(compile-command.c)"; \
done; \
$(open-check-inhibit-asm) \
- echo "\$$(objpfx)%.d: $$dir/%.s \$$(objpfx)dummy.d; \
+ echo "\$$(objpfx)%.d: $$dir/%.s \$$(common-objpfx)dummy.d; \
\$$(make-dummy-dep)"; \
echo "\$$(objpfx)%.d: $$dir/%.S \$$(before-compile); \
\$$(+make-deps)"; \
S-CPPFLAGS = $(asm-CPPFLAGS)
define +make-deps
+$(make-target-directory)
-@rm -f $@
$(+mkdep) $< $(CPPFLAGS) $($(<:$*.%=%)-CPPFLAGS) | \
sed -e 's,$(subst .,\.,$*)\.o,$(foreach o,$(object-suffixes),$(@:.d=$o)) $@,' \
# Continuation lines here are dangerous because they introduce spaces!
define sed-remove-objpfx
-e 's@ $(subst .,\.,$(subst @,\@,$(objpfx)))@ $$(objpfx)@g' \
--e 's@^$(subst .,\.,$(subst @,\@,$(objpfx)))@$$(objpfx)@g'
+-e 's@^$(subst .,\.,$(subst @,\@,$(objpfx)))@$$(objpfx)@g' \
+-e 's@ $(subst .,\.,$(subst @,\@,$(common-objpfx)))@ $$(common-objpfx)@g' \
+-e 's@^$(subst .,\.,$(subst @,\@,$(common-objpfx)))@$$(common-objpfx)@g'
endef
endif
\f
# Give libc.so an entry point and make it directly runnable itself.
LDFLAGS-c.so += -e __libc_main
# Use our own special initializer and finalizer files for libc.so.
-elfobjdir := $(firstword $(objdir) $(patsubst ../$(subdir),.,$(..)elf))
+elfobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)elf)
$(common-objpfx)libc.so: $(elfobjdir)/soinit.so \
$(common-objpfx)libc_pic.a \
$(elfobjdir)/sofini.so $(elfobjdir)/ld.so
# Create the stamp$o files to keep the parent makefile happy.
subdir_lib: $(foreach o,$(object-suffixes),$(objpfx)stamp$o-$(subdir))
$(foreach o,$(object-suffixes),$(objpfx)stamp$o-$(subdir)):
+ $(make-target-directory)
rm -f $@; > $@
else
include $(o-iterator)
define do-ar
topdir=`cd $(..).; pwd`; \
-$(patsubst %,cd %;,$(objdir)) \
+$(patsubst %/,cd %;,$(objpfx)) \
$$topdir/autolock.sh ${O%-lib}.lck $(AR) cru$(verbose) ${O%-lib} \
$(patsubst $(objpfx)%,%,$^)
rm -f $@
touch $@
endef
-ifdef subdir
-O%-lib = $(filter ../,$(firstword $(objdir) ../))$(patsubst %,$(libtype$*),c)
-else
-O%-lib = $(patsubst %,$(libtype$*),c)
-endif
+O%-lib = $(..)$(patsubst %,$(libtype$*),c)
endif
$$(RANLIB) $$(common-objpfx)$$(patsubst %,$$(libtype$o),c)
endef
ifndef subdir
-subdirs-stamps := $(foreach d,$(subdirs),\
- $(firstword $(objdir) $(subdir))/stamp%-$d)
+subdirs-stamps := $(foreach d,$(subdirs),$(common-objpfx)$d/stamp%-$d)
subdirs-stamp-o = $(subst %,$o,$(subdirs-stamps))
$(subdirs-stamps): subdir_lib;
endif
# Canned sequence for building an extra library archive.
define build-extra-lib
-$(patsubst %,cd %;,$(objdir)) \
+$(patsubst %/,cd %;,$(objpfx)) \
$(AR) cru$(verbose) $(@:$(objpfx)%=%) \
$(patsubst $(objpfx)%,%,$^)
$(RANLIB) $@
endef
# We always want to use configuration definitions.
-ifdef objdir
-# This is always used in $(common-objdir), so we use no directory name.
-BUILD_CFLAGS = -include config.h
-else
BUILD_CFLAGS = -include $(..)config.h
-endif
# Support the GNU standard name for this target.
.PHONY: check
$(addsuffix .o,$(tests) $(others)) \
$(addsuffix .out,$(tests)))
-rm -f $(addprefix $(objpfx),$(extra-objs) $(install-lib))
- -rm -f core $(objpfx)stub-$(subdir)
+ -rm -f core $(common-objpfx)stub-$(subdir)
$(rmobjs)
define rmobjs
$(foreach o,$(object-suffixes),
$(common-objpfx)stub-$(subdir): $(+depfiles)
# Use /dev/null since `...` might expand to empty.
(s=`cd $s; /bin/pwd`; \
- $(patsubst %,cd %;,$(objdir)) \
+ $(patsubst %/,cd %;,$(objpfx)) \
sed -n 's/^stub_warning *(\([^)]*\).*$$/#define __stub_\1/p' \
`sed -n 's@^.*$s/\([a-z0-9_-]*\.c\).*$$@'"$$s"/'\1@p' \
$(patsubst $(objpfx)%,%,$^) /dev/null` \