当前位置: 技术问答>linux和unix
我想在我的交叉编译环境中写一个最简单的驱动?请问如何编译?
来源: 互联网 发布时间:2016-02-29
本文导语: /* * $Id: hello.c,v 1.5 2004/10/26 03:32:21 corbet Exp $ */ #...
/*
* $Id: hello.c,v 1.5 2004/10/26 03:32:21 corbet Exp $
*/
#include
#include
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello, worldn");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel worldn");
}
module_init(hello_init);
module_exit(hello_exit);
就比如这个来自LDD3的源代码
我的交叉编译工具是mips-linux-g++
请问这样编译或者写makefile文件
* $Id: hello.c,v 1.5 2004/10/26 03:32:21 corbet Exp $
*/
#include
#include
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello, worldn");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel worldn");
}
module_init(hello_init);
module_exit(hello_exit);
就比如这个来自LDD3的源代码
我的交叉编译工具是mips-linux-g++
请问这样编译或者写makefile文件
|
CROSS_COMPILE=/home/guys/starwave-ppc/staging_dir_powerpc/bin/powerpc-linux-uclibc-
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
RM = rm
KMOD = hello
LINUX = /home/guys/starwave-ppc/build_powerpc/linux
SYS_INC = /home/guys/starwave-ppc/staging_dir_powerpc/bin/../lib/gcc/powerpc-linux-uclibc/3.4.6/include
CINCS = -I . -I include -I inc -I $(LINUX)/include -I $(LINUX)/arch/ppc
-I $(LINUX)/arch/ppc/include
CFLAG = -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs
-fno-strict-aliasing -fno-common -ffreestanding -O2
-fomit-frame-pointer -Iarch/ppc -msoft-float -pipe -ffixed-r2
-mmultiple -mstring -Wa,-maltivec -Wdeclaration-after-statement
DFLAGS = -DMODULE -DKBUILD_BASENAME=$(KMOD) -DKBUILD_MODNAME=$(KMOD)
CFLAGS = -m32 -Wp,-MD,.$(KMOD).o.d
-nostdinc -isystem $(SYS_INC)
-D__KERNEL__ $(CINCS) $(CFLAG)
SRCS = $(KMOD).mod.o $(KMOD).o
OBJS = $(SRCS)
all: $(KMOD)
@echo "Look for $
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
RM = rm
KMOD = hello
LINUX = /home/guys/starwave-ppc/build_powerpc/linux
SYS_INC = /home/guys/starwave-ppc/staging_dir_powerpc/bin/../lib/gcc/powerpc-linux-uclibc/3.4.6/include
CINCS = -I . -I include -I inc -I $(LINUX)/include -I $(LINUX)/arch/ppc
-I $(LINUX)/arch/ppc/include
CFLAG = -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs
-fno-strict-aliasing -fno-common -ffreestanding -O2
-fomit-frame-pointer -Iarch/ppc -msoft-float -pipe -ffixed-r2
-mmultiple -mstring -Wa,-maltivec -Wdeclaration-after-statement
DFLAGS = -DMODULE -DKBUILD_BASENAME=$(KMOD) -DKBUILD_MODNAME=$(KMOD)
CFLAGS = -m32 -Wp,-MD,.$(KMOD).o.d
-nostdinc -isystem $(SYS_INC)
-D__KERNEL__ $(CINCS) $(CFLAG)
SRCS = $(KMOD).mod.o $(KMOD).o
OBJS = $(SRCS)
all: $(KMOD)
@echo "Look for $