diff options
author | Bad Diode <bd@badd10de.dev> | 2021-05-22 23:17:50 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-05-22 23:17:50 +0200 |
commit | 97d1c4246e167ab493175d890409c4154628760c (patch) | |
tree | 41e9b05c3e4a890cb7e8491d55173dcd84964ab8 /tools/bin2carr/Makefile | |
parent | efbee96caa1452486a007eeeabb5073aa9025dae (diff) | |
download | uxngba-97d1c4246e167ab493175d890409c4154628760c.tar.gz uxngba-97d1c4246e167ab493175d890409c4154628760c.zip |
Include bin2carr on the tools directory
Diffstat (limited to 'tools/bin2carr/Makefile')
-rw-r--r-- | tools/bin2carr/Makefile | 47 |
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. | ||
5 | SRC_DIR := src | ||
6 | SRC_MAIN := $(SRC_DIR)/main.c | ||
7 | WATCH_SRC := $(wildcard $(SRC_DIR)/*.c) | ||
8 | WATCH_SRC += $(wildcard $(SRC_DIR)/*.h) | ||
9 | |||
10 | # Output library names and executables. | ||
11 | BIN_NAME := bin2carr | ||
12 | BUILD_DIR := build | ||
13 | BIN := $(BUILD_DIR)/$(BIN_NAME) | ||
14 | |||
15 | # Compiler and linker configuration. | ||
16 | CC := gcc | ||
17 | CFLAGS := -Wall -Wextra -pedantic -std=c99 -DBIN_NAME=\"$(BIN_NAME)\" | ||
18 | LDFLAGS := -lm | ||
19 | LDLIBS := | ||
20 | RELEASE_CFLAGS := -DNDEBUG -O2 | ||
21 | DEBUG_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 | ||
28 | DEBUG ?= 0 | ||
29 | ifeq ($(DEBUG), 1) | ||
30 | CFLAGS += $(DEBUG_CFLAGS) | ||
31 | else | ||
32 | CFLAGS += $(RELEASE_CFLAGS) | ||
33 | endif | ||
34 | |||
35 | static: $(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 | |||
43 | run: $(BIN) | ||
44 | exec $(BIN) | ||
45 | |||
46 | clean: | ||
47 | rm -r $(BUILD_DIR) | ||