ARM A-32 的条件 Automake 编译?

Conditional Automake compilation for ARM A-32?

我有一个源文件需要为 ARM A-32 编译。 A-32 包括 ARMv4 和 ARMv7(但不包括 Aarch32 或 Aarch64)。我们的 GNU makefile 有:

IS_ARM32 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E 'arm|armhf|arm7l|eabihf')
...

ifeq ($(IS_ARM32),1)
AES_ARCH = -march=armv7-a -marm
SRCS += aes-armv4.S
endif
...

ifeq ($(IS_ARM32),1)
aes-armv4.o : aes-armv4.S
    $(CC) $(strip $(CXXFLAGS) $(AES_ARCH) -mfloat-abi=$(FP_ABI) -c) $<
endif

根据 Conditional Compilation using Automake Conditionals 手册:

An often simpler way to compile source files conditionally is to use Automake conditionals. For instance, you could use this Makefile.am construct to build the same hello example:

bin_PROGRAMS = hello
if LINUX
hello_SOURCES = hello-linux.c hello-common.c
else
hello_SOURCES = hello-generic.c hello-common.c
endif

In this case, configure.ac should setup the LINUX conditional using AM_CONDITIONAL (see Conditionals).

在条件句 link 之后,我没有看到示例中使用的 LINUX 等条件句列表。它还缺少对体系结构(如 ARM 和 PowerPC)的条件编译的讨论。

Automake 对 ARM A-32 使用什么条件?

或者如何针对 ARM A-32 进行条件编译?

Following the link to conditionals I don't see a list of the conditionals like LINUX in the manual's example. It also lacks a discussion of conditional compilation for platforms, like ARM and PowerPC.

您似乎忽略了引用的手册摘录中的这段文字:

In this case, configure.ac should setup the LINUX conditional using AM_CONDITIONAL

AM_CONDITIONAL 是 Autoconf 宏,您可以使用它定义在 Automake 条件中使用的谓词。没有预制谓词。

What does Automake use for ARM A-32?

Or how does one conditionally compile for ARM A-32?

鉴于您现有的方法是基于

IS_ARM32 := $(shell echo "$(HOSTX)" | $(GREP) -i -c -E 'arm|armhf|arm7l|eabihf')

您可以在 configure.ac 中执行此操作:

AM_CONDITIONAL([ARM32], [echo "$HOSTX" | $GREP -i -c -E 'arm|armhf|arm7l|eabihf'])

这假定 HOSTXGREP 是 autoconf 输出变量,其值已经设置。如果您不是这种情况,那么我相信它至少为您提供了一个模型。

使用 configure.ac 中定义的 ARM32 谓词,您可以在 Makefile.am 文件中使用它,就像手册中的示例一样:

if ARM32
hello_SOURCES = hello-arm32.c hello-common.c
else
hello_SOURCES = hello-generic.c hello-common.c
endif