|
| 1 | +# indicate the Hardware Image file |
| 2 | +HDA_IMG = ../rootfs/hdc-0.11-new.img |
| 3 | + |
| 4 | +# indicate the path of the calltree |
| 5 | +CALLTREE=$(shell find tools/ -name "calltree" -perm 755 -type f) |
| 6 | + |
| 7 | +# indicate the path of the bochs |
| 8 | +#BOCHS=$(shell find tools/ -name "bochs" -perm 755 -type f) |
| 9 | +BOCHS=bochs |
| 10 | + |
| 11 | +# |
| 12 | +# if you want the ram-disk device, define this to be the |
| 13 | +# size in blocks. |
| 14 | +# |
| 15 | +RAMDISK = #-DRAMDISK=512 |
| 16 | + |
| 17 | +# This is a basic Makefile for setting the general configuration |
| 18 | +include Makefile.header |
| 19 | + |
| 20 | +LDFLAGS += -Ttext 0 -e startup_32 |
| 21 | +CFLAGS += $(RAMDISK) -Iinclude |
| 22 | +CPP += -Iinclude |
| 23 | + |
| 24 | +# |
| 25 | +# ROOT_DEV specifies the default root-device when making the image. |
| 26 | +# This can be either FLOPPY, /dev/xxxx or empty, in which case the |
| 27 | +# default of /dev/hd6 is used by 'build'. |
| 28 | +# |
| 29 | +ROOT_DEV= #FLOPPY |
| 30 | + |
| 31 | +ARCHIVES=kernel/kernel.o mm/mm.o fs/fs.o |
| 32 | +DRIVERS =kernel/blk_drv/blk_drv.a kernel/chr_drv/chr_drv.a |
| 33 | +MATH =kernel/math/math.a |
| 34 | +LIBS =lib/lib.a |
| 35 | + |
| 36 | +.c.s: |
| 37 | + @$(CC) $(CFLAGS) -S -o $*.s $< |
| 38 | +.s.o: |
| 39 | + @$(AS) -o $*.o $< |
| 40 | +.c.o: |
| 41 | + @$(CC) $(CFLAGS) -c -o $*.o $< |
| 42 | + |
| 43 | +all: Image |
| 44 | + |
| 45 | +Image: boot/bootsect boot/setup tools/system |
| 46 | + @cp -f tools/system system.tmp |
| 47 | + @strip system.tmp |
| 48 | + @objcopy -O binary -R .note -R .comment system.tmp tools/kernel |
| 49 | + @tools/build.sh boot/bootsect boot/setup tools/kernel Image $(ROOT_DEV) |
| 50 | + @rm system.tmp |
| 51 | + @rm tools/kernel -f |
| 52 | + @sync |
| 53 | + |
| 54 | +disk: Image |
| 55 | + @dd bs=8192 if=Image of=/dev/fd0 |
| 56 | + |
| 57 | +boot/head.o: boot/head.s |
| 58 | + @make head.o -C boot/ |
| 59 | + |
| 60 | +tools/system: boot/head.o init/main.o \ |
| 61 | + $(ARCHIVES) $(DRIVERS) $(MATH) $(LIBS) |
| 62 | + @$(LD) $(LDFLAGS) boot/head.o init/main.o \ |
| 63 | + $(ARCHIVES) \ |
| 64 | + $(DRIVERS) \ |
| 65 | + $(MATH) \ |
| 66 | + $(LIBS) \ |
| 67 | + -o tools/system |
| 68 | + @nm tools/system | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aU] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)'| sort > System.map |
| 69 | + |
| 70 | +kernel/math/math.a: |
| 71 | + @make -C kernel/math |
| 72 | + |
| 73 | +kernel/blk_drv/blk_drv.a: |
| 74 | + @make -C kernel/blk_drv |
| 75 | + |
| 76 | +kernel/chr_drv/chr_drv.a: |
| 77 | + @make -C kernel/chr_drv |
| 78 | + |
| 79 | +kernel/kernel.o: |
| 80 | + @make -C kernel |
| 81 | + |
| 82 | +mm/mm.o: |
| 83 | + @make -C mm |
| 84 | + |
| 85 | +fs/fs.o: |
| 86 | + @make -C fs |
| 87 | + |
| 88 | +lib/lib.a: |
| 89 | + @make -C lib |
| 90 | + |
| 91 | +boot/setup: boot/setup.s |
| 92 | + @make setup -C boot |
| 93 | + |
| 94 | +boot/bootsect: boot/bootsect.s |
| 95 | + @make bootsect -C boot |
| 96 | + |
| 97 | +tmp.s: boot/bootsect.s tools/system |
| 98 | + @(echo -n "SYSSIZE = (";ls -l tools/system | grep system \ |
| 99 | + | cut -c25-31 | tr '\012' ' '; echo "+ 15 ) / 16") > tmp.s |
| 100 | + @cat boot/bootsect.s >> tmp.s |
| 101 | + |
| 102 | +clean: |
| 103 | + @rm -f Image System.map tmp_make core boot/bootsect boot/setup |
| 104 | + @rm -f init/*.o tools/system boot/*.o typescript* info bochsout.txt |
| 105 | + @for i in mm fs kernel lib boot; do make clean -C $$i; done |
| 106 | +info: |
| 107 | + @make clean |
| 108 | + @script -q -c "make all" |
| 109 | + @cat typescript | col -bp | grep -E "warning|Error" > info |
| 110 | + @cat info |
| 111 | + |
| 112 | +distclean: clean |
| 113 | + @rm -f tag cscope* linux-0.11.* $(CALLTREE) |
| 114 | + @(find tools/calltree-2.3 -name "*.o" | xargs -i rm -f {}) |
| 115 | + @make clean -C tools/calltree-2.3 |
| 116 | + @make clean -C tools/bochs/bochs-2.3.7 |
| 117 | + |
| 118 | +backup: clean |
| 119 | + @(cd .. ; tar cf - linux | compress16 - > backup.Z) |
| 120 | + @sync |
| 121 | + |
| 122 | +dep: |
| 123 | + @sed '/\#\#\# Dependencies/q' < Makefile > tmp_make |
| 124 | + @(for i in init/*.c;do echo -n "init/";$(CPP) -M $$i;done) >> tmp_make |
| 125 | + @cp tmp_make Makefile |
| 126 | + @for i in fs kernel mm; do make dep -C $$i; done |
| 127 | + |
| 128 | +tag: tags |
| 129 | +tags: |
| 130 | + @ctags -R |
| 131 | + |
| 132 | +cscope: |
| 133 | + @cscope -Rbkq |
| 134 | + |
| 135 | +start: |
| 136 | + @qemu -m 16M -boot a -fda Image -hda $(HDA_IMG) |
| 137 | + |
| 138 | +bochs-start: |
| 139 | + @$(BOCHS) -q -f tools/bochs/bochsrc/bochsrc-hd.bxrc |
| 140 | + |
| 141 | +debug: |
| 142 | + @qemu -m 16M -boot a -fda Image -hda $(HDA_IMG) -s -S -nographic -serial '/dev/ttyS0' |
| 143 | + |
| 144 | +bochs-debug: |
| 145 | + @$(BOCHS) -q -f tools/bochs/bochsrc/bochsrc-hd-dbg.bxrc |
| 146 | + |
| 147 | +bochs: |
| 148 | +ifeq ($(BOCHS),) |
| 149 | + @(cd tools/bochs/bochs-2.3.7; \ |
| 150 | + ./configure --enable-plugins --enable-disasm --enable-gdb-stub;\ |
| 151 | + make) |
| 152 | +endif |
| 153 | + |
| 154 | +bochs-clean: |
| 155 | + @make clean -C tools/bochs/bochs-2.3.7 |
| 156 | + |
| 157 | +calltree: |
| 158 | +ifeq ($(CALLTREE),) |
| 159 | + @make -C tools/calltree-2.3 |
| 160 | +endif |
| 161 | + |
| 162 | +calltree-clean: |
| 163 | + @(find tools/calltree-2.3 -name "*.o" \ |
| 164 | + -o -name "calltree" -type f | xargs -i rm -f {}) |
| 165 | + |
| 166 | +cg: callgraph |
| 167 | +callgraph: |
| 168 | + @calltree -b -np -m init/main.c | tools/tree2dotx > linux-0.11.dot |
| 169 | + @dot -Tjpg linux-0.11.dot -o linux-0.11.jpg |
| 170 | + |
| 171 | +help: |
| 172 | + @echo "<<<<This is the basic help info of linux-0.11>>>" |
| 173 | + @echo "" |
| 174 | + @echo "Usage:" |
| 175 | + @echo " make --generate a kernel floppy Image with a fs on hda1" |
| 176 | + @echo " make start -- start the kernel in qemu" |
| 177 | + @echo " make debug -- debug the kernel in qemu & gdb at port 1234" |
| 178 | + @echo " make disk -- generate a kernel Image & copy it to floppy" |
| 179 | + @echo " make cscope -- genereate the cscope index databases" |
| 180 | + @echo " make tags -- generate the tag file" |
| 181 | + @echo " make cg -- generate callgraph of the system architecture" |
| 182 | + @echo " make clean -- clean the object files" |
| 183 | + @echo " make distclean -- only keep the source code files" |
| 184 | + @echo "" |
| 185 | + @echo "Note!:" |
| 186 | + @echo " * You need to install the following basic tools:" |
| 187 | + @echo " ubuntu|debian, qemu|bochs, ctags, cscope, calltree, graphviz " |
| 188 | + @echo " vim-full, build-essential, hex, dd, gcc 4.3.2..." |
| 189 | + @echo " * Becarefull to change the compiling options, which will heavily" |
| 190 | + @echo " influence the compiling procedure and running result." |
| 191 | + @echo "" |
| 192 | + @echo "Author:" |
| 193 | + @echo " * 1991, linus write and release the original linux 0.95(linux 0.11)." |
| 194 | + @echo " * 2005, jiong.zhao<gohigh@sh163.net> release a new version " |
| 195 | + @echo " which can be used in RedHat 9 along with the book 'Explaining " |
| 196 | + @echo " Linux-0.11 Completly', and he build a site http://www.oldlinux.org" |
| 197 | + @echo " * 2008, falcon<wuzhangjin@gmail.com> release a new version which can be" |
| 198 | + @echo " used in ubuntu|debian 32bit|64bit with gcc 4.3.2, and give some new " |
| 199 | + @echo " features for experimenting. such as this help info, boot/bootsect.s and" |
| 200 | + @echo " boot/setup.s with AT&T rewritting, porting to gcc 4.3.2 :-)" |
| 201 | + @echo "" |
| 202 | + @echo "<<<Be Happy To Play With It :-)>>>" |
| 203 | + |
| 204 | +### Dependencies: |
| 205 | +init/main.o: init/main.c include/unistd.h include/sys/stat.h \ |
| 206 | + include/sys/types.h include/sys/times.h include/sys/utsname.h \ |
| 207 | + include/utime.h include/time.h include/linux/tty.h include/termios.h \ |
| 208 | + include/linux/sched.h include/linux/head.h include/linux/fs.h \ |
| 209 | + include/linux/mm.h include/signal.h include/asm/system.h \ |
| 210 | + include/asm/io.h include/stddef.h include/stdarg.h include/fcntl.h |
0 commit comments