GNU Make では、注文のみのターゲットを指定できます。
[...] ルールの 1 つが実行された場合にターゲットを強制的に更新せずに、呼び出すルールに特定の順序を課したい場合があります。その場合、注文のみの前提条件を定義します。注文のみの前提条件は、パイプ記号 (|) を前提条件リストに配置することで指定できます。パイプ記号の左側の前提条件はすべて正常です。右側の前提条件は注文のみです。
targets : normal-prerequisites | order-only-prerequisites
注文のみの前提条件は含まれていません$^
。を使用してそれらを参照できます$|
。
これは、システム ライブラリをリンク用の追加の依存関係として指定するのに便利です。
CXX = cl
CXXFLAGS = /nologo /W4 /EHsc /MD
RC = rc
RCFLAGS = /nologo
# Link executables; $^ = all prerequisites; $| = order-only prerequisites
%.exe: %.obj %.res
$(CXX) $(CXXFLAGS) /Fe$@ $^ $|
# Compile source files
%.obj: %.cpp
$(CXX) $(CXXFLAGS) /c /Fo$@ $^
# Compile resource files
%.res: %.rc
$(RC) $(RCFLAGS) /r /fo$@ $^
# System libraries needed for linking. Specify them as order-only prerequisites
# so their (no-op) rule being executed (due to their absence from the build
# directory) won't make the target appear out of date.
ErrorShow.exe: | user32.lib
Singleton.exe: | user32.lib advapi32.lib
ProcessInfo.exe: | user32.lib advapi32.lib gdi32.lib
# Set libraries as no-op targets to satisfy rule existence requirement.
advapi32.lib:
gdi32.lib:
user32.lib:
Microsoft NMAKE に同等の機能を持たせる方法はありますか?