3 CFLAGS= -ffreestanding -mno-red-zone -mcmodel=large
4 CFLAGS= -Wall -Iinclude -Ipci -Iklib -I. -std=c99 -nostdlibinc -Wno-parentheses -ffreestanding -mcmodel=large -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -fomit-frame-pointer
5 LDFLAGS= -L. -Tlink64.ld
6 CFLAGS32= -ffreestanding -mno-red-zone -mno-mmx -mno-sse -mno-sse2
9 DIS= objdump -M intel -d
11 LIBSRC=$(wildcard klib/*.c)
12 #LIBOBJS:=$(addsuffix .o,$(basename, $(wildcard klib/*.c)))
13 LIBOBJS:=$(addsuffix .o, $(basename $(wildcard klib/*.c)))
14 #LIBOBJS:=$(addprefix klib/, $(LIBOBJS))
16 #PATH:=/home/nw/src/kernel/cc/sysroot/bin:$(PATH)
19 CC=clang -target amd64-elf-zos
24 # CC=/opt/local/libexec/llvm-3.9/bin/clang
27 OBJCOPY=x86_64-elf-objcopy
31 $(OBJCOPY) $< -O elf32-i386 $@
33 usermode.o: usermode.c
34 $(CC) $(CFLAGS) -fpic -c -o $@ $<
36 include/errno.h: include/errno.in tools/mkerrno
39 libklib.a: CFLAGS+=-D_PDCLIB_restrict=restrict
41 $(AR) rcu $@ $(LIBOBJS)
43 vfs/vfs.o: vfs/vfs.c vfs/vfs.h | include/errno.h
44 vfs/pipes.o: vfs/pipes.c vfs/vfs.h | include/errno.h
46 libvfs.a: vfs/pipes.o vfs/vfs.o
49 pci/func.o: pci/func.c
51 libpci.a: pci/pci.o pci/func.o
54 pic.o: pic.h interrupt.h
59 KOBJS= boot32.o bootz.o kernel.o interrupt.o idt.o \
60 pic.o ioport.o timer.o tty.o mem.o \
61 memx64.o spinlock.o process.o taskx64.o kbd.o \
62 cpu.o syscalls.o smp.o \
64 KLIBS=libpci.a libklib.a
66 zos64: $(KOBJS) $(KLIBS) link64.ld
67 $(LD) $(LDFLAGS) -z max-page-size=0x1000 -nostdlib $(KOBJS) $(KLIBS) -o $@
70 #qemu-system-x86_64 -d in_asm,op -m 512M -kernel $< -vnc :0
71 qemu-system-x86_64 -monitor stdio -m 256MB -kernel $< -vnc :0 -append 'mboot hb' \
72 -drive file=rdisk.img,if=none,id=mydisk \
73 -device ich9-ahci,id=ahci \
74 -device ide-drive,drive=mydisk,bus=ahci.0
75 #-device ide-hd,drive=mydisk
77 #qemu-system-x86_64 -d in_asm,op -m 512M -kernel $< -vnc :0
78 qemu-system-x86_64 -monitor stdio -m 256MB -kernel $< -display curses -append 'mboot hb' \
79 -drive file=rdisk.img,if=none,id=mydisk \
80 -device ich9-ahci,id=ahci \
81 -device ide-drive,drive=mydisk,bus=ahci.0
82 #-device ide-hd,drive=mydisk
85 qemu-img create -f qcow2 $@ 1G
87 mem.o: mem.c mem.h multiboot.h
88 interrupt.o: interrupt.c interrupt.h
89 process.o: process.c process.h
93 #qemu-system-x86_64 -d in_asm,op -m 512M -kernel $< -vnc :0
94 qemu-system-x86_64 $(SMP) -d cpu_reset -monitor stdio -m 256MB \
95 -kernel $< -append 'mboot hb' \
96 -drive file=rdisk.img,if=none,id=mydisk \
97 -device ich9-ahci,id=ahci \
98 -device ide-drive,drive=mydisk,bus=ahci.0
99 #-device ide-hd,drive=mydisk
102 qemu-system-x86_64 -display curses -m 512M -kernel $< -append 'mboot hb'
104 kernel.o: kernel.c multiboot.h
105 $(CC) $(CFLAGS) -o $@ -c $<
108 rm -f *.o *.a zos64 zos klib/*.o vfs/*.o pci/*.o ahci/*.o
114 $(CC) $(CFLAGS) -c -o $@ $<
117 cc -Wall -Wno-parentheses -I. -c -o $@ $+
119 test: t/t_printk tprintk.o
122 t/t_printk.o: t/t_printk.c
123 cc -Wall -I. -c -o $@ $+
125 t/t_printk: tprintk.o t/t_printk.o