aboutsummaryrefslogtreecommitdiff
path: root/rules.mk
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 /rules.mk
parent0369b1505b019becfb74ccd9c82f9f7700af377a (diff)
Chore: updated build paths
Diffstat (limited to 'rules.mk')
-rw-r--r--rules.mk44
1 files changed, 32 insertions, 12 deletions
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