2016-08-16 5 views
2

私は現在、メークファイルの書き方を学んでいます。私は(自動的に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: [email protected]' 
     @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: [email protected]' 
     @echo ' ' 
     $(MAKE) --no-print-directory post-build 

    # Other Targets 
    clean: 
     -$(RM) * 
     [email protected] ' ' 

    post-build: 
     [email protected] '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" 
     [email protected] ' ' 

    .PHONY: all clean dependents 
    .SECONDARY: post-build 

    -include ../makefile.targets 

私は私の頭をラップしようとしています.elfファイルを作成するためのルールの中で、$(MAKE) --no-print-directory post-buildという行の周りにあります。

変数$(MAKE)の定義が見つかりません。そのため、何か組み込みであると仮定します。この行は実際に何をしていますか? docsから

+1

https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html#MAKE-Variable – Notlikethat

答えて

3

make自体を再帰的に呼び出して、-t,-nおよび-qのオプションを転送します。これは理にかなっています。ネストしたmake呼び出しをこれらのオプションとともに実行したいとします。

+0

ありがとうございました。私は別の(本当に関連していない)質問があります。ポストビルドで '@ echo'コマンドの前に' -'文字があるのはなぜですか?実行可能ファイルを作成するためのルール内の '@ echo'コマンドはそれを持っていません。 –

+0

@ K.Mulier:[この既存のQ&A](http://stackoverflow.com/a/14248293/15416)を参照してください。 – MSalters

1

この変数の値は

を呼び出した作りとファイル名でそれはあなたが呼び出す必要があるだろういくつかの目標を作るために場合に便利ですそのメイクができますが、-tで予行演習のいくつかの並べ替えを行っている(--touch)、-n--just-print)、または-q--question)フラグ。 ($MAKE)を使用すると、その動作は再帰的に伝播します。

+0

"makeが呼び出されたファイル名"とはどういうものですか? –

+1

docの段落の残り:*このファイル名が/ bin/makeの場合、実行されたレシピは 'cd subdir &&/bin/make'です。特別なバージョンのmakeを使ってトップレベルのmakefileを実行すると、再帰的な呼び出しのために同じ特別なバージョンが実行されます* – Daerdemandt

+0

したがって、C:\ Apps \ SysGCCファイルをダブルクリックしてGNU makeプログラムを起動すると\ arm-eabi \ bin \ make.exe'を実行すると、$(MAKE)変数は文字列 "C:¥Apps¥SysGCC¥arm-eabi¥bin¥make.exe"に展開されますか? –

関連する問題