Let's look at a specific example and find out what it does in the 4.1 kernel, for example. IHEX
.
Find what code does
Just run:
make SHELL='sh -x'
How it works: fooobar.com/questions/38647 / ...
If we select the output for IHEX
, we find the lines:
+ echo IHEX firmware/e100/d101s_ucode.bin IHEX firmware/e100/d101s_ucode.bin + objcopy -Iihex -Obinary /home/ciro/git/kernel/src/firmware/e100/d101s_ucode.bin.ihex firmware/e100/d101s_ucode.bin
therefore, we conclude that IHEX
does a objcopy -Iihex
.
Find where the code is defined
Each kernel command should be defined as follows:
quiet_cmd_ihex = IHEX $@ cmd_ihex = $(OBJCOPY) -Iihex -Obinary $< $@ $(obj)/%: $(obj)/%.ihex $(call cmd,ihex)
to configure details (e.g. V=1
and make -s
).
In general, you just need
git grep 'cmd.* = CODE'
to find the CODE
.
I explained in detail how this system works: fooobar.com/questions/921548 / ...
Get a list of all codes
make | grep -E '^ ' | sort -uk1,1
CC and CC [M]
Defined in scripts/Makefile.build
:
quiet_cmd_cc_o_c = CC $(quiet_modtag) $@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
and [M]
comes from target specific variables :
$(real-objs-m) : quiet_modtag := [M] $(real-objs-m:.o=.i) : quiet_modtag := [M] $(real-objs-m:.o=.s) : quiet_modtag := [M] $(real-objs-m:.o=.lst): quiet_modtag := [M] $(obj-m) : quiet_modtag := [M]
Then called through:
$(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE [...] $(call if_changed_rule,cc_o_c) define rule_cc_o_c [...] $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \
where if_changed_rule
defined in scripts/Kbuild.include
as:
if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \ @set -e; \ $(rule_$(1)))
and Kbuild.include
included in the top-level Makefile.
LD
There are several versions, but the easiest way:
quiet_cmd_link_o_target = LD $@ cmd_link_o_target = $(if $(strip $(obj-y)),\ $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \ $(cmd_secanalysis),\ rm -f $@ ; $(AR) rcs$(KBUILD_ARFLAGS) $@ ) $(builtin-target): $(obj-y) FORCE $(call if_changed,link_o_target)
and in scripts/Kbuild.include
:
# Execute command if command has changed or prerequisite(s) are updated.