我目前正在学习如何编写makefile.我有以下makefile(它是为一个应该在ARM芯片上运行的C项目自动生成的),我正在尝试理解它:
RM := rm -rf
# All of the sources participating in the build are defined here
-include sources.mk
-include FreeRTOS/Supp_Components/subdir.mk
-include FreeRTOS/MemMang/subdir.mk
-...
-include subdir.mk
-include objects.mk
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(S_UPPER_DEPS)),)
-include $(S_UPPER_DEPS)
endif
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif
-include ../makefile.defs
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: FreeRTOS_T02.elf
# Tool invocations
FreeRTOS_T02.elf: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@'
@echo 'Invoking: MCU GCC Linker'
arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -specs=nosys.specs -specs=nano.specs -T LinkerScript.ld -Wl,-Map=output.map -Wl,--gc-sections -lm -o "FreeRTOS_T02.elf" @"objects.list" $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
$(MAKE) --no-print-directory post-build
# Other Targets
clean:
-$(RM) *
-@echo ' '
post-build:
-@echo 'Generating binary and Printing size information:'
arm-none-eabi-objcopy -O binary "FreeRTOS_T02.elf" "FreeRTOS_T02.bin"
arm-none-eabi-size "FreeRTOS_T02.elf"
-@echo ' '
.PHONY: all clean dependents
.SECONDARY: post-build
-include ../makefile.targets
Run Code Online (Sandbox Code Playgroud)
我正试图围绕$(MAKE) --no-print-directory post-build制作.elf文件的规则中的线条.
我找不到变量的定义$(MAKE),所以我认为它是内置的东西.这条线实际上在做什么?
MSa*_*ers 11
这是一个递归调用make自身,转发-t,-n和-q选项.这是有道理的:您希望嵌套make调用也可以使用这些选项运行.
从文档:
这个变量的值是调用 make 的文件名
如果要创建某个目标必须调用其makefile,但您正在使用-t( --touch)、-n( --just-print) 或-q( --question) 标志进行某种试运行,则它很有用。如果($MAKE)使用,该行为将递归传播。
| 归档时间: |
|
| 查看次数: |
8492 次 |
| 最近记录: |