aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-10-08 10:25:59 +0200
committerBad Diode <bd@badd10de.dev>2021-10-08 10:25:59 +0200
commit96d27c2a3e1a0fa0878beb3f9cd02f4b4ed8fdbb (patch)
tree9ec40c0c37630d1b6a7546cc8c9f09fe65809861 /Makefile
downloadbdl-96d27c2a3e1a0fa0878beb3f9cd02f4b4ed8fdbb.tar.gz
bdl-96d27c2a3e1a0fa0878beb3f9cd02f4b4ed8fdbb.zip
Initial commit w/ small readline echo function
Diffstat (limited to 'Makefile')
-rwxr-xr-xMakefile51
1 files changed, 51 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100755
index 0000000..8bd5560
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,51 @@
1.POSIX:
2.SUFFIXES:
3
4# Source code location and files to watch for changes.
5SRC_DIR := src/bootstrap
6BUILD_DIR := build
7SRC_MAIN := $(SRC_DIR)/main.c
8WATCH_SRC := $(shell find $(SRC_DIR) -name "*.c" -or -name "*.s" -or -name "*.h")
9INC_DIRS := $(shell find $(SRC_DIR) -type d)
10INC_FLAGS := $(addprefix -I,$(INC_DIRS))
11
12# Output executable.
13TARGET := bdl
14BIN := $(BUILD_DIR)/$(TARGET)
15
16# Compiler and linker configuration.
17CC := cc
18CFLAGS := -Wall -Wextra -pedantic
19CFLAGS += $(INC_FLAGS)
20LDFLAGS :=
21LDLIBS :=
22RELEASE_CFLAGS := -DNDEBUG -O2
23DEBUG_CFLAGS := -DDEBUG -O2 -g
24
25.PHONY: tools clean run
26
27# Setup debug/release builds.
28# make clean && make <target> DEBUG=0
29# make clean && make <target> DEBUG=1
30DEBUG ?= 0
31ifeq ($(DEBUG), 1)
32 CFLAGS += $(DEBUG_CFLAGS)
33else
34 CFLAGS += $(RELEASE_CFLAGS)
35endif
36
37main: tools $(BUILD_DIR) $(ROM) $(BIN)
38
39$(BIN): $(SRC_MAIN) $(WATCH_SRC)
40 $(CC) $(CFLAGS) $(LDFLAGS) -o $(BIN) $(SRC_MAIN) $(LDLIBS)
41
42# Create build directory if needed.
43$(BUILD_DIR): tools
44 mkdir -p $(BUILD_DIR)
45
46run: $(BIN)
47 ./$(BIN)
48
49# Remove build directory.
50clean:
51 rm -rf $(BUILD_DIR)