-
Notifications
You must be signed in to change notification settings - Fork 18
/
Makefile
55 lines (43 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
# Common prefix for installation directories, following GNU conventions.
# See https://www.gnu.org/prep/standards/html_node/Directory-Variables.html for details.
# Installation prefix
PREFIX = /usr/local
DATAROOTDIR = $(PREFIX)/share
# Where to put the executable.
BINDIR = $(PREFIX)/bin
# Where to put the manual pages.
MANDIR = $(DATAROOTDIR)/man
TARGET = kabmat
SRC_DIR = src
BUILD_DIR = bin
DATA_DIR = ~/.local/share/kabmat
CFLAGS = -std=c++17 -Wall -Wextra
# library linker commands (start with -l)
LOADLIBS = -lncurses
SOURCES := $(shell find $(SRC_DIR) -type f -name '*.cpp')
OBJECTS := $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(SOURCES))
.PHONY: all
all:
for dirname in $$(find $(SRC_DIR) -type d | sed 's/'$(SRC_DIR)'/'$(BUILD_DIR)'/'); do mkdir -p $$dirname; done
mkdir -p $(DATA_DIR)
touch $(DATA_DIR)/data
+$(MAKE) $(TARGET)
$(TARGET): $(OBJECTS)
$(CXX) $(OBJECTS) $(CFLAGS) -o $@ $(LOADLIBS)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX) $(CFLAGS) -c $< -o $@ $(LOADLIBS)
.PHONY: clean
clean:
-rm -rf $(BUILD_DIR) $(TARGET)
.PHONY: install
install:
mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MANDIR)/man1
cp ./$(TARGET) $(DESTDIR)$(BINDIR)
chmod 0755 $(DESTDIR)$(BINDIR)/$(TARGET)
cp ./doc/kabmat.1 $(DESTDIR)$(MANDIR)/man1
chmod 0644 $(DESTDIR)$(MANDIR)/man1/kabmat.1
$(MAKE) clean
.PHONY: uninstall
uninstall:
rm $(DESTDIR)$(BINDIR)/$(TARGET)
rm $(DESTDIR)$(MANDIR)/man1/kabmat.1