From 96d27c2a3e1a0fa0878beb3f9cd02f4b4ed8fdbb Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Fri, 8 Oct 2021 10:25:59 +0200 Subject: Initial commit w/ small readline echo function --- Makefile | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..8bd5560 --- /dev/null +++ b/Makefile @@ -0,0 +1,51 @@ +.POSIX: +.SUFFIXES: + +# Source code location and files to watch for changes. +SRC_DIR := src/bootstrap +BUILD_DIR := build +SRC_MAIN := $(SRC_DIR)/main.c +WATCH_SRC := $(shell find $(SRC_DIR) -name "*.c" -or -name "*.s" -or -name "*.h") +INC_DIRS := $(shell find $(SRC_DIR) -type d) +INC_FLAGS := $(addprefix -I,$(INC_DIRS)) + +# Output executable. +TARGET := bdl +BIN := $(BUILD_DIR)/$(TARGET) + +# Compiler and linker configuration. +CC := cc +CFLAGS := -Wall -Wextra -pedantic +CFLAGS += $(INC_FLAGS) +LDFLAGS := +LDLIBS := +RELEASE_CFLAGS := -DNDEBUG -O2 +DEBUG_CFLAGS := -DDEBUG -O2 -g + +.PHONY: tools clean run + +# Setup debug/release builds. +# make clean && make DEBUG=0 +# make clean && make DEBUG=1 +DEBUG ?= 0 +ifeq ($(DEBUG), 1) + CFLAGS += $(DEBUG_CFLAGS) +else + CFLAGS += $(RELEASE_CFLAGS) +endif + +main: tools $(BUILD_DIR) $(ROM) $(BIN) + +$(BIN): $(SRC_MAIN) $(WATCH_SRC) + $(CC) $(CFLAGS) $(LDFLAGS) -o $(BIN) $(SRC_MAIN) $(LDLIBS) + +# Create build directory if needed. +$(BUILD_DIR): tools + mkdir -p $(BUILD_DIR) + +run: $(BIN) + ./$(BIN) + +# Remove build directory. +clean: + rm -rf $(BUILD_DIR) -- cgit v1.2.1