rules.mk 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #
  2. # (C) Copyright 2006-2013
  3. # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. #
  5. # SPDX-License-Identifier: GPL-2.0+
  6. #
  7. #########################################################################
  8. _depend: $(obj).depend
  9. # Split the source files into two camps: those in the current directory, and
  10. # those somewhere else. For the first camp we want to support CPPFLAGS_<fname>
  11. # and for the second we don't / can't.
  12. PWD_SRCS := $(filter $(notdir $(SRCS)),$(SRCS))
  13. OTHER_SRCS := $(filter-out $(notdir $(SRCS)),$(SRCS))
  14. # This is a list of dependency files to generate
  15. DEPS := $(basename $(patsubst %,$(obj).depend.%,$(PWD_SRCS)))
  16. # Join all the dependencies into a single file, in three parts
  17. # 1 .Concatenate all the generated depend files together
  18. # 2. Add in the deps from OTHER_SRCS which we couldn't process
  19. # 3. Add in the HOSTSRCS
  20. $(obj).depend: $(src)Makefile $(TOPDIR)/config.mk $(DEPS) $(OTHER_SRCS) \
  21. $(HOSTSRCS)
  22. cat /dev/null $(DEPS) >$@
  23. @for f in $(OTHER_SRCS); do \
  24. g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \
  25. $(CC) -M $(CPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \
  26. done
  27. @for f in $(HOSTSRCS); do \
  28. g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \
  29. $(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \
  30. done
  31. MAKE_DEPEND = $(CC) -M $(CPPFLAGS) $(EXTRA_CPPFLAGS_DEP) \
  32. -MQ $(addsuffix .o,$(obj)$(basename $<)) $< >$@
  33. $(obj).depend.%: %.c
  34. $(MAKE_DEPEND)
  35. $(obj).depend.%: %.S
  36. $(MAKE_DEPEND)
  37. $(HOSTOBJS): $(obj)%.o: %.c
  38. $(HOSTCC) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c
  39. $(NOPEDOBJS): $(obj)%.o: %.c
  40. $(HOSTCC) $(HOSTCFLAGS_NOPED) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c
  41. #########################################################################