]> Git Repo - u-boot.git/blame - scripts/Makefile.host.tmp
kbuild: change out-of-tree build
[u-boot.git] / scripts / Makefile.host.tmp
CommitLineData
ad71fa99
MY
1
2__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
3
4# C code
5# Executables compiled from a single .c file
6host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m)))
7
8# C executables linked based on several .o files
9host-cmulti := $(foreach m,$(__hostprogs),$(if $($(m)-objs),$(m)))
10
11# Object (.o) files compiled from .c files
12host-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
16host-objdirs := $(foreach f,$(__hostprogs), $(if $(dir $(f)),$(dir $(f))))
17# directory of .o files from prog-objs notation
18host-objdirs += $(foreach f,$(host-cmulti), \
19 $(foreach m,$($(f)-objs), \
20 $(if $(dir $(m)),$(dir $(m)))))
21
22host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs))))
23
9e414032
MY
24__hostprogs := $(addprefix $(obj)/,$(__hostprogs))
25host-csingle := $(addprefix $(obj)/,$(host-csingle))
26host-cmulti := $(addprefix $(obj)/,$(host-cmulti))
27host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
28host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
ad71fa99
MY
29
30obj-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
39flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
40
41ifeq ($(OBJTREE),$(SRCTREE))
42__hostc_flags = $(_hostc_flags)
43else
44__hostc_flags = -I$(obj) $(call flags,_hostc_flags)
45endif
46
47hostc_flags = $(__hostc_flags)
48
49#####
50# Compile programs on the host
51
9e414032 52$(host-csingle): $(obj)/%: $(src)/%.c
ad71fa99
MY
53 $(HOSTCC) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTLDFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $<
54
9e414032
MY
55$(host-cmulti): $(obj)/%: $(host-cobjs)
56 $(HOSTCC) $(HOSTLDFLAGS) -o $@ $(addprefix $(obj)/,$($(@F)-objs)) $(HOSTLOADLIBES_$(@F))
ad71fa99 57
9e414032 58$(host-cobjs): $(obj)/%.o: $(src)/%.c
ad71fa99
MY
59 $(HOSTCC) $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS_$(@F)) $(HOSTCFLAGS_$(BCURDIR)) -o $@ $< -c
60
61targets += $(host-csingle) $(host-cmulti) $(host-cobjs)
This page took 0.030341 seconds and 4 git commands to generate.