-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
42 lines (32 loc) · 922 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Directories
BUILD_DIR := build
# Compiler and flags
CC := gcc # Use `gcc` explicitly for MinGW
CFLAGS := -Wall -Wextra
CPPFLAGS := -I include -I lib/sc_map
LDFLAGS := -lncurses
# Source files
SRCS := src/sltool.c src/setlist.c src/songlist.c src/utils.c lib/sc_map/sc_map.c
OBJS := $(patsubst src/%.c, $(BUILD_DIR)/%.o, $(SRCS))
# Executable
EXECUTABLE := sltool
# Determine the platform
ifeq ($(OS),Windows_NT)
# If the OS is Windows, add the path to MinGW ncurses include directory
CPPFLAGS += -I/mingw64/include/ncurses
# Add the -DNCURSES_STATIC flag
CFLAGS += -DNCURSES_STATIC
# Add the -static flag
LDFLAGS += -static
endif
# Targets
.PHONY: all clean
all: $(BUILD_DIR) $(EXECUTABLE)
$(EXECUTABLE): $(OBJS)
$(CC) $^ -o $@ $(LDFLAGS)
$(BUILD_DIR)/%.o: src/%.c | $(BUILD_DIR)
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(BUILD_DIR):
mkdir -p $@
clean:
rm -rf $(BUILD_DIR) $(EXECUTABLE)