makefileにオプションを渡す

makefileにオプションを渡す

ファイルの生成

my_test:
ifdef $(toto)
        @echo 'toto is defined'
else
        @echo 'no toto around'
endif

予想される動作

$ make my_test
no toto around

$ make my_test toto
toto is defined

現在の行動

$ make my_test
no toto around

$ make my_test toto
no toto around
make: *** No rule to make target `toto'.  Stop.

実行すると、make my_test予想どおりelseテキストが表示されますno toto around。しかし、

make my_test toto
no toto around
make: *** No rule to make target `toto'.  Stop.

ファイルバージョンの作成

 $ make -v
   GNU Make 3.81

SLEバージョン

$ cat /etc/*release
  VERSION_ID="11.4"
  PRETTY_NAME="SUSE Linux Enterprise Server 11 SP4"

ポリスチレン

ポイントはmake my_testifを指定することですtotototo指定しない場合、コマンドは自動的に実行されます。

ベストアンサー1

totoの周りのドルを削除し、別の方法でコマンドラインからtotoを渡す必要があります。

コマンドライン

make toto=1  my_test

ファイルの生成

my_test:
ifdef toto
        @echo 'toto is defined'
else
        @echo 'no toto around'
endif

おすすめ記事