How to change makefile diagnostic message when compiling [ GNU ARM GCC, Eclipse make.exe]

176 views Asked by At

I'm building a program for STM32F4 by using GNU-ARM-Gcc and Eclipse_make.exe to build the project. Everything works fine but the diagnostic message show on the terminal when compiling is too long and very hard to see. When each *.c file is compiled, the Terminal gives me a diagnostic message (see the paragraph below) can anyone give me the advice to show just a file name [delete gcc directory path, dependencies, header file path]. The makefile is generated by CubeMX. Here is makefile: https://github.com/loiefy/STM32-makefile/blob/main/Makefile

The example diagnostic message:

C:/Program Files (x86)/GNU Arm Embedded Toolchain/9 2020-q2-update/bin/arm-none-eabi-gcc -c -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32F407xx -IEngine/Src/website_c -IEngine/Inc -ILWIP/Target -IMiddlewares/Third_Party/LwIP/src/include -IMiddlewares/Third_Party/LwIP/system -IDrivers/STM32F4xx_HAL_Driver/Inc -IDrivers/STM32F4xx_HAL_Driver/Inc/Legacy -IMiddlewares/Third_Party/LwIP/src/include/netif/ppp -IMiddlewares/Third_Party/LwIP/src/apps/httpd -IDrivers/CMSIS/Device/ST/STM32F4xx/Include -IMiddlewares/Third_Party/LwIP/src/include/lwip -IMiddlewares/Third_Party/LwIP/src/include/lwip/apps -IMiddlewares/Third_Party/LwIP/src/include/lwip/priv -IMiddlewares/Third_Party/LwIP/src/include/lwip/prot -IMiddlewares/Third_Party/LwIP/src/include/netif -IMiddlewares/Third_Party/LwIP/src/include/posix -IMiddlewares/Third_Party/LwIP/src/include/posix/sys -IMiddlewares/Third_Party/LwIP/system/arch -IDrivers/CMSIS/Include -IDrivers/CMSIS/Include -IEngine/Inc -ILWIP/Target  -Og -Wall -fdata-sections -ffunction-sections -fdiagnostics-show-location=every-line -g -gdwarf-2 -MMD -MP -MF"build/mqtt.d"  -Wa,-a,-ad,-alms=build/mqtt.lst Middlewares/Third_Party/LwIP/src/apps/mqtt/mqtt.c -o build/mqtt.o

The message I want to show: Middlewares/Third_Party/LwIP/src/apps/mqtt/mqtt.c was compiled

I had spent a day finding the echo command or another command has the same purpose to show the message inside the makefile. But I found nothing.
Thank you for your help

1

There are 1 answers

3
code_fodder On BEST ANSWER

So make by default echo's each line it runs - your compiler line in the makefile:

$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 
    $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@

Will output the execution line what you can do is:

$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) 
    @echo "compiling $<"
    @$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@

Note: the @ prefix in make means dont print the command that is being executed. Hence even the echo line needs the @ otherwise you would get the echo comping... getting printed as well as compiling ...

You may or may not want to do similar for all of your outputs. I some times conditionally do one or other based on a verbosity flag that can be passed in so that when you really want to see the actual compile line you can....