-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (48 loc) · 1.41 KB
/
Copy pathMakefile
File metadata and controls
60 lines (48 loc) · 1.41 KB
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
.SUFFIXES:
.DELETE_ON_ERROR:
.SECONDARY:
SHELL := /bin/bash
.SHELLFLAGS := -O globstar -c
# it would have been nice to use the C++2X std for this project,
# but openfst is c++17 only (uses features deprecated in c++20)
# so much for backward compatibility!
CXX := g++ -std=c++17
CXXFLAGS := -Wall -Wextra -fmax-errors=5
LDFLAGS := -L/home/padril/libs/lib/ -lfst -lngram
BUILD := build
OBJ_DIR := $(BUILD)/objects
APP_DIR := $(BUILD)/bin
SRC_DIR := src
BIN_DIR := bin
INCLUDE_DIR := include
SRC := $(sort $(wildcard $(SRC_DIR)/*.cpp $(SRC_DIR)/*/*.cpp))
BIN := $(sort $(wildcard $(BIN_DIR)/*.cpp $(BIN_DIR)/*/*.cpp))
APPS := $(BIN:$(BIN_DIR)/%.cpp=$(APP_DIR)/%)
INCLUDE := -I$(INCLUDE_DIR) -isystem /home/padril/libs/include/
OBJECTS := $(SRC:%.cpp=$(OBJ_DIR)/%.o)
DEPENDS := $(OBJECTS:%.o=%.d)
HEADERS := $(sort $(wildcard $(INCLUDE_DIR)/*.hpp $(INCLUDE_DIR)/*/*.hpp))
.PHONY: debug
debug: CXXFLAGS += -DDEBUG -g -Wpedantic
debug: build $(APPS)
.PHONY: release
release: CXXFLAGS += -O3
release: build $(APPS)
.PHONY: build
build:
mkdir -p $(BUILD)
mkdir -p $(OBJ_DIR)
mkdir -p $(APP_DIR)
$(APP_DIR)/%: $(OBJ_DIR)/$(BIN_DIR)/%.o $(OBJECTS)
mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) -o $@ $^ $(LDFLAGS)
-include $(DEPENDS)
$(OBJ_DIR)/%.o: %.cpp
mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -MMD -o $@
.PHONY: clean
clean:
rm $(OBJ_DIR)/**/*.o
rm $(OBJ_DIR)/**/*.d
rm $(APPS)
find $(BUILD) -type d -empty -delete