【发布时间】:2026-01-06 10:35:01
【问题描述】:
我必须在 Windows 上自动化几个简单的构建。 如果我使用特定的目标,我能够生成调试信息。
我的 Makefile
.c.obj:
@echo executing compile rule
$(cc) $(cdebug) $(cflags) $(cvars) $*.c
.obj.exe:
@echo executing linker rule
$(link) $(ldebug) $(conflags) -out:$@ $** $(conlibs)
foo.exe: foo.obj
@echo executing target rule
$(link) $(ldebug) $(conflags) -out:$@ $** $(conlibs)
nmake /f Makefile.win foo.exe:制作输出:
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
executing compile rule
cl -Zi -Od -DDEBUG -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_X
86_=1 -DWIN32 -D_WIN32 -W3 -D_WINNT -D_WIN32_WINNT=0x0500 -DNTDDI_VERSION=0x050
00000 -D_WIN32_IE=0x0500 -DWINVER=0x0500 -D_MT -MTd foo.c
foo.c
executing target rule
link /DEBUG /DEBUGTYPE:cv /INCREMENTAL:NO /NOLOGO -subsystem:console,5.
0 -out:foo.exe foo.obj kernel32.lib ws2_32.lib mswsock.lib advapi32.lib
nmake /f Makefile.win bar.exe:制作输出:
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
cl bar.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
bar.c
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
/out:bar.exe
bar.obj
请注意,没有后缀规则被第二次执行。我究竟做错了什么?
我在顶部添加了.SUFFIXES: .exe .obj。
【问题讨论】: