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