-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
50 lines (41 loc) · 1.12 KB
/
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
43
44
45
46
47
48
49
50
CC = gcc
CFLAGS = -Wall -Iinclude -I/usr/local/include/notcurses
LDFLAGS = -lncurses -lconfig -lsixel -lm
SRC_DIR = src
OBJ_DIR = obj
BIN_DIR = bin
CONFIG_DIR = $(HOME)/.config/tuxplorer
SOURCES = $(wildcard $(SRC_DIR)/*.c)
OBJECTS = $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SOURCES))
TARGET = $(BIN_DIR)/tuxplorer
BINDIR = $(DESTDIR)/bin
CONFIG_FILE = $(CONFIG_DIR)/config.cfg
# Dynamically generate the config content to account for different user home directories
define CONFIG_CONTENT
pins: {
Desktop: "$(HOME)/Desktop",
Home: "$(HOME)"
}
params: {
TextEditor: "vim"
}
endef
export CONFIG_CONTENT
all: directories $(TARGET) config
directories:
@mkdir -p $(BIN_DIR) $(OBJ_DIR)
config:
@mkdir -p $(CONFIG_DIR)
@echo "$$CONFIG_CONTENT" > $(CONFIG_FILE)
@echo "Configuration file created at $(CONFIG_FILE)"
$(TARGET): $(OBJECTS)
@echo "Linking: " $(OBJECTS) " into " $(TARGET)
@$(CC) $(OBJECTS) $(LDFLAGS) -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@echo "Compiling: " $<
@$(CC) $(CFLAGS) -c $< -o $@
clean:
@rm -rf $(OBJ_DIR) $(BIN_DIR) $(CONFIG_DIR)
install:
install -m 755 $(TARGET) $(BINDIR)
.PHONY: all clean directories config