aboutsummaryrefslogtreecommitdiffstats
path: root/tools/bin2carr/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'tools/bin2carr/Makefile')
-rw-r--r--tools/bin2carr/Makefile47
1 files changed, 47 insertions, 0 deletions
diff --git a/tools/bin2carr/Makefile b/tools/bin2carr/Makefile
new file mode 100644
index 0000000..a9ff816
--- /dev/null
+++ b/tools/bin2carr/Makefile
@@ -0,0 +1,47 @@
1.POSIX:
2.SUFFIXES:
3
4# Source code location and files to watch for changes.
5SRC_DIR := src
6SRC_MAIN := $(SRC_DIR)/main.c
7WATCH_SRC := $(wildcard $(SRC_DIR)/*.c)
8WATCH_SRC += $(wildcard $(SRC_DIR)/*.h)
9
10# Output library names and executables.
11BIN_NAME := bin2carr
12BUILD_DIR := build
13BIN := $(BUILD_DIR)/$(BIN_NAME)
14
15# Compiler and linker configuration.
16CC := gcc
17CFLAGS := -Wall -Wextra -pedantic -std=c99 -DBIN_NAME=\"$(BIN_NAME)\"
18LDFLAGS := -lm
19LDLIBS :=
20RELEASE_CFLAGS := -DNDEBUG -O2
21DEBUG_CFLAGS := -DDEBUG -g
22
23.PHONY: static clean run
24
25# Setup debug/release builds.
26# make clean && make <target> DEBUG=0
27# make clean && make <target> DEBUG=1
28DEBUG ?= 0
29ifeq ($(DEBUG), 1)
30 CFLAGS += $(DEBUG_CFLAGS)
31else
32 CFLAGS += $(RELEASE_CFLAGS)
33endif
34
35static: $(BUILD_DIR) $(BIN)
36
37$(BIN): $(SRC_MAIN) $(WATCH_SRC)
38 $(CC) $(CFLAGS) $(LDFLAGS) -o $(BIN) $(SRC_MAIN) $(LDLIBS)
39
40$(BUILD_DIR):
41 mkdir -p $(BUILD_DIR)
42
43run: $(BIN)
44 exec $(BIN)
45
46clean:
47 rm -r $(BUILD_DIR)