Skip to content

Commit

Permalink
support Mac OS X
Browse files Browse the repository at this point in the history
  • Loading branch information
袁新宇 committed Apr 30, 2012
1 parent e3ed742 commit 8793585
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 34 deletions.
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
OS = Mac

# indicate the Hardware Image file
HDA_IMG = hdc-0.11.img

Expand Down Expand Up @@ -44,11 +46,11 @@ all: Image

Image: boot/bootsect boot/setup tools/system
@cp -f tools/system system.tmp
@strip system.tmp
@objcopy -O binary -R .note -R .comment system.tmp tools/kernel
@$(STRIP) system.tmp
@$(OBJCOPY) -O binary -R .note -R .comment system.tmp tools/kernel
@tools/build.sh boot/bootsect boot/setup tools/kernel Image $(ROOT_DEV)
@rm system.tmp
@rm tools/kernel -f
@rm -f tools/kernel
@sync

disk: Image
Expand Down Expand Up @@ -133,13 +135,11 @@ cscope:
@cscope -Rbkq

start:
@qemu -m 16M -boot a -fda Image -hda $(HDA_IMG)

bochs-start:
@$(BOCHS) -q -f tools/bochs/bochsrc/bochsrc-hd.bxrc
@qemu-system-x86_64 -m 16M -boot a -fda Image -hda $(HDA_IMG)

debug:
@qemu -m 16M -boot a -fda Image -hda $(HDA_IMG) -s -S -nographic -serial '/dev/ttyS0'
@echo $(OS)
@qemu-system-x86_64 -m 16M -boot a -fda Image -hda $(HDA_IMG) -s -S

bochs-debug:
@$(BOCHS) -q -f tools/bochs/bochsrc/bochsrc-hd-dbg.bxrc
Expand Down
52 changes: 35 additions & 17 deletions Makefile.header
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
# This file is the Makefile Header for every sub Makefile, which designed to
# simplfy the porting and maintaining operation
# author: falcon <[email protected]>
# update: 2008-10-29

AS = as --32
LD = ld
#LDFLAGS = -m elf_i386 -x
LDFLAGS = -m elf_i386
CC = gcc
CFLAGS = -g -m32 -fno-builtin -fno-stack-protector -fomit-frame-pointer -fstrength-reduce #-Wall

CPP = cpp -nostdinc
AR = ar

# we should use -fno-stack-protector with gcc 4.3
gcc_version=$(shell ls -l `which gcc` | tr '-' '\n' | tail -1)
UNAME := $(shell uname)

ifeq ($(UNAME), Linux)
AS = as --32
LD = ld
#LDFLAGS = -m elf_i386 -x
LDFLAGS = -m elf_i386
CC = gcc
CFLAGS = -g -m32 -fno-builtin -fno-stack-protector -fomit-frame-pointer -fstrength-reduce #-Wall

CPP = cpp -nostdinc
AR = ar
STRIP = strip
OBJCOPY = objcopy
# we should use -fno-stack-protector with gcc 4.3
gcc_version=$(shell ls -l `which gcc` | tr '-' '\n' | tail -1)
endif



ifeq ($(UNAME), Darwin)
AS = i386-elf-as --32
LD = i386-elf-ld
#LDFLAGS = -m elf_i386 -x
LDFLAGS = -m elf_i386
CC = i386-elf-gcc-4.3.2
CFLAGS = -gdwarf-2 -g3 -m32 -fno-builtin -fno-stack-protector -fomit-frame-pointer -fstrength-reduce #-Wall

CPP = i386-elf-cpp-4.3.2 -nostdinc
AR =i386-elf-ar
STRIP = i386-elf-strip
OBJCOPY = i386-elf-objcopy
endif


39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@
Linux-0.11
==========

The old Linux kernel source ver 0.11 which has been tested under modern Linux, Mac OSX and Windows.
The old Linux kernel source ver 0.11 which has been tested under modern Linux, Mac OSX and Windows.

1. Build on Linux

1.1. Linux Setup

* a linux distribution: debian , ubuntu and mint are recommended
* some tools: gcc gdb qemu
* a linux-0.11 hardware image file: hdc-0.11.img, please download it from http://www.oldlinux.org, or http://mirror.lzu.edu.cn/os/oldlinux.org/, ant put it in the root directory.

1.2. hack linux-0.11

$ make help // get help
$ make // compile
$ make start // boot it on qemu
$ make debug // debug it via qemu & gdb, you'd start gdb to connect it.

$ gdb tools/system
(gdb) target remote :1234
(gdb) b main
(gdb) c


2. Build on Mac OS X

2.1. Mac OS X Setup

* install qemu
$ sudo port install qemu
* install cross compiler gcc and binutils
$ sudo port install i386-elf-binutils i386-elf-gcc qemu
* install gdb. you need download the gdb source and compile it to use gdb because port doesn't provide i386-elf-gdb, or you can use the pre-compiled gdb in the tools directory.
* a linux-0.11 hardware image file: hdc-0.11.img

2.2. hack linux-0.11

same as section 1.2

4 changes: 2 additions & 2 deletions boot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ all: bootsect setup
bootsect: bootsect.s
@$(AS) -o bootsect.o bootsect.s
@$(LD) $(LDFLAGS) -o bootsect bootsect.o
@objcopy -R .pdr -R .comment -R.note -S -O binary bootsect
@$(OBJCOPY) -R .pdr -R .comment -R.note -S -O binary bootsect


setup: setup.s
@$(AS) -o setup.o setup.s
@$(LD) $(LDFLAGS) -o setup setup.o
@objcopy -R .pdr -R .comment -R.note -S -O binary setup
@$(OBJCOPY) -R .pdr -R .comment -R.note -S -O binary setup

head.o: head.s
@$(AS) -o head.o head.s
Expand Down
6 changes: 0 additions & 6 deletions kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ LDFLAGS += -r

CFLAGS += -I../include

#ifneq ($(gcc_version), 4.3)

#CFLAGS += -O1

#endif

CPP += -I../include

.c.s:
Expand Down
Binary file added tools/gdb
Binary file not shown.

0 comments on commit 8793585

Please sign in to comment.