1 # SPDX-License-Identifier: GPL-2.0 2 3 # LEX 4 # -------------------------------------------- 5 quiet_cmd_flex = LEX $@ 6 cmd_flex = $(LEX) -o$@ -L $< 7 8 $(obj)/%.lex.c: $(src)/%.l FORCE 9 $(call if_changed,flex) 10 11 # YACC 12 # -------------------------------------------- 13 quiet_cmd_bison = YACC $(basename $@).[ch] 14 cmd_bison = $(YACC) -o $(basename $@).c 15 16 $(obj)/%.tab.c $(obj)/%.tab.h: $(src)/%.y FORC 17 $(call if_changed,bison) 18 19 # ============================================ 20 # Building binaries on the host system 21 # Binaries are used during the compilation of 22 # to preprocess a data file. 23 # 24 # Both C and C++ are supported, but preferred 25 # Rust is also supported, but it may only be u 26 # toolchain is required to be available (e.g. 27 # 28 # Sample syntax (see Documentation/kbuild/make 29 # hostprogs := bin2hex 30 # Will compile bin2hex.c and create an executa 31 # 32 # hostprogs := lxdialog 33 # lxdialog-objs := checklist.o lxdialog.o 34 # Will compile lxdialog.c and checklist.c, and 35 # lxdialog, based on checklist.o and lxdialog. 36 # 37 # hostprogs := qconf 38 # qconf-cxxobjs := qconf.o 39 # qconf-objs := menu.o 40 # Will compile qconf as a C++ program, and men 41 # They are linked as C++ code to the executabl 42 # 43 # hostprogs := target 44 # target-rust := y 45 # Will compile `target` as a Rust program, usi 46 # The crate may consist of several source file 47 48 # C code 49 # Executables compiled from a single .c file 50 host-csingle := $(foreach m,$(hostprogs), \ 51 $(if $($(m)-objs)$($(m 52 53 # C executables linked based on several .o fil 54 host-cmulti := $(foreach m,$(hostprogs),\ 55 $(if $($(m)-cxxobjs)$($(m)- 56 57 # Object (.o) files compiled from .c files 58 host-cobjs := $(sort $(foreach m,$(hostpr 59 60 # C++ code 61 # C++ executables compiled from at least one . 62 # and zero or more .c files 63 host-cxxmulti := $(foreach m,$(hostprogs),$( 64 65 # C++ Object (.o) files compiled from .cc file 66 host-cxxobjs := $(sort $(foreach m,$(host-c 67 68 # Rust code 69 # Executables compiled from a single Rust crat 70 # one or more .rs files) 71 host-rust := $(foreach m,$(hostprogs),$( 72 73 host-csingle := $(addprefix $(obj)/,$(host- 74 host-cmulti := $(addprefix $(obj)/,$(host- 75 host-cobjs := $(addprefix $(obj)/,$(host- 76 host-cxxmulti := $(addprefix $(obj)/,$(host- 77 host-cxxobjs := $(addprefix $(obj)/,$(host- 78 host-rust := $(addprefix $(obj)/,$(host- 79 80 ##### 81 # Handle options to gcc. Support building with 82 83 hostc_flags = -Wp,-MMD,$(depfile) \ 84 $(KBUILD_HOSTCFLAGS) $(HOST_E 85 $(HOSTCFLAGS_$(target-stem).o 86 hostcxx_flags = -Wp,-MMD,$(depfile) \ 87 $(KBUILD_HOSTCXXFLAGS) $(HOST 88 $(HOSTCXXFLAGS_$(target-stem) 89 90 # `--out-dir` is required to avoid temporaries 91 # current working directory, which may be not 92 # modules case. 93 hostrust_flags = --out-dir $(dir $@) --emit=de 94 -Clinker-flavor=gcc -Clinker= 95 -Clink-args='$(call escsq,$(K 96 $(KBUILD_HOSTRUSTFLAGS) $(HOS 97 $(HOSTRUSTFLAGS_$(target-stem 98 99 # $(objtree)/$(obj) for including generated he 100 ifeq ($(KBUILD_EXTMOD),) 101 ifdef building_out_of_srctree 102 hostc_flags += -I $(objtree)/$(obj) 103 hostcxx_flags += -I $(objtree)/$(obj) 104 endif 105 endif 106 107 ##### 108 # Compile programs on the host 109 110 # Create executable from a single .c file 111 # host-csingle -> Executable 112 quiet_cmd_host-csingle = HOSTCC $@ 113 cmd_host-csingle = $(HOSTCC) $(hostc_fl 114 $(KBUILD_HOSTLDLIBS) $(HOSTLDL 115 $(host-csingle): $(obj)/%: $(obj)/%.c FORCE 116 $(call if_changed_dep,host-csingle) 117 118 # Link an executable based on list of .o files 119 # host-cmulti -> executable 120 quiet_cmd_host-cmulti = HOSTLD $@ 121 cmd_host-cmulti = $(HOSTCC) $(KBUILD_H 122 $(addprefix $(obj)/, 123 $(KBUILD_HOSTLDLIBS) 124 $(host-cmulti): FORCE 125 $(call if_changed,host-cmulti) 126 $(call multi_depend, $(host-cmulti), , -objs) 127 128 # Create .o file from a single .c file 129 # host-cobjs -> .o 130 quiet_cmd_host-cobjs = HOSTCC $@ 131 cmd_host-cobjs = $(HOSTCC) $(hostc_fl 132 $(host-cobjs): $(obj)/%.o: $(obj)/%.c FORCE 133 $(call if_changed_dep,host-cobjs) 134 135 # Link an executable based on list of .o files 136 # host-cxxmulti -> executable 137 quiet_cmd_host-cxxmulti = HOSTLD $@ 138 cmd_host-cxxmulti = $(HOSTCXX) $(KBUILD_ 139 $(foreach o,objs cxx 140 $(addprefix $(obj)/, 141 $(KBUILD_HOSTLDLIBS) 142 $(host-cxxmulti): FORCE 143 $(call if_changed,host-cxxmulti) 144 $(call multi_depend, $(host-cxxmulti), , -objs 145 146 # Create .o file from a single .cc (C++) file 147 quiet_cmd_host-cxxobjs = HOSTCXX $@ 148 cmd_host-cxxobjs = $(HOSTCXX) $(hostcxx 149 $(host-cxxobjs): $(obj)/%.o: $(obj)/%.cc FORCE 150 $(call if_changed_dep,host-cxxobjs) 151 152 # Create executable from a single Rust crate ( 153 # one or more `.rs` files) 154 # host-rust -> Executable 155 quiet_cmd_host-rust = HOSTRUSTC $@ 156 cmd_host-rust = \ 157 $(HOSTRUSTC) $(hostrust_flags) --emit= 158 $(host-rust): $(obj)/%: $(src)/%.rs FORCE 159 +$(call if_changed_dep,host-rust) 160 161 targets += $(host-csingle) $(host-cmulti) $(ho 162 $(host-cxxmulti) $(host-cxxobjs) $(
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.