Closed MisterHW closed 1 year ago
But there is still no need for nonstandard MODE
to be part of the libscpi
. You can just pass the MODE
content to the CFLAGS
and LDFLAGS
as needed.
CFLAGS="$(MODE)" LDFLAGS="$(MODE)" make
I tried the following:
# cpu
CPU = -mcpu=cortex-m7
# fpu
FPU = -mfpu=fpv5-sp-d16
# float-abi
FLOAT-ABI = -mfloat-abi=hard
# -m options
MODE= $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
clean:
make -C libscpi clean
scpi:
CC="arm-none-eabi-gcc" AR="arm-none-eabi-ar" CFLAGS="$(MODE)" make -C libscpi static
Which appears to be working. This eliminates Option 1. Unfortunately, I don't see how that would translate to the CLion Makefile Target setup. It may not be possible at all.
Closing for now. Feel free to suggest what should happen to the associated commit.
To be able to compile the static library using the Arm GNU Toolchain, its particular tools must be used.
Subsequently, the appropriate ‘-m’ options need to be set to compile libscpi, otherwise an
error is encountered when linking in one's own project, as hard or soft floats must be used consistently.
However, "Passing variables on the command line overrides assignments in the sub-makefile but exported variables do not override assignments in the sub-makefile." (source) So it seems it is not possible to simply pass CFLAGS in the command line, and one is not supposed to export CFLAGS directly.
Option 1: Modify
libscpi/Makefile
, Export OptionsIn
libscpi/Makefile
:In one's own project directory, an additional makefile is created or amended, containing:
Option 2: Modify
libscpi/Makefile
, Pass Variable In Command LineIn
libscpi/Makefile
:CLion Example
Under
Run > Edit Configurations ...
, click+
to 'Add New Configuration' and selectMakefile Target
(see makefiles-support).The following fields need to be set, and that is where
MODE
is introduced:$PROJECT_DIR$/Third_Party/scpi-parser/libscpi/Makefile
clean static
CC=arm-none-eabi-gcc AR=arm-none-eabi-ar MODE="-mcpu=cortex-m7 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard"
$PROJECT_DIR$/Third_Party/scpi-parser/libscpi
Hint : you'll also need to specify the path to make.
Proposed Changes
Introduce variable as per https://github.com/MisterHW/scpi-parser/commit/c394eb954fe1ede45c9372e795b4705f9c7e25c9 . Compatibility: If
MODE
doesn't exist, it will be ignored.