]> pd.if.org Git - zos/blob - Makefile
add a readme with a public domain note
[zos] / Makefile
1 AFLAGS=-felf64
2 AS=yasm $(AFLAGS)
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
7 OS=$(shell uname -s)
8
9 DIS= objdump -M intel -d
10
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))
15
16 #PATH:=/home/nw/src/kernel/cc/sysroot/bin:$(PATH)
17 #export PATH
18
19 CC=clang -target amd64-elf-zos
20 LD=ld
21 OBJCOPY=objcopy
22
23 ifeq ($(OS),Darwin)
24 #       CC=/opt/local/libexec/llvm-3.9/bin/clang
25         LD=x86_64-elf-ld
26         AR=x86_64-elf-ar
27         OBJCOPY=x86_64-elf-objcopy
28 endif
29
30 zos: zos64
31         $(OBJCOPY) $< -O elf32-i386 $@
32
33 usermode.o: usermode.c
34         $(CC) $(CFLAGS) -fpic -c -o $@ $<
35
36 include/errno.h: include/errno.in tools/mkerrno
37         tools/mkerrno $< > $@
38
39 libklib.a: CFLAGS+=-D_PDCLIB_restrict=restrict
40 libklib.a: $(LIBOBJS)
41         $(AR) rcu $@ $(LIBOBJS)
42
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
45
46 libvfs.a: vfs/pipes.o vfs/vfs.o
47         $(AR) rcu $@ $+
48
49 pci/func.o: pci/func.c
50
51 libpci.a: pci/pci.o pci/func.o
52         $(AR) rcu $@ $+
53
54 pic.o: pic.h interrupt.h
55
56 zos64: libklib.a
57 zos64: link64.ld
58
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 \
63        usermain.o
64 KLIBS=libpci.a libklib.a
65
66 zos64: $(KOBJS) $(KLIBS) link64.ld
67         $(LD) $(LDFLAGS) -z max-page-size=0x1000 -nostdlib $(KOBJS) $(KLIBS) -o $@
68
69 zemu: zos
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
76 cemu: zos
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
83
84 rdisk.img:
85         qemu-img create -f qcow2 $@ 1G
86
87 mem.o: mem.c mem.h multiboot.h
88 interrupt.o: interrupt.c interrupt.h
89 process.o: process.c process.h
90
91 #               -initrd TODO
92 memu: zos rdisk.img
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
100
101 cemu2: zos
102         qemu-system-x86_64 -display curses -m 512M -kernel $< -append 'mboot hb'
103
104 kernel.o: kernel.c multiboot.h
105         $(CC) $(CFLAGS) -o $@ -c $<
106
107 clean:
108         rm -f *.o *.a zos64 zos klib/*.o vfs/*.o pci/*.o ahci/*.o
109
110 %.o%.s:
111         $(AS) -o $@ $<
112
113 %.o%.c:
114         $(CC) $(CFLAGS) -c -o $@ $<
115
116 tprintk.o: printk.c
117         cc -Wall -Wno-parentheses -I. -c -o $@ $+
118
119 test: t/t_printk tprintk.o
120         t/t_printk
121
122 t/t_printk.o: t/t_printk.c
123         cc -Wall -I. -c -o $@ $+
124
125 t/t_printk: tprintk.o t/t_printk.o
126         cc -Wall -o $@ $+
127
128 %.d%.o:
129         $(DIS) $<