解读makefile和source文件

需要三个文件:
源文件(假设只有一个), MAKEFILE, SOURCE总共三个文件。
源文件是你的驱动程序了。

MAKEFILE如下:

#
# 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 driver components of the Windows NT DDK
#
!INCLUDE $(NTMAKEENV)\makefile.def
其实就一句话。一般不用修改
SOURCE文件:
TARGETNAME=WssProcMon
TARGETPATH=..\obj
TARGETTYPE=DRIVER
SOURCES=WssProcMon.c
TARGETNAME是你准备编译成文件的名字
TARGETPATH产生的驱动的目录
TARGETTYPE目标类型,当然是驱动了。
SOURCES 这里是包含的源文件程序,可以包含多个文件,我这里只有一个。
还可以有包含头文件的,需要包含下面的语句:
INCLUDES=..\inc
这是头文件包含的地方,当然,也可以直接放在当前目录下。
这样就差不多了,这样把这三个文件放在同个文件夹中。
进入ddk的编译器,然后进入该文件夹,使用命令:
build -cez
就可以看到如下的信息:
D:\工作\软件白名单系统\进程监控驱动\src>build -cez
BUILD: Adding /Y to COPYCMD so xcopy ops won’t hang.
BUILD: Using 2 child processes
BUILD: Object root set to: ==> objchk_wnet_x86
BUILD: Compile and Link for i386
BUILD: Examining d:\工作\软件白名单系统\进程监控驱动\src directory for files to compile.
BUILD: Compiling d:\工作\软件白名单系统\进程监控驱动\src directory
1>Compiling - wssprocmon.c for i386
BUILD: Linking d:\工作\软件白名单系统\进程监控驱动\src directory
1>Linking Executable - d:\工作\软件白名单系统\进程监控驱动\obj\i386\wssprocmon.sys for i386
BUILD: Done
2 files compiled
1 executable built
这样就可以看到sys文件了。
补充下:
TARGETNAME=HelloWDM //编译出来的驱动程序的名称
TARGETTYPE=DRIVER      //编译的类型是驱动程序编译
DRIVERTYPE=WDM           //驱动程序的类型是WDM驱动程序
TARGETPATH=OBJ             //生成的文件存放在OBJ目录中
INCLUDES=$(BASEDIR)\inc;\   //这是需要引入的头文件
         $(BASEDIR)\inc\ddk;\
TARGETLIBS=$(BASEDIR)\lib\*\free\usbd.lib\  //这是需要引入的库文件
SOURCES=HelloWDM.cpp\    //这是源码文件

猜你喜欢

转载自liuleijsjx.iteye.com/blog/837089