Assuming that you have the right compiler for ARM, then simply supplying a different CC=
should suffice:
make CC=gcc-arm
(assuming your ARM compiler is called gcc-arm
). You could also edit this in the makefile itself.
Remember to make clean
before compiling with a different compiler because make
does not know with which compiler might have generated existing files.
I also want to know regarding how to set the ARM compiler flags. Can I include those flags directly in the normal LDFLAGS section?
Well, if you want to give compiler flags you should give those in CFLAGS
. The LDFLAGS
variable is for linker flags. See here for more information on implicit variables. In your case there is basically no difference since you would pass both of these to the $(CC)
command, but it's not always the case.
You should modify your compilation command like this:
LDFLAGS = -lm
CFLAGS = -Wall
# ...
hellomake: $(obj)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
Then you can supply different flags from the command line (overriding those in the makefile):
make CC=gcc-arm CFLAGS='-Wall -mfpu=neon-vfpv4 -mcpu=cortex-a7'
Or you could just modify the makefile itself:
CFLAGS = -Wall -mfpu=neon-vfpv4 -mcpu=cortex-a7
As a note: make
already has an implicit value for $(CC)
, which is cc
. The cc
command is usually a link to your default compiler on Linux. Therefore you can even omit the CC = gcc
in the makefile altogether if you want.