brintos

brintos / linux-shallow public Read only

0
0
Text · 2.5 KiB · 7621f55 Raw
76 lines · plain
1# SPDX-License-Identifier: GPL-2.02# ==========================================================================3# Building binaries on the host system4# Binaries are not used during the compilation of the kernel, and intended5# to be build for target board, target board can be host of course. Added to6# build binaries to run not on host system.7#8# Sample syntax9# tprogs-y := xsk_example10# Will compile xsk_example.c and create an executable named xsk_example11#12# tprogs-y    := xdpsock13# xdpsock-objs := xdpsock_1.o xdpsock_2.o14# Will compile xdpsock_1.c and xdpsock_2.c, and then link the executable15# xdpsock, based on xdpsock_1.o and xdpsock_2.o16#17# Derived from scripts/Makefile.host18#19__tprogs := $(sort $(tprogs-y))20 21# C code22# Executables compiled from a single .c file23tprog-csingle	:= $(foreach m,$(__tprogs), \24			$(if $($(m)-objs),,$(m)))25 26# C executables linked based on several .o files27tprog-cmulti	:= $(foreach m,$(__tprogs),\28			$(if $($(m)-objs),$(m)))29 30# Object (.o) files compiled from .c files31tprog-cobjs	:= $(sort $(foreach m,$(__tprogs),$($(m)-objs)))32 33tprog-csingle	:= $(addprefix $(obj)/,$(tprog-csingle))34tprog-cmulti	:= $(addprefix $(obj)/,$(tprog-cmulti))35tprog-cobjs	:= $(addprefix $(obj)/,$(tprog-cobjs))36 37#####38# Handle options to gcc. Support building with separate output directory39 40_tprogc_flags   = $(TPROGS_CFLAGS) \41                 $(TPROGCFLAGS_$(basetarget).o)42 43# $(objtree)/$(obj) for including generated headers from checkin source files44ifeq ($(KBUILD_EXTMOD),)45ifdef building_out_of_srctree46_tprogc_flags   += -I $(objtree)/$(obj)47endif48endif49 50tprogc_flags    = -Wp,-MD,$(depfile) $(_tprogc_flags)51 52# Create executable from a single .c file53# tprog-csingle -> Executable54quiet_cmd_tprog-csingle 	= CC  $@55      cmd_tprog-csingle	= $(CC) $(tprogc_flags) $(TPROGS_LDFLAGS) -o $@ $< \56		$(TPROGS_LDLIBS) $(TPROGLDLIBS_$(@F))57$(tprog-csingle): $(obj)/%: $(src)/%.c FORCE58	$(call if_changed_dep,tprog-csingle)59 60# Link an executable based on list of .o files, all plain c61# tprog-cmulti -> executable62quiet_cmd_tprog-cmulti	= LD  $@63      cmd_tprog-cmulti	= $(CC) $(tprogc_flags) $(TPROGS_LDFLAGS) -o $@ \64			  $(addprefix $(obj)/,$($(@F)-objs)) \65			  $(TPROGS_LDLIBS) $(TPROGLDLIBS_$(@F))66$(tprog-cmulti): $(tprog-cobjs) FORCE67	$(call if_changed,tprog-cmulti)68$(call multi_depend, $(tprog-cmulti), , -objs)69 70# Create .o file from a single .c file71# tprog-cobjs -> .o72quiet_cmd_tprog-cobjs	= CC  $@73      cmd_tprog-cobjs	= $(CC) $(tprogc_flags) -c -o $@ $<74$(tprog-cobjs): $(obj)/%.o: $(src)/%.c FORCE75	$(call if_changed_dep,tprog-cobjs)76