.SUFFIXES: .c .S .o .os .oS .so .a .s .i
PHONY := FORCE
+
+.PHONY: dummy $(PHONY) \
+ all check test $(clean_targets) \
+ config dist menuconfig oldconfig release \
+ subdirs utils help
+
# order is important, the stripping uses STRIP_FLAGS for lib-so, but not for lib-a
ifeq ($(HAVE_SHARED),y)
.LIBPATTERNS: "lib%.so"
libs: $(lib-so-y) $(lib-a-y)
-$(lib-so-y): $(interp)
+$(lib-so-y): | $(interp)
else
.LIBPATTERNS: "lib%.a"
ifeq ($(UCLIBC_FORMAT_SHARED_FLAT),y)
endif
objs: all_objs
-shared_objs = $(ldso-y) $(libc-y:.o=.os) $(libc-shared-y) $(libc-nonshared-y) $(libdl-so-y)
-shared_objs += $(libcrypt-so-y) $(libintl-so-y) $(libm-so-y) $(libnsl-so-y) $(libpthread-so-y) $(libpthread-nonshared-y)
-shared_objs += $(libthread_db-so-y) $(libresolv-so-y) $(librt-so-y) $(libutil-so-y)
-ar_objs = $(libc-y) $(libc-static-y) $(libdl-a-y) $(libcrypt-a-y) $(libintl-a-y) $(libm-a-y) $(libnsl-a-y)
-ar_objs += $(libpthread-a-y) $(libthread_db-a-y) $(libresolv-a-y) $(librt-a-y) $(libutil-a-y)
+shared_objs = $(libc-y:.o=.os) $(libc-shared-y) $(libc-nonshared-y) \
+ $(libcrypt-so-y) $(libdl-so-y) \
+ $(libintl-so-y) $(libm-so-y) $(libnsl-so-y) \
+ $(libpthread-so-y) $(libpthread-nonshared-y) $(libthread_db-so-y) \
+ $(libresolv-so-y) $(librt-so-y) \
+ $(ldso-y) \
+ $(libutil-so-y)
+
+ar_objs = $(libc-y) $(libc-static-y) $(libcrypt-a-y) \
+ $(libdl-a-y) $(libintl-a-y) $(libm-a-y) $(libnsl-a-y) \
+ $(libpthread-a-y) $(libthread_db-a-y) \
+ $(libresolv-a-y) $(librt-a-y) $(libutil-a-y)
ifeq ($(DOPIC),y)
ar_objs := $(ar_objs:.o=.os)
endif
+flat_objs = $(lib-gdb-y)
ifeq ($(HAVE_SHARED),y)
all_objs: $(sort $(shared_objs) $(ar_objs))
any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
+# ../foo/bar/baz.ext -> foo_bar_baz.ext
+variablify = $(subst /,_,$(subst $(top_builddir),,$(1)))
+# strip the top_builddir off everything to make the *string* idempotent for -C
+dirify = $(subst $(top_builddir),,$(patsubst -L$(top_builddir)%,-L%,$(patsubst -I$(top_builddir)%,-I%,$(1))))
+
# True if not identical. Neither order nor whitespace nor identical flags
# matter.
-compare_flags = $(strip $(filter-out $(cmd_$(1)), $(cmd_$(@))) \
- $(filter-out $(cmd_$(@)), $(cmd_$(1))))
+compare_flags = \
+ $(strip $(filter-out $(call dirify,$(cmd_$(call variablify,$(1)))), \
+ $(call dirify,$(cmd_$(call variablify,$(@))))) \
+ $(filter-out $(call dirify,$(cmd_$(call variablify,$(@)))), \
+ $(call dirify,$(cmd_$(call variablify,$(1))))))
# Rebuild if any prerequisite, the used CC or flags changed.
# Previously used flags are stored in the corresponding .%.dep files
-maybe_exec = $(if $(strip $(compare_flags) $(any-prereq)), \
+maybe_exec = \
+ $(if $(strip $(compare_flags) $(any-prereq)), \
@set -e; \
$(disp_$(1)); \
$(cmd_$(1)); \
- echo 'cmd_$@ := $(cmd_$1)' >> $(dir $@).$(notdir $@).dep)
+ echo 'cmd_$(call variablify,$@) := $(call dirify,$(cmd_$(call variablify,$1)))' >> $(dir $@).$(notdir $@).dep)
+
CFLAGS_gen.dep = -MT $@ -MD -MP -MF $(dir $@).$(notdir $@).dep
$(CFLAGS-$(notdir $<)) \
$(CFLAGS-$(notdir $@)) \
$(CFLAGS_gen.dep)
-cmd_compile.i = $(cmd_compile.c:-c=-E -dD)
+cmd_compile.i = $(cmd_compile.c:-c=-E -dD $(EXTRA_CPPFLAGS))
cmd_compile.s = $(cmd_compile.c:-c=-S)
cmd_compile.u = $(CC) $^ $(DEPS-$(notdir $@)) -o $@ $(CFLAGS) $(CFLAGS-$(notdir $(^D))) $(CFLAGS-$(notdir $@)) $(CFLAGS_gen.dep)
cmd_compile.S = $(filter-out -std=gnu99, $(cmd_compile.c)) -D__ASSEMBLER__ $(ASFLAGS) $(ARCH_ASFLAGS) $(ASFLAGS-$(suffix $@)) $(ASFLAGS-$(notdir $<)) $(ASFLAGS-$(notdir $@))
cmd_t_strip = $(STRIPTOOL) $(STRIP_FLAGS) $@
cmd_ar = $(AR) $(ARFLAGS) $@ $^
-# special suckage alert. We try to avoid --check-symlink-times thus we touch
-# the link-target.
define do_ln
@$(disp_ln)
$(Q)$(LN) -fs
compile.s = $(call maybe_exec,compile.s)
compile.S = @$(call maybe_exec,compile.S)
compile.m = @$(call maybe_exec,compile.m)
-compile-m = @$(disp_compile-m) ; $(cmd_compile-m)
+compile-m = @$(disp_compile-m) ; $(cmd_compile-m) ; $(cmd_t_strip)
do_strip = @$(disp_strip) ; $(cmd_strip)
do_t_strip= @$(disp_t_strip) ; $(cmd_t_strip)
-do_ar = @$(disp_ar) ; $(cmd_ar)
do_unifdef= @$(disp_unifdef) ; $(cmd_unifdef)
+define do_ar
+ $(do_strip)
+ @$(disp_ar) ; $(cmd_ar)
+endef
define compile.u
@$(disp_compile.u) ; $(cmd_compile.u)
@$(disp_t_strip)
define linkm.so
$(Q)$(INSTALL) -d $(dir $@)
$(Q)$(RM) $@ $@.$(2) $(dir $@)$(1)
+ $(do_strip)
@$(disp_ld)
$(Q)$(CC) $(LDFLAGS-$(notdir $@)) -Wl,-soname=$(notdir $@).$(2) \
$(NOSTDLIB_CFLAGS) -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \
$(Q)$(INSTALL) -d $(dir $@)
$(Q)$(RM) $@
$(do_ar)
- $(do_t_strip)
$(top_builddir)lib/libpthread_nonshared.a: $(libpthread-nonshared-y)
$(Q)$(INSTALL) -d $(dir $@)
$(Q)$(RM) $@
$(do_ar)
- $(do_t_strip)
files.dep := $(libc-a-y) $(libc-so-y) $(libc-nonshared-y) \
$(libm-a-y) $(libm-so-y) \
.depends.dep := $(foreach f,$(.depends.dep),$(dir $(f)).$(notdir $(f)))
.depends.dep := $(wildcard $(.depends.dep))
-.PHONY: dummy $(PHONY)
FORCE:
clean: objclean-y headers_clean-y
objclean-y: $(objclean-y)
headers_clean-y: $(headers_clean-y)
-.PHONY: \
- all check clean realclean distclean test \
- config dist menuconfig oldconfig release \
- subdirs utils
-
ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
ifneq ($(strip $(.depends.dep)),)
.NOEXPORT:
endif
endif
+# vi: ft=make :