-include Makefile.BuildNum.$(ARCH)
-KERNEL_VERSION = 0.5
+ifeq ($(BUILD_NUM),)
+BUILD_NUM = 0
+endif
+
+KERNEL_VERSION = $(ACESS_VERSION)
MAKEDEP = $(CC) -M
CPPFLAGS += -I./include -I./arch/$(ARCHDIR)/include -D_MODULE_NAME_=\"Kernel\"
CPPFLAGS += -DARCH=$(ARCH) -DARCHDIR=$(ARCHDIR) -DARCHDIR_IS_$(ARCHDIR)=1
-CPPFLAGS += -DKERNEL_VERSION=$(KERNEL_VERSION) -DBUILD_NUM=$(BUILD_NUM)
-CFLAGS += -Wall -Werror -fno-stack-protector -fno-builtin -Wstrict-prototypes -g
+CPPFLAGS += -DKERNEL_VERSION=$(KERNEL_VERSION)
+CFLAGS += -Wall -Werror -fno-stack-protector -Wstrict-prototypes -g
CFLAGS += -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wuninitialized
+CFLAGS += -O3
LDFLAGS += -T arch/$(ARCHDIR)/link.ld -g
OBJDIR := obj-$(ARCH)/
endif
ifeq ($(AS_SUFFIX),)
- AS_SUFFIX = s
+ AS_SUFFIX = S
endif
+BUILDINFO_OBJ := $(OBJDIR)buildinfo.o$(OBJSUFFIX)
+BUILDINFO_SRC := $(OBJDIR)buildinfo.c$(OBJSUFFIX)
+
OBJ := $(addprefix arch/$(ARCHDIR)/,$(A_OBJ))
OBJ += heap.o drvutil.o logging.o debug.o lib.o adt.o time.o
-OBJ += messages.o modules.o syscalls.o system.o threads.o
-OBJ += $(addprefix vfs/fs/, $(addsuffix .o,$(FILESYSTEMS)))
+OBJ += messages.o modules.o syscalls.o system.o
+OBJ += threads.o mutex.o semaphore.o
OBJ += drv/vterm.o drv/proc.o drv/fifo.o drv/iocache.o drv/pci.o
-#OBJ += drv/kb.o drv/dma.o drv/vga.o
OBJ += binary.o bin/elf.o bin/pe.o
OBJ += vfs/main.o vfs/open.o vfs/acls.o vfs/dir.o vfs/io.o vfs/mount.o
OBJ += vfs/memfile.o vfs/nodecache.o vfs/handle.o vfs/select.o vfs/mmap.o
BIN = ../Acess2.$(ARCH).bin
GZBIN = ../Acess2.$(ARCH).gz
-DEPFILES = $(filter %.o$(OBJSUFFIX),$(OBJ))
-DEPFILES := $(DEPFILES:%.o$(OBJSUFFIX)=%.dep$(OBJSUFFIX))
+DEPFILES := $(OBJ:%$(OBJSUFFIX)=%.dep$(OBJSUFFIX))
SRCFILES = $(OBJ:$(OBJDIR)%.o$(OBJSUFFIX)=%.c)
SRCFILES := $(SRCFILES:$(OBJDIR)%.ao$(OBJSUFFIX)=%.$(AS_SUFFIX))
+OBJ += $(BUILDINFO_OBJ)
+
.PHONY: all clean install apidoc
all: $(BIN)
clean:
# $(RM) $(BIN) ../Acess2.$(ARCH).gz $(BIN).dsm ../Map.$(ARCH).txt LineCounts.$(ARCH).txt $(OBJ) $(DEPFILES)
- @$(RM) $(BIN) ../Acess2.$(ARCH).gz $(BIN).dsm ../Map.$(ARCH).txt LineCounts.$(ARCH).txt -r $(OBJDIR) $(OBJ) $(DEPFILES)
+ @$(RM) $(BIN) ../Acess2.$(ARCH).gz $(BIN).dsm ../Map.$(ARCH).txt LineCounts.$(ARCH).txt -r $(OBJDIR) $(OBJ) $(DEPFILES) $(BUILDINFO_SRC)
install: $(BIN)
cp $(BIN) $(BIN)_
$(BIN): $(OBJ) $(MODS) arch/$(ARCHDIR)/link.ld Makefile
@echo --- LD -o $(BIN)
- @$(LD) $(LDFLAGS) -o $(BIN) $(OBJ) $(MODS) -Map ../Map.$(ARCH).txt
+ @$(LD) $(LDFLAGS) -o $(BIN) $(OBJ) $(MODS) --defsym __buildnum=$$(( $(BUILD_NUM) + 1 )) -Map ../Map.$(ARCH).txt
$(DISASM) -S $(BIN) > $(BIN).dsm
@wc -l $(SRCFILES) include/*.h > LineCounts.$(ARCH).txt
@echo BUILD_NUM = $$(( $(BUILD_NUM) + 1 )) > Makefile.BuildNum.$(ARCH)
$(POSTBUILD)
-# $(STRIP) $(BIN)
$(OBJDIR)%.ao$(OBJSUFFIX): %.$(AS_SUFFIX) Makefile
@echo --- AS -o $@
@mkdir -p $(dir $@)
@$(AS) $(ASFLAGS) $< -o $@
+ifeq ($(AS_SUFFIX),S)
+ @$(MAKEDEP) $(CPPFLAGS) -MT $@ -o $(OBJDIR)$*.ao.dep$(OBJSUFFIX) $<
+endif
$(OBJDIR)%.o$(OBJSUFFIX): %.c Makefile
# if exists %*/Makefile
@echo --- CC -o $@
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
- @$(MAKEDEP) $(CPPFLAGS) -MT $@ -o $(OBJDIR)$*.dep$(OBJSUFFIX) $<
+ @$(MAKEDEP) $(CPPFLAGS) -MT $@ -o $(OBJDIR)$*.o.dep$(OBJSUFFIX) $<
# endif
%.xo.$(ARCH):
Makefile: ../Makefile.cfg arch/$(ARCHDIR)/Makefile
-# HACK - Rebuild proc when the buildnum changes
-#$(OBJDIR)drv/proc.o$(OBJSUFFIX): Makefile.BuildNum.$(ARCH)
+$(BUILDINFO_SRC): $(filter-out $(BUILDINFO_OBJ), $(OBJ)) $(MODS) arch/$(ARCHDIR)/link.ld Makefile
+ @echo "#include <acess.h>" > $@
+ @echo "const char gsGitHash[] = \""`git log -n 1 | head -n 1 | awk '{print $$2}'`"\";" >> $@
+ @echo "const int giBuildNumber = $(BUILD_NUM);" >> $@
+$(BUILDINFO_OBJ): $(BUILDINFO_SRC)
+ @echo --- CC -o $@
+ @$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
# Dependency Files
-include $(DEPFILES)