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