我正在尝试编译一些第三方代码并遇到了一些奇怪的 NMAKE 行为。
Makefile 中的行是
cholmod_aat.o: ../Core/cholmod_aat.c
$(C) -c $(I) $< -Fo$@
这会产生以下错误:
Wed, Aug 15 2012 23:25:20 ../Include/cholmod.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_blas.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_check.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_cholesky.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_complexity.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_config.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_core.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_internal.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_matrixops.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_modify.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_partition.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_supernodal.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_template.h
Fri, Aug 17 2012 16:06:24 ../Core/cholmod_aat.c
cholmod_aat.o target does not exist
NMAKE : warning U4006: special macro undefined : '$<'
cl -O2 -nologo -D__MINGW32__ /MD -DNPARTITION -c -I../../AMD/Include -I.
./../AMD/Source -I../../COLAMD/Include -I../../metis-4.0/Lib -I../../CCOLAMD/In
clude -I../../CAMD/Include -I../Include -I../../UFconfig -Focholmod_aat.o
cl : Command line error D8003 : missing source filename
NMAKE : fatal error U1077: '"c:\Program Files (x86)\Microsoft Visual Studio 10.0
\VC\BIN\cl.EXE"' : return code '0x2'
Stop.
为什么 nmake 事先将 cholmod_aat.c 列为依赖项时说 '$<' 是“未定义的”?更令人困惑的是,如果我将 $< 替换为 $? 在 makefile 中,nmake 扩展 '$?' 正好:
Wed, Aug 15 2012 23:25:20 ../Include/cholmod.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_blas.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_check.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_cholesky.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_complexity.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_config.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_core.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_internal.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_matrixops.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_modify.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_partition.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_supernodal.h
Wed, Aug 15 2012 23:25:20 ../Include/cholmod_template.h
Fri, Aug 17 2012 16:06:24 ../Core/cholmod_aat.c
cholmod_aat.o target does not exist
cl -O2 -nologo -D_MINGW32_ /MD -DNPARTITION -c -I../../AMD/Include -I.
./../AMD/Source -I../../COLAMD/Include -I../../metis-4.0/Lib -I../../CCOLAMD/In
clude -I../../CAMD/Include -I../Include -I../../UFconfig ../Include/cholmod.h .
./Include/cholmod_blas.h ../Include/cholmod_check.h ../Include/cholmod_cholesky.
h ../Include/cholmod_complexity.h ../Include/cholmod_config.h ../Include/cholmod
_core.h ../Include/cholmod_internal.h ../Include/cholmod_matrixops.h ../Include/
cholmod_modify.h ../Include/cholmod_partition.h ../Include/cholmod_supernodal.h
../Include/cholmod_template.h ../Core/cholmod_aat.c -Focholmod_aat.o
到底是怎么回事?