揭开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。
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。
相关文章推荐
- 终于揭开了makefile之神秘面纱。。。
- 【软件测试自动化-QTP系列讲座 15】 == 揭开QTP的神秘面纱 (二)隐藏方法篇 ==
- 揭开俄罗斯“鬼谷”的神秘面纱
- 揭开Expect的神秘面纱
- 揭开观察者设计模式的神秘面纱,手把手教你写监听器
- GIS:揭开你神秘的面纱
- WCF从理论到实践(1):揭开神秘面纱
- 带你一步一步揭开Rxjava2.0的神秘面纱(1)
- [转]揭开正则表达式的神秘面纱
- 揭开宏的神秘面纱:什么是宏,为什么使用宏?
- 揭开云计算的神秘面纱――云,飘向哪端?
- keil 揭开PC-Lint9的神秘面纱
- 揭开“定点攻击”的神秘面纱
- block介绍(四)揭开神秘面纱(下)
- 艾伟:WCF从理论到实践(1):揭开神秘面纱
- 揭开Java IO流中的flush()的神秘面纱
- 揭开正则表达式的神秘面纱
- 揭开PC-Lint9的神秘面纱
- 揭开J2EE集群的神秘面纱(五)
- 揭开.NET消息循环的神秘面纱