简体   繁体   English

Windows Makefile:生成调试信息

[英]Windows makefile: generate debug information

I have to automate couple of simple builds on windows. 我必须在Windows上自动化几个简单的构建。 I am able to generate debug information if I use specific target. 如果使用特定目标,则能够生成调试信息。

My Makefile 我的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 : make Output: 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 : make Output: nmake /f Makefile.win bar.exe :make输出:

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

Notice that none of the suffix rules were executed second time. 请注意,没有第二次执行任何后缀规则。 What am I doing wrong? 我究竟做错了什么? I have added .SUFFIXES: .exe .obj at the top. 我在顶部添加了.SUFFIXES: .exe .obj

First be sure both .obj and .exe are in the suffixes list, or those suffix rules won't take effect: 首先,请确保.obj.exe都在后缀列表中,否则这些后缀规则将不会生效:

.SUFFIXES: .obj .exe

Second, using $** is very odd. 其次,使用$**非常奇怪。 Why are you adding foo* to your link line? 为什么要在链接行中添加foo* I would think you'd want something like $^ instead. 我想您会想要类似$^东西。

Other than that all I can suggest is you examine the actual linker lines that are printed by make in both situations and figure out what the difference is between them. 除此之外,我只能建议您检查两种情况下由make打印的实际链接器行,并找出它们之间的区别。 You don't show that here. 您不在这里显示。

GNU make takes the approach of modeling the entire dependency tree at once, and tracing the modified files all the way through to the output. GNU make采用了一次对整个依赖树进行建模的方法,并一直跟踪修改后的文件直至输出。 This is great if make is the only build tool you use. 如果make是您使用的唯一构建工具,那么这很好。 This doesn't work well if you have very large projects, so you need to make them in a specific order. 如果您有非常大的项目,这将无法正常工作,因此您需要按特定的顺序进行制作。 This doesn't work well if 'make' doesn't support some tools of your build process, so you would need to run make multiple times anyway. 如果'make'不支持构建过程中的某些工具,则此方法将无法正常工作,因此无论如何您都需要多次运行make。

nmake.exe takes the approach of doing the simplest possible thing: Only doing one pass at a time. nmake.exe采用最简单的方法:一次仅执行一次传递。 It assumes it will be part of a larger tool chain. 假设它将成为更大的工具链的一部分。 So if you have multi-pass dependencies, you will need multiple passes of nmake. 因此,如果您具有多遍依赖关系,则将需要多遍nmake。 If your build process requires more than 3 passes, you are probably doing A Bad Thing and you should fix your process. 如果您的构建过程需要3次以上的通过,则您可能正在做一件坏事,应该修复您的过程。 And for crying out loud, if you need multiple passes, just write a script to do it. 为了大声喊叫,如果需要多次通过,只需编写一个脚本来完成。

from here: nmake inference rules limited to depth of 1 从这里开始: nmake推理规则限于深度1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM