2016-10-30 21 views
0

私はこのメイクファイルを持っていますが、実際には仕事をしていますが、それほど美しくはないと感じています。私の目標は単純です。誰かが「make」を初めて呼び出すと、コンパイルとステージングの両方が実行されますが、makeを連続して呼び出すと、コンパイルのみが呼び出されます。ユーザーがステージングを実行したい場合、ユーザーは「ステージングを行う」必要があります。誰もが良いアイデアを持っていますか?このルールの代わりにmakefileのルールを呼び出す

all: compile 

.PHONY: compile staging               

compile: 
    @echo "compile" 
    @test -f ./.staging || make ./.staging 

force_staging: 
    @rm -f ./.staging 

staging: force_staging compile 
    @: 

./.staging: 
    @echo "staging" 
    @touch [email protected] 

答えて

0

代わりのファイルの存在のためのテスト、私はあなたがこれはorder only依存関係のための仕事のように聞こえる.staging

all: compile 

.PHONY: compile 

compile: ./.staging 
    @echo "compile" 

force_staging: 
    @rm -f ./.staging 

staging: force_staging compile 
    @: 

./.staging: 
    @echo "staging" 
    @touch [email protected] 
+0

申し訳ありませんが、最初にステージングする前に実行する必要があります –

+0

あなたのアプローチはこのタスクに最適です – igagis

0

に依存関係を追加することができると思う:

all: compile 

compile: | .staging 
    echo [email protected] 
    touch [email protected] 

.staging: 
    echo [email protected] 
    touch [email protected] 

staging: .staging compile 

気付いた場合は、そのユーザmake stagingの場合は.stagingが通常のターゲットになり、古い場合は再構築されます。ユーザーがmake allを実行した場合、.stagingは存在しない場合にのみ再構築されます。

関連する問題