-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
70 lines (56 loc) · 1.39 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Variables for the compiler
CXX = g++
CXXFLAGS = -Wall -g -std=c++17
# Libraries path
NCURSES_LIBS = -lncurses
# Source and object directories
SRC_DIR = src
SRC_FONTS = src/fonts
OBJ_DIR = obj
OBJ_FONTS_DIR = obj/fonts
# Source files
SOURCES = \
$(SRC_DIR)/main.cpp \
$(SRC_DIR)/clockfont.cpp \
$(SRC_DIR)/fonts/hashtag.cpp \
$(SRC_DIR)/fonts/asterisk.cpp \
$(SRC_DIR)/fonts/lines.cpp \
$(SRC_DIR)/fonts/doublelines.cpp
# Object files
OBJECTS = \
$(OBJ_DIR)/main.o \
$(OBJ_DIR)/clockfont.o \
$(OBJ_FONTS_DIR)/hashtag.o \
$(OBJ_FONTS_DIR)/asterisk.o \
$(OBJ_FONTS_DIR)/lines.o \
$(OBJ_FONTS_DIR)/doublelines.o
# Executable name
EXEC = coolclock
# Installation directory
DESTDIR = /usr/local
BIN_DIR = $(DESTDIR)/bin
# Default rule to compile
all: $(EXEC)
# How to compile the executable
$(EXEC): $(OBJECTS)
$(CXX) $(OBJECTS) -o $(EXEC) $(NCURSES_LIBS)
# How to compile object files
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
@mkdir -p $(OBJ_DIR)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(OBJ_FONTS_DIR)/%.o: $(SRC_FONTS)/%.cpp
@mkdir -p $(OBJ_FONTS_DIR)
$(CXX) $(CXXFLAGS) -c $< -o $@
# Clean object files and executables
clean:
rm -rf $(OBJ_DIR) $(EXEC)
# Recompile everything
build: clean all
# Installation
install: $(EXEC)
install -D $(EXEC) $(BIN_DIR)/$(EXEC)
@echo "Installed in $(BIN_DIR)/$(EXEC)"
# Uninstallation
uninstall:
rm -f $(BIN_DIR)/$(EXEC)
@echo "Uninstalled from $(BIN_DIR)/$(EXEC)"