Big bugfixes from trying a Clone/fork bomb
[tpg/acess2.git] / Kernel / Makefile
1 # Acess2 Kernel
2 # Root Makefile
3 # NOTE: Does some voodoo to allow differing architecture builds to co-exist
4 # - The built objects and dependency files are suffixed with the arch name
5 # - The final binary is Acess2.<ARCH>.bin
6
7 -include ../Makefile.cfg
8
9 -include arch/$(ARCHDIR)/Makefile
10
11 -include Makefile.BuildNum.$(ARCH)
12
13 KERNEL_VERSION = 0.5
14
15 MAKEDEP         = $(CC) -M
16
17 CPPFLAGS        += -I./include -I./arch/$(ARCHDIR)/include -D_MODULE_NAME_=\"Kernel\"
18 CPPFLAGS        += -DARCH=$(ARCH) -DARCHDIR=$(ARCHDIR) -DKERNEL_VERSION=$(KERNEL_VERSION) -DBUILD_NUM=$(BUILD_NUM)
19 CFLAGS          += -Wall -Werror -O3 -fno-stack-protector -fno-builtin -Wstrict-prototypes -g
20 ASFLAGS         += -D ARCH=\"$(ARCH)\" -D ARCHDIR=\"$(ARCHDIR)\"
21 LDFLAGS         += -T arch/$(ARCHDIR)/link.ld -g
22
23 ifeq ($(DEBUG_BUILD),yes)
24         LDFLAGS += -g
25         CFLAGS += -g
26 endif
27
28 OBJ := $(addprefix arch/$(ARCHDIR)/,$(A_OBJ))
29 OBJ += heap.o drvutil.o logging.o debug.o lib.o adt.o time.o
30 OBJ += messages.o modules.o syscalls.o system.o threads.o
31 OBJ += $(addprefix vfs/fs/, $(addsuffix .o,$(FILESYSTEMS)))
32 OBJ += drv/kb.o drv/vterm.o drv/proc.o drv/fifo.o drv/iocache.o drv/dma.o drv/pci.o drv/vga.o
33 OBJ += binary.o bin/elf.o bin/pe.o
34 OBJ += vfs/main.o vfs/open.o vfs/acls.o vfs/dir.o vfs/io.o vfs/mount.o vfs/memfile.o vfs/nodecache.o vfs/handle.o
35 OBJ += vfs/fs/root.o vfs/fs/devfs.o
36 OBJ += $(addprefix drv/, $(addsuffix .o,$(DRIVERS)))
37 OBJ := $(addsuffix .$(ARCH), $(OBJ))
38 MODS += $(addprefix ../Modules/, $(addsuffix .xo.$(ARCH),$(MODULES)))
39 BIN = ../Acess2.$(ARCH).bin
40 GZBIN = ../Acess2.$(ARCH).gz
41
42 DEPFILES  = $(filter %.o.$(ARCH),$(OBJ))
43 DEPFILES := $(DEPFILES:%.o.$(ARCH)=%.d.$(ARCH))
44
45 SRCFILES  = $(OBJ:%.o.$(ARCH)=%.c)
46 SRCFILES := $(SRCFILES:%.ao.$(ARCH)=%.asm)
47
48 .PHONY: all clean install apidoc
49
50 all: $(BIN)
51
52 clean:
53         @$(RM) $(BIN) ../Acess2.$(ARCH).gz $(BIN).dsm ../Map.$(ARCH).txt LineCounts.$(ARCH).txt $(OBJ) $(DEPFILES)
54
55 install: $(BIN) 
56         gzip -c $(BIN) > ../Acess2.$(ARCH).gz
57         $(xCP) ../Acess2.$(ARCH).gz $(DISTROOT)
58
59 apidoc:
60         doxygen Doxyfile.api
61
62 $(BIN): $(OBJ) $(MODS) arch/$(ARCHDIR)/link.ld Makefile
63         @echo --- LD -o $(BIN)
64         @$(LD) $(LDFLAGS) -o $(BIN) $(OBJ) $(MODS) -Map ../Map.$(ARCH).txt
65         $(DISASM) -S $(BIN) > $(BIN).dsm
66         @wc -l $(SRCFILES) include/*.h > LineCounts.$(ARCH).txt
67         @echo BUILD_NUM = $$(( $(BUILD_NUM) + 1 )) > Makefile.BuildNum.$(ARCH)
68         $(POSTBUILD)
69         @$(STRIP) $(BIN)
70
71 %.ao.$(ARCH): %.asm Makefile
72         @echo --- NASM -o $@
73         @$(AS) $(ASFLAGS) $< -o $@
74
75 %.o.$(ARCH): %.c Makefile
76 #       if exists %*/Makefile
77 #       @make -C %*/ all
78 #       else
79         @echo --- GCC -o $@
80         @$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
81         @$(MAKEDEP) $(CPPFLAGS) -MT $@ -o $*.d.$(ARCH) $<
82 #       endif
83
84 %.xo.$(ARCH):
85         @make -C $* all
86
87 include/syscalls.h:     syscalls.lst Makefile
88         php GenSyscalls.php
89
90 Makefile:       ../Makefile.cfg arch/$(ARCHDIR)/Makefile
91
92 drv/proc.o.%: Makefile.BuildNum
93
94 # Dependency Files
95 -include $(DEPFILES)

UCC git Repository :: git.ucc.asn.au