Instruct Automake to use C++ compiler for *.S files?

Clash Royale CLAN TAG#URR8PPPInstruct Automake to use C++ compiler for *.S files?
We have a C++ project. We need to assemble a *.S file through the compiler. In our GNUmakefile we use:
*.S
GNUmakefile
# ARM asm implementation.
aes-armv4.o : aes-armv4.S
$(CXX) $(CXXFLAGS) $(AES_FLAGS) -mfloat-abi=$(FP_ABI) -c $<
We have the following in our Makefile.am, which depends on AC_SUBST([AES_FLAGS], [-march=armv7-a -Wa,--noexecstack]) in configure.ac:
Makefile.am
AC_SUBST([AES_FLAGS], [-march=armv7-a -Wa,--noexecstack])
configure.ac
libaes_armv4_la_SOURCES = aes-armv4.S
libaes_armv4_la_CXXFLAGS = $(AM_CXXFLAGS) $(AES_FLAGS)
However, the resulting Makefile uses the C compiler and fails to use the flags we setup for the source file:
Makefile
C
make[1]: Entering directory '/home/build/cryptopp'
/bin/bash ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -g -O2 -MT aes-armv4.lo -MD -MP -MF .deps/aes-armv4.Tpo -c -o aes-armv4.lo aes-armv4.S
libtool: compile: gcc -DHAVE_CONFIG_H -I. -g -O2 -MT aes-armv4.lo -MD -MP -MF .deps/aes-armv4.Tpo -c aes-armv4.S -fPIC -DPIC -o .libs/aes-armv4.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -g -O2 -MT aes-armv4.lo -MD -MP -MF .deps/aes-armv4.Tpo -c aes-armv4.S -o aes-armv4.o >/dev/null 2>&1
mv -f .deps/aes-armv4.Tpo .deps/aes-armv4.Plo
AES_FLAGS provides -march=armv7-a -Wa,--noexecstack. -march=armv7-a increases performance due to unaligned loads and -Wa,--noexecstack is a security requirement.
AES_FLAGS
-march=armv7-a -Wa,--noexecstack
-march=armv7-a
-Wa,--noexecstack
The manual does not state how to tell Autotools to use the C++ compiler in this instance. Also see 8.9 C++ Support.
How do I tell Automake to use the C++ compiler and flags for the source file?
Our configure.ac has the following. It lacks a reference to the C compiler and never touches AC_PROG_CC, CFLAGS or AM_CFLAGS because we are a C++ project:
configure.ac
AC_PROG_CC
CFLAGS
AM_CFLAGS
AC_PROG_CXX
AC_LANG([C++])
...
AC_SUBST([AES_FLAGS], [-march=armv7-a -Wa,--noexecstack])
Thanks @Sam, that was it. Do you want to answer?
– jww
3 hours ago
1 Answer
1
automake uses the CCAS macro to specify which compiler to run, using CCASFLAGS and AM_CCASFLAGS to specify any custom compilation options.
CCAS
CCASFLAGS
AM_CCASFLAGS
More information
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
gnu.org/software/automake/manual/html_node/…
– Sam Varshavchik
3 hours ago