# Standard housekeeping .PHONY: all debug release system bins libs tests clean target install .SUFFIXES: all: targets debug: CC := clang debug: CFLAGS += -DDEBUG -g -fsanitize=address debug: INCS := -I $(INC_DIR) debug: ELIBS := -fsanitize=address debug: STATIC := debug: CINIT := debug: CFINI := debug: targets release: CFLAGS += -O2 -mtune=native -flto #-DNDEBUG release: targets # Targets & array of sources & intermediates SRCS := OBJS := DEPS := LIBS := BINS := TEST := GENS := # generic rules %.a: %.o $(ARCHIVE) %: %.o $(LINK) # explicit system layer DIR := sys include $(DIR)/rules.mk # userland rules $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(COMPILE) $(OBJ_DIR)/%.o: $(SRC_DIR)/%.s $(ASSEMBLE) $(OBJ_DIR)/%: $(SRC_DIR)/%.c $(COMPLINK) # iterate through source directory tree DIR := src include $(DIR)/rules.mk system: $(RUNTIME) bins: system $(BINS) tests: system $(TEST) targets: libs bins tests clean: @echo removing system layer @rm -f $(SYS_OBJS) $(SYS) $(RT) $(RT_OBJS) $(RT1) $(RTI) $(RTN) @echo removing object files @rm -f $(OBJS) @echo removing dependency files @rm -f $(DEPS) @echo removing generated source files @rm -f $(GENS) @echo removing libraries @rm -f $(LIBS) @echo removing binaries @rm -f $(BINS) @echo removing unit tests @rm -f $(TEST) install: targets @echo installing executables @if [ -n $$BINS ]; then\ install $(BINS) $(BIN_DIR);\ fi @echo installing libraries @if [ -n $$LIBS ]; then\ install $(LIBS) $(LIB_DIR);\ fi @echo installing terminfo @tic -sx $(SRC_DIR)/cmd/term/term.info database: compiledb make -j4