]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - rules.mk
kbuild: change out-of-tree build
[karo-tx-uboot.git] / rules.mk
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
9 _depend:        $(obj)/.depend
10
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 := $(foreach f,$(SRCS), $(if \
15         $(filter $(if $(KBUILD_SRC),$(srctree)/)$(src)/$(notdir $f),$f), $f))
16 OTHER_SRCS := $(filter-out $(PWD_SRCS),$(SRCS))
17
18 # This is a list of dependency files to generate
19 DEPS := $(basename $(addprefix $(obj)/.depend., $(notdir $(PWD_SRCS))))
20
21 # Join all the dependencies into a single file, in three parts
22 #       1 .Concatenate all the generated depend files together
23 #       2. Add in the deps from OTHER_SRCS which we couldn't process
24 #       3. Add in the HOSTSRCS
25 $(obj)/.depend: $(TOPDIR)/config.mk $(DEPS) $(OTHER_SRCS) \
26                 $(HOSTSRCS)
27         cat /dev/null $(DEPS) >$@
28         @for f in $(OTHER_SRCS); do \
29                 g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \
30                 $(CC) -M $(CPPFLAGS) -MQ $(obj)/$$g $$f >> $@ ; \
31         done
32         @for f in $(HOSTSRCS); do \
33                 g=`basename $$f | sed -e 's/\(.*\)\.[[:alnum:]_]/\1.o/'`; \
34                 $(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)/$$g $$f >> $@ ; \
35         done
36
37 MAKE_DEPEND = $(CC) -M $(CPPFLAGS) $(EXTRA_CPPFLAGS_DEP) \
38                 -MQ $(addsuffix .o,$(obj)$(basename $<)) $< >$@
39
40
41 $(obj)/.depend.%:       $(src)/%.c
42         $(MAKE_DEPEND)
43
44 $(obj)/.depend.%:       $(src)/%.S
45         $(MAKE_DEPEND)
46
47 #########################################################################