aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas <nbnoll@eml.cc>2021-11-15 15:05:18 -0800
committerNicholas <nbnoll@eml.cc>2021-11-15 15:05:18 -0800
commit27d656be97f1544d7535d8c144ff28b9214aed97 (patch)
treeb9ae0f24e6979da36685cb44ef1cb93ad245802c
parent0369b1505b019becfb74ccd9c82f9f7700af377a (diff)
Chore: updated build paths
-rwxr-xr-xbin/updatedirs3
-rw-r--r--rules.mk44
-rw-r--r--src/base/rules.mk2
3 files changed, 36 insertions, 13 deletions
diff --git a/bin/updatedirs b/bin/updatedirs
index b304251..850fe1a 100755
--- a/bin/updatedirs
+++ b/bin/updatedirs
@@ -11,6 +11,9 @@ if __name__ == "__main__":
if not os.path.exists(BUILD):
os.mkdir(BUILD)
+ if not os.path.exists(f"{BUILD}/sys"):
+ os.mkdir(f"{BUILD}/sys")
+
if not os.path.exists(TEST):
os.mkdir(TEST)
diff --git a/rules.mk b/rules.mk
index f01c791..f6d1603 100644
--- a/rules.mk
+++ b/rules.mk
@@ -4,16 +4,16 @@
all: targets
-debug: CC := clang
+debug: CC := clang
debug: CFLAGS += -DDEBUG -g -fsanitize=address
-debug: INCS := -I $(INC_DIR)
-debug: ELIBS := -fsanitize=address
+debug: INCS := -I $(INC_DIR)
+debug: ELIBS := -fsanitize=address
debug: STATIC :=
-debug: CINIT :=
-debug: CFINI :=
+debug: CINIT :=
+debug: CFINI :=
debug: targets
-release: CFLAGS += -O2 -mtune=native -flto -ffast-math #-DNDEBUG
+release: CFLAGS += -O2 -mtune=native -flto #-DNDEBUG
release: targets
# Targets & array of sources & intermediates
@@ -27,17 +27,37 @@ TEST :=
GENS :=
-# Iterate through directory tree
+# iterate through source directory tree
DIR := src
include $(DIR)/rules.mk
-# Generic rules
+# generic rules
%.a: %.o
$(ARCHIVE)
%: %.o
$(LINK)
+# explicit system layer
+SYS := $(OBJ_DIR)/sys/sys.a
+
+SYS_SRCS := $(sort $(wildcard $(SYS_DIR)/src/*.c))
+
+SYS_OBJS := $(filter %.o, $(SYS_SRCS:.c=.o))
+SYS_OBJS := $(patsubst $(SYS_DIR)/src/%, $(OBJ_DIR)/$(SYS_DIR)/%, $(SYS_OBJS))
+
+# rules for kernel interface
+$(OBJ_DIR)/$(SYS_DIR)/%.o: $(SYS_DIR)/src/%.c
+ $(COMPILE)
+
+$(OBJ_DIR)/$(SYS_DIR)/%.o: $(SYS_DIR)/src/%.s
+ $(ASSEMBLE)
+
+
+$(SYS): $(SYS_OBJS)
+ $(ARCHIVE)
+
+# rules for userland
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
$(COMPILE)
@@ -47,7 +67,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.s
$(OBJ_DIR)/%: $(SRC_DIR)%.c
$(COMPLNK)
-targets: $(LIBS) $(BINS) $(TEST)
+targets: $(SYS) $(LIBS) $(BINS) $(TEST)
clean:
@echo removing object files
@@ -66,14 +86,14 @@ clean:
install: targets
@echo installing executables
@if [ -n $$BINS ]; then\
- install $(BINS) $(BIN_DIR); \
+ install $(BINS) $(BIN_DIR);\
fi
@echo installing libraries
@if [ -n $$LIBS ]; then\
- install $(LIBS) $(LIB_DIR); \
+ install $(LIBS) $(LIB_DIR);\
fi
@echo installing terminfo
- @tic -sx cmd/term/term.info
+ @tic -sx $(SRC_DIR)/cmd/term/term.info
database:
compiledb make -j4
diff --git a/src/base/rules.mk b/src/base/rules.mk
index 847e4d8..ef93f5c 100644
--- a/src/base/rules.mk
+++ b/src/base/rules.mk
@@ -30,7 +30,7 @@ include share/paths.mk
$(LIBS_$(d)): $(OBJS_$(d))
$(ARCHIVE)
-$(TEST_$(d)): TCLIBS := $(LIBS_$(d))
+$(TEST_$(d)): TCLIBS = $(LIBS_$(d))
$(TEST_$(d)): $(UNIT_$(d)) $(LIBS_$(d))
$(LINK)