build: add a "user" arch to allow the kernel to run as a program on the host machine

This commit is contained in:
2023-02-25 17:58:23 +00:00
parent 8c87e78797
commit eed73e2414
21 changed files with 286 additions and 26 deletions

View File

@@ -1,6 +1,6 @@
KERNEL_EXEC := socks_kernel
ARCH := x86_64
SOCKS_ARCH ?= x86_64
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
ROOT_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
@@ -13,7 +13,7 @@ BUILD_DIR := build
# Architecture-specific source files
####################################
include arch/$(ARCH)/config.mk
include arch/$(SOCKS_ARCH)/config.mk
####################################
# Platform-independent kernel source files
@@ -31,10 +31,10 @@ LIBC_SRC_DIRS := stdio string ctype
LIBC_C_FILES := $(foreach dir,$(LIBC_SRC_DIRS),$(wildcard libc/$(dir)/*.c))
LIBC_OBJ := $(addprefix $(BUILD_DIR)/,$(LIBC_C_FILES:.c=.o))
BUILD_ID := $(shell tools/generate_build_id.py --arch $(ARCH))
BUILD_ID := $(shell tools/generate_build_id.py --arch $(SOCKS_ARCH))
CFLAGS := $(CFLAGS) -DBUILD_ID=\"$(BUILD_ID)\" -g -Wall -Werror -pedantic \
-Iinclude -Iarch/$(ARCH)/include -Ilibc/include -Os
-Iinclude -Iarch/$(SOCKS_ARCH)/include -Ilibc/include -Os
ASMFLAGS := $(ASMFLAGS) -DBUILD_ID=\"$(BUILD_ID)\"
LDFLAGS := $(LDFLAGS) -g -Os
@@ -77,7 +77,7 @@ compile-db: $(BUILD_DIR)/compile_commands.json
tools:
@$(MAKE) --no-print-directory -C tools
include arch/$(ARCH)/extra.mk
include arch/$(SOCKS_ARCH)/extra.mk
.PHONY: all tools compile-db $(BUILD_DIR)/compile_commands.json