Added some very pedantic warning flags
[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 -fno-stack-protector -fno-builtin -Wstrict-prototypes -g
20 CFLAGS      += -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wuninitialized
21 ASFLAGS         += -D ARCH=\"$(ARCH)\" -D ARCHDIR=\"$(ARCHDIR)\"
22 LDFLAGS         += -T arch/$(ARCHDIR)/link.ld -g
23
24 ifeq ($(DEBUG_BUILD),yes)
25         LDFLAGS += -g
26         CFLAGS += -g
27 endif
28
29 OBJ := $(addprefix arch/$(ARCHDIR)/,$(A_OBJ))
30 OBJ += heap.o drvutil.o logging.o debug.o lib.o adt.o time.o
31 OBJ += messages.o modules.o syscalls.o system.o threads.o
32 OBJ += $(addprefix vfs/fs/, $(addsuffix .o,$(FILESYSTEMS)))
33 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
34 OBJ += binary.o bin/elf.o bin/pe.o
35 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
36 OBJ += vfs/fs/root.o vfs/fs/devfs.o
37 OBJ += $(addprefix drv/, $(addsuffix .o,$(DRIVERS)))
38 OBJ := $(addsuffix .$(ARCH), $(OBJ))
39 MODS += $(addprefix ../Modules/, $(addsuffix .xo.$(ARCH),$(MODULES)))
40 BIN = ../Acess2.$(ARCH).bin
41 GZBIN = ../Acess2.$(ARCH).gz
42
43 DEPFILES  = $(filter %.o.$(ARCH),$(OBJ))
44 DEPFILES := $(DEPFILES:%.o.$(ARCH)=%.d.$(ARCH))
45
46 SRCFILES  = $(OBJ:%.o.$(ARCH)=%.c)
47 SRCFILES := $(SRCFILES:%.ao.$(ARCH)=%.asm)
48
49 .PHONY: all clean install apidoc
50
51 all: $(BIN)
52
53 clean:
54         @$(RM) $(BIN) ../Acess2.$(ARCH).gz $(BIN).dsm ../Map.$(ARCH).txt LineCounts.$(ARCH).txt $(OBJ) $(DEPFILES)
55
56 install: $(BIN) 
57         gzip -c $(BIN) > ../Acess2.$(ARCH).gz
58         $(xCP) ../Acess2.$(ARCH).gz $(DISTROOT)
59
60 apidoc:
61         doxygen Doxyfile.api
62
63 $(BIN): $(OBJ) $(MODS) arch/$(ARCHDIR)/link.ld Makefile
64         @echo --- LD -o $(BIN)
65         @$(LD) $(LDFLAGS) -o $(BIN) $(OBJ) $(MODS) -Map ../Map.$(ARCH).txt
66         $(DISASM) -S $(BIN) > $(BIN).dsm
67         @wc -l $(SRCFILES) include/*.h > LineCounts.$(ARCH).txt
68         @echo BUILD_NUM = $$(( $(BUILD_NUM) + 1 )) > Makefile.BuildNum.$(ARCH)
69         $(POSTBUILD)
70         @$(STRIP) $(BIN)
71
72 %.ao.$(ARCH): %.asm Makefile
73         @echo --- NASM -o $@
74         @$(AS) $(ASFLAGS) $< -o $@
75
76 %.o.$(ARCH): %.c Makefile
77 #       if exists %*/Makefile
78 #       @make -C %*/ all
79 #       else
80         @echo --- GCC -o $@
81         @$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
82         @$(MAKEDEP) $(CPPFLAGS) -MT $@ -o $*.d.$(ARCH) $<
83 #       endif
84
85 %.xo.$(ARCH):
86         @make -C $* all
87
88 include/syscalls.h:     syscalls.lst Makefile
89         php GenSyscalls.php
90
91 Makefile:       ../Makefile.cfg arch/$(ARCHDIR)/Makefile
92
93 drv/proc.o.%: Makefile.BuildNum
94
95 # Dependency Files
96 -include $(DEPFILES)

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