diff options
Diffstat (limited to 'rules.mk')
-rw-r--r-- | rules.mk | 44 |
1 files changed, 32 insertions, 12 deletions
@@ -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 |