您的位置:首页 > 其它

揭开Makefile的神秘面纱

2014-03-20 13:12 183 查看
!if 0

Copyright (c) Microsoft Corporation. All rights reserved.

!endif

!if 0

Use of this sample source code is subject to the terms of the Microsoft

license agreement under which you licensed this sample source code. If

you did not accept the terms of the license agreement, you are not

authorized to use this sample source code. For the terms of the license,

please see the license agreement between you and Microsoft or, if applicable,

see the LICENSE.RTF on your install media or the root of your tools installation.

THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.

!endif

!if 0

Use of this source code is subject to the terms of the Microsoft end-user

license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.

If you did not accept the terms of the EULA, you are not authorized to use

this source code. For a copy of the EULA, please see the LICENSE.RTF on your

install media.

 

 

 

!endif

 

SYNCHRONIZE_DRAIN=1

 

TARGETNAME=NULLCAM

TARGETTYPE=LIBRARY

TARGETDEFNAME=$(TARGETNAME)

DEFFILE=$(TARGETDEFNAME).def

WINCETARGETFILE0=$(_RELEASELIBDIR)\$(DEFFILE)

 

TARGETLIBS= \

    $(_COMMONSDKROOT)\lib\$(_CPUINDPATH)\coredll.lib \

 

 

INCLUDES=$(INCLUDES)\

    $(_PUBLICROOT)\directx\sdk\inc

 

SOURCES= \

CameraDevice.cpp \

CameraDriver.cpp \

PinDevice.cpp \

PinDriver.cpp \

PinHardware.cpp

 

总 体而言,sources文件包含了一些用户的宏定义,这些宏定义会被Makefile和Nmake使用,来编译项目的源代码。我们知道,Nmake程序要 通过使用Makefile来知道如何对源代码进行编译,如果对于每个目录、每个项目,都要写自己的Makefile,虽然灵活性很高但是工作量非常大。有 没有一种简单的方法来使用makefile呢?比较简单的办法是可把一些makefile中对所有项目都通用的部分提取出来,对某个特定项目,只需把不同 的内容添加进来,这样就简化了对makefile的使用。sources文件就是出于此种目的而诞生的。

下图展示了makefile与sources之间的关系。




在要被构建的目录中,如果该目录包含sources文件,那么在相同目录一定还会有另外一个makefile文件。通常,此makefile值包含一行内容,如下所示:

!if 0

Copyright (c) Microsoft Corporation. All rights reserved.

!endif

!if 0

Use of this sample source code is subject to the terms of the Microsoft

license agreement under which you licensed this sample source code. If

you did not accept the terms of the license agreement, you are not

authorized to use this sample source code. For the terms of the license,

please see the license agreement between you and Microsoft or, if applicable,

see the LICENSE.RTF on your install media or the root of your tools installation.

THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.

!endif

 

#

# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source

# file to this component. This file merely indirects to the real make file

# that is shared by all the components of Windows CE

#

!INCLUDE $(_MAKEENVROOT)\makefile.def

 

 

_MAKEENVROOT是wince.bat设置的一个环境变量,通常指向wince.bat所在的目录,也就是 %_PUBLICROOT%\COMMON\OAK\MISC下。makefile.def文件几乎有3000行,是被所有windows CE项目共享的公用makefile模板,在makefile.def中定义了很多宏的具体用法和推导规则。同时,在makefile.def中还有这样 一条语句(wince5.0中第200行):

 

 

!INCLUDE.\sources.

 

 

这 样makefile.def就包含本地的sources文件。因此,当构建系统在某个目录中调用Nmake时,Nmake会去使用该目录中的 makefile,然后makefile把makefile.def展开到本地,makefile.def还会把本地的sources文件包含进了。这 样,本地sources文件中定义的宏与makefile.def中的宏共同起了作用,形成了一份完整的可悲Nmake使用的makefile。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: