]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - scripts/Makefile.host.tmp
53fe9300be7641c497f42836bd9d7c46203d7ea1
[karo-tx-uboot.git] / scripts / Makefile.host.tmp
1
2 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
3
4 # C code
5 # Executables compiled from a single .c file
6 host-csingle    := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m)))
7
8 # C executables linked based on several .o files
9 host-cmulti     := $(foreach m,$(__hostprogs),$(if $($(m)-objs),$(m)))
10
11 # Object (.o) files compiled from .c files
12 host-cobjs      := $(sort $(foreach m,$(__hostprogs),$($(m)-objs)))
13
14 # output directory for programs/.o files
15 # hostprogs-y := tools/build may have been specified. Retrieve directory
16 host-objdirs := $(foreach f,$(__hostprogs), $(if $(dir $(f)),$(dir $(f))))
17 # directory of .o files from prog-objs notation
18 host-objdirs += $(foreach f,$(host-cmulti),                  \
19                     $(foreach m,$($(f)-objs),                \
20                         $(if $(dir $(m)),$(dir $(m)))))
21
22 host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs))))
23
24 __hostprogs     := $(addprefix $(obj)/,$(__hostprogs))
25 host-csingle    := $(addprefix $(obj)/,$(host-csingle))
26 host-cmulti     := $(addprefix $(obj)/,$(host-cmulti))
27 host-cobjs      := $(addprefix $(obj)/,$(host-cobjs))
28 host-objdirs    := $(addprefix $(obj)/,$(host-objdirs))
29
30 obj-dirs += $(host-objdirs)
31
32 #####
33 # Handle options to gcc. Support building with separate output directory
34
35 _hostc_flags   = $(HOSTCFLAGS)   $(HOST_EXTRACFLAGS)   \
36                  $(HOSTCFLAGS_$(basetarget).o)
37
38 # Find all -I options and call addtree
39 flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
40
41 ifeq ($(OBJTREE),$(SRCTREE))
42 __hostc_flags   = $(_hostc_flags)
43 else
44 __hostc_flags   = -I$(obj) $(call flags,_hostc_flags)
45 endif
46
47 hostc_flags    = $(__hostc_flags)
48
49 #####
50 # Compile programs on the host
51
52 $(host-csingle): $(obj)/%: $(src)/%.c
53         $(HOSTCC) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTLDFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $<
54
55 $(host-cmulti): $(obj)/%: $(host-cobjs)
56         $(HOSTCC) $(HOSTLDFLAGS) -o $@ $(addprefix $(obj)/,$($(@F)-objs)) $(HOSTLOADLIBES_$(@F))
57
58 $(host-cobjs): $(obj)/%.o: $(src)/%.c
59         $(HOSTCC) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c
60
61 targets += $(host-csingle)  $(host-cmulti) $(host-cobjs)