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
7 -include ../Makefile.cfg
9 -include arch/$(ARCHDIR)/Makefile
11 -include Makefile.BuildNum.$(ARCH)
17 KERNEL_VERSION = $(ACESS_VERSION)
21 CPPFLAGS += -I./include -I./arch/$(ARCHDIR)/include -D_MODULE_NAME_=\"Kernel\"
22 CPPFLAGS += -DARCH=$(ARCH) -DARCHDIR=$(ARCHDIR) -DARCHDIR_IS_$(ARCHDIR)=1
23 CPPFLAGS += -DKERNEL_VERSION=$(KERNEL_VERSION)
24 CFLAGS += -Wall -Werror -fno-stack-protector -Wstrict-prototypes -g
25 CFLAGS += -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wuninitialized
27 LDFLAGS += -T arch/$(ARCHDIR)/link.ld -g
29 OBJDIR := obj-$(ARCH)/
30 #OBJSUFFIX := .$(ARCH)
32 ifeq ($(DEBUG_BUILD),yes)
41 BUILDINFO_OBJ := $(OBJDIR)buildinfo.o$(OBJSUFFIX)
42 BUILDINFO_SRC := $(OBJDIR)buildinfo.c$(OBJSUFFIX)
44 OBJ := $(addprefix arch/$(ARCHDIR)/,$(A_OBJ))
45 OBJ += heap.o drvutil.o logging.o debug.o lib.o adt.o time.o
46 OBJ += messages.o modules.o syscalls.o system.o
47 OBJ += threads.o mutex.o semaphore.o
48 OBJ += drv/vterm.o drv/proc.o drv/fifo.o drv/iocache.o drv/pci.o
49 OBJ += binary.o bin/elf.o bin/pe.o
50 OBJ += vfs/main.o vfs/open.o vfs/acls.o vfs/dir.o vfs/io.o vfs/mount.o
51 OBJ += vfs/memfile.o vfs/nodecache.o vfs/handle.o vfs/select.o vfs/mmap.o
52 OBJ += vfs/fs/root.o vfs/fs/devfs.o
53 OBJ += $(addprefix drv/, $(addsuffix .o,$(DRIVERS)))
55 OBJ := $(addsuffix $(OBJSUFFIX), $(OBJ))
56 OBJ := $(addprefix $(OBJDIR), $(OBJ))
58 MODS += $(addprefix ../Modules/, $(addsuffix .xo.$(ARCH),$(MODULES)))
59 BIN = ../Acess2.$(ARCH).bin
60 GZBIN = ../Acess2.$(ARCH).gz
62 DEPFILES := $(OBJ:%$(OBJSUFFIX)=%.dep$(OBJSUFFIX))
64 SRCFILES = $(OBJ:$(OBJDIR)%.o$(OBJSUFFIX)=%.c)
65 SRCFILES := $(SRCFILES:$(OBJDIR)%.ao$(OBJSUFFIX)=%.$(AS_SUFFIX))
67 OBJ += $(BUILDINFO_OBJ)
69 .PHONY: all clean install apidoc
74 # $(RM) $(BIN) ../Acess2.$(ARCH).gz $(BIN).dsm ../Map.$(ARCH).txt LineCounts.$(ARCH).txt $(OBJ) $(DEPFILES)
75 @$(RM) $(BIN) ../Acess2.$(ARCH).gz $(BIN).dsm ../Map.$(ARCH).txt LineCounts.$(ARCH).txt -r $(OBJDIR) $(OBJ) $(DEPFILES) $(BUILDINFO_SRC)
80 gzip -c $(BIN)_ > ../Acess2.$(ARCH).gz
82 $(xCP) ../Acess2.$(ARCH).gz $(DISTROOT)
87 $(BIN): $(OBJ) $(MODS) arch/$(ARCHDIR)/link.ld Makefile
88 @echo --- LD -o $(BIN)
89 @$(LD) $(LDFLAGS) -o $(BIN) $(OBJ) $(MODS) --defsym __buildnum=$$(( $(BUILD_NUM) + 1 )) -Map ../Map.$(ARCH).txt
90 $(DISASM) -S $(BIN) > $(BIN).dsm
91 @wc -l $(SRCFILES) include/*.h > LineCounts.$(ARCH).txt
92 @echo BUILD_NUM = $$(( $(BUILD_NUM) + 1 )) > Makefile.BuildNum.$(ARCH)
95 $(OBJDIR)%.ao$(OBJSUFFIX): %.$(AS_SUFFIX) Makefile
98 @$(AS) $(ASFLAGS) $< -o $@
100 @$(MAKEDEP) $(CPPFLAGS) -MT $@ -o $(OBJDIR)$*.ao.dep$(OBJSUFFIX) $<
103 $(OBJDIR)%.o$(OBJSUFFIX): %.c Makefile
104 # if exists %*/Makefile
109 @$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
110 @$(MAKEDEP) $(CPPFLAGS) -MT $@ -o $(OBJDIR)$*.o.dep$(OBJSUFFIX) $<
114 @BUILDTYPE=static make -C $* all
116 include/syscalls.h include/syscalls.inc.asm: syscalls.lst Makefile GenSyscalls.pl
119 Makefile: ../Makefile.cfg arch/$(ARCHDIR)/Makefile
121 $(BUILDINFO_SRC): $(filter-out $(BUILDINFO_OBJ), $(OBJ)) $(MODS) arch/$(ARCHDIR)/link.ld Makefile
122 @echo "#include <acess.h>" > $@
123 @echo "const char gsGitHash[] = \""`git log -n 1 | head -n 1 | awk '{print $$2}'`"\";" >> $@
124 @echo "const int giBuildNumber = $(BUILD_NUM);" >> $@
125 $(BUILDINFO_OBJ): $(BUILDINFO_SRC)
127 @$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<