Kbuild provides per-file compiler flag addition/removal: CFLAGS_<basetarget>.o CFLAGS_REMOVE_<basetarget>.o AFLAGS_<basetarget>.o AFLAGS_REMOVE_<basetarget>.o CPPFLAGS_<basetarget>.lds HOSTCFLAGS_<basetarget>.o HOSTCXXFLAGS_<basetarget>.o The <basetarget> is the filename of the target with its directory and suffix stripped. This syntax comes into a trouble when two files with the same basename appear in one Makefile, for example: obj-y += foo.o obj-y += dir/foo.o CFLAGS_foo.o := <some-flags> Here, the <some-flags> applies to both foo.o and dir/foo.o The real world problem is: scripts/kconfig/util.c scripts/kconfig/lxdialog/util.c Both files are compiled into scripts/kconfig/mconf, but only the latter should be given with the ncurses flags. It is more sensible to use the relative path to the Makefile, like this: obj-y += foo.o CFLAGS_foo.o := <some-flags> obj-y += dir/foo.o CFLAGS_dir/foo.o := <other-flags> At first, I attempted to replace $(basetarget) with $*. The $* variable is replaced with the stem ('%') part in a pattern rule. This works with most of cases, but does not for explicit rules. For example, arch/ia64/lib/Makefile reuses rule_as_o_S in its own explicit rules, so $* will be empty, resulting in ignoring the per-file AFLAGS. I introduced a new variable, target-stem, which can be used also from explicit rules. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Marc Zyngier <maz@kernel.org>
24 lines
741 B
Makefile
24 lines
741 B
Makefile
#
|
|
# Makefile for DCN.
|
|
|
|
DCN20 = dcn20_resource.o dcn20_hwseq.o dcn20_dpp.o dcn20_dpp_cm.o dcn20_hubp.o \
|
|
dcn20_mpc.o dcn20_opp.o dcn20_hubbub.o dcn20_optc.o dcn20_mmhubbub.o \
|
|
dcn20_stream_encoder.o dcn20_link_encoder.o dcn20_dccg.o \
|
|
dcn20_vmid.o dcn20_dwb.o dcn20_dwb_scl.o
|
|
|
|
ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
|
|
DCN20 += dcn20_dsc.o
|
|
endif
|
|
|
|
ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)
|
|
cc_stack_align := -mpreferred-stack-boundary=4
|
|
else ifneq ($(call cc-option, -mstack-alignment=16),)
|
|
cc_stack_align := -mstack-alignment=16
|
|
endif
|
|
|
|
CFLAGS_$(AMDDALPATH)/dc/dcn20/dcn20_resource.o := -mhard-float -msse $(cc_stack_align)
|
|
|
|
AMD_DAL_DCN20 = $(addprefix $(AMDDALPATH)/dc/dcn20/,$(DCN20))
|
|
|
|
AMD_DISPLAY_FILES += $(AMD_DAL_DCN20)
|