linux驱动之makefile详解
# If KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
ifneq ($(KERNELRELEASE),)
obj-m := hello.o
# Otherwise we were called directly from the command
# line; invoke the kernel build system.
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
endif
当我们敲下make时,我们进入了这个权威的makefile二次。第一次进入makefile,发现KERNELRELEASE没有被设置时,于是她根据build这个符号链接定位内核源代码目录,然后进入default,开始第二个make,-C选项进入内核源代码目录,找到顶层的makefile,然后-M返回当前目录执行makefile文件,这就是第二次进入这个makefile,在这次,由于KERNELRELEASE变量已经定义,因此不需要进入else语言,在这里,obj-m:=hello.o这个语句和我们以前不是驱动程序中的makefile不同,在这里内核会帮你处理一切,这句话是告诉内核,需要从hello.o创建一个驱动模型(module)。
参考文献 《linux device drivers 3》
本文来自CSDN博客,转载自:http://blog.csdn.net/abc19842008/archive/2008/02/14/2095836.aspx
相关文档:
安装OpenSSH
Ubuntu缺省没有安装SSH Server,使用以下命令安装:
sudo apt-get install openssh-server openssh-client
不过Ubuntu缺省已经安装了ssh client。
配置完成后重起:
sudo /etc/init.d/ssh restart
windows 客户端用putty连接命令shell模式
......
引:
Linux操作系统是由Linus Torvalds先生在1991年创建的,之后不断获得互联网上众多程序员的自愿支持,经过十几年的发展,如今已经成为继Windows之后的第二大电脑操作系统软件。
你是否对Linux有充分的了解呢?作为一种平台,Linux首先获得了沉溺于某种癖好之士和黑客们的
青睐。Linux操作系统是由Linus
Torvalds先生 ......
所需文件hello.c, main.c, hello.h, Makefile,在同一个目录下
hello.c:
#include <stdio.h>
void hello(char name[])
{
printf("Hello %s!\n", name);
}
main.c:
#include "stdio.h"
#include "hello.h"
// The second
int main()
{
hello("GCC");
printf("Haha Linux Ubuntu!\n");
......
文件在两个文件夹:
inc/hello.h
main/hello.c, main.c, Makefile
文件内容:
hello.h
void hello(char name[]);
hello.c
#include <stdio.h>
void hello(char name[])
{
printf("Hello %s!\n", name);
}
main.c
#include <stdio.h>
#include "../inc/hello.h"
// The second
int main( ......