环境: Ubuntu 14.04.2 LTS 64位
GCC: gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2
1. 编译流程需要三步
下载linux1.0.tar.gz然后解压至任意目录
cong@msi:/work/qemu/x86/linux$ make config
cong@msi:/work/qemu/x86/linux$ make dep
cong@msi:/work/qemu/x86/linux$ make zImage
2. Makefile修改
TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
CC =gcc -D__KERNEL__ -I$(TOPDIR)/include
-
serial.c:538:8: error: macro names must be identifiers
-
#ifdef 0
-
cong@msi:/work/qemu/x86/linux$ vi drivers/char/serial.c
-
将#ifdef 0 -->#if 0
-
-
-
buffer.c:108:8: error: macro names must be identifiers
-
#ifdef 0 /* Disable bad-block debugging code */
-
cong@msi:/work/qemu/x86/linux$ vi fs/buffer.c
-
将#ifdef 0 -->#if 0
-
sched.c:41:25: error: conflicting type qualifiers for 'xtime'
-
/work/qemu/x86/linux/sched.h:308:23: note: previous declaration of 'xtime' was here
-
将include/linux/sched.h中
-
//extern struct timeval xtime;
extern volatile struct timeval xtime;
-
cong@msi:/work/qemu/x86/linux$ as -c -o boot/head.o boot/head.s
-
boot/head.S: Assembler messages:
-
boot/head.S:64: Error: invalid instruction suffix for `push'
-
boot/head.S:65: Error: invalid instruction suffix for `popf'
-
boot/head.S:99: Error: invalid instruction suffix for `pushf
-
修改Makefile:
-
.s.o:
$(AS) $(ASFLAGS) -c -o $*.o $<
-
gcc -D__KERNEL__ -I/work/qemu/x86/linux/include -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe -m486 -c -o init/main.o init/main.c
-
gcc: error: unrecognized command line option ‘-m486’
-
修改Makefile:
还有很多有时间再整理
3.现在己经可以编译通过了,但是运行时还有点问题,先把修改的diff文件如下
change.rar(下载后改名为change.tar.gz)
阅读(1828) | 评论(0) | 转发(0) |