'What's the difference between these 2 pieces of Makefile.am code?

I am completely new to using autotools so it might be a dumb question but I'll try anyway. I have two pieces of Makefile.am. Except one is working fine and the other is not.

This works fine.

sbin_PROGRAMS = kernel
kernel_SOURCES = \
    src/arch/$(host_cpu)/arch_sysdefs.h \
    src/arch/$(host_cpu)/boot.asm \
    src/arch/$(host_cpu)/cpu.asm \
    src/arch/$(host_cpu)/isr.asm \
    src/kmain.cpp

But this doesn't. .asm files are completely ignored by generated Makefile.

if HOST_CPU_X86
ASM_EXT = .asm
else
ASM_EXT = .S
endif

sbin_PROGRAMS = kernel
kernel_SOURCES = \
    src/arch/$(host_cpu)/arch_sysdefs.h \
    src/arch/$(host_cpu)/boot$(ASM_EXT) \
    src/arch/$(host_cpu)/cpu$(ASM_EXT) \
    src/arch/$(host_cpu)/isr$(ASM_EXT) \
    src/kmain.cpp

What I am trying to do is that I want to use different suffixes for assembly files for some CPUs my project is going to support.

I've also added necessary rule to transform .asm to object files.

.asm.o:
    yasm -f $(YASM_OUT_FMT) $< -o $@

EDIT: Temporarily overriding .cpp.o rule with echo $(kernel_SOURCES) reveals that $(ASM_EXT) in kernel_SOURCES is substituted correctly. For example src/arch/$(host_cpu)/boot$(ASM_EXT) becomes src/arch/x86_64/boot.asm for x86-64 CPU and src/arch/arm/boot.S for ARM, etc. Also, setting ASM_EXT variable from autoconf.ac doesn't make any difference.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source