-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
48 lines (35 loc) · 985 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
43
44
45
46
47
48
CXX := g++
CC := gcc
SRC_DIRECTORY = src
OBJ_DIRECTORY = obj
BIN_DIRECTORY = bin
CREATE_DIRS = mkdir -p $(@D)
INC_DIRECTORIES := \
$(SRC_DIRECTORY)
CXXFLAGS := \
$(foreach inc_dir,$(INC_DIRECTORIES),-I $(inc_dir)) \
-std=c++17
LFLAGS :=
SOURCES := \
$(wildcard $(SRC_DIRECTORY)/*.cpp) \
$(wildcard $(SRC_DIRECTORY)/*/*.cpp)
HEADERS := \
$(wildcard $(SRC_DIRECTORY)/*.h) \
$(wildcard $(SRC_DIRECTORY)/*/*.h)
OBJECTS := $(SOURCES:$(SRC_DIRECTORY)/%.cpp=$(OBJ_DIRECTORY)/%.o)
all: $(BIN_DIRECTORY)/binedit
$(BIN_DIRECTORY)/binedit: $(OBJECTS)
@$(CREATE_DIRS)
@echo "linking $@"
@$(CXX) $(OBJECTS) -o $@ $(LFLAGS)
$(OBJ_DIRECTORY)/%.o: $(SRC_DIRECTORY)/%.cpp $(HEADERS)
@$(CREATE_DIRS)
@echo "compile $@"
@$(CXX) -c $< -o $@ $(CXXFLAGS)
install: $(BIN_DIRECTORY)/binedit
sudo install -m 557 $(BIN_DIRECTORY)/binedit /usr/local/bin
uninstall: /usr/local/bin/binedit
sudo rm /usr/local/bin/binedit
clean:
@rm -rf $(OBJ_DIRECTORY)
@rm -rf $(BIN_DIRECTORY)