-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
71 lines (54 loc) · 1.7 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
71
# Compiler settings
SSL_DIR = C:/Program Files/OpenSSL-Win64
CXX = g++
CXXFLAGS = -Wall -Wextra -std=c++17 -MMD -MP -DCPPHTTPLIB_OPENSSL_SUPPORT
LDFLAGS = -lWs2_32 -L"$(SSL_DIR)/lib" -lssl -lcrypto -lcrypt32
# Directories
SRCDIR = src
CMDDIR = commands
INCDIR = include
DEPDIR = dependencies
BUILDDIR = ../project-guild-test
OBJDIR = build
# Target executable
TARGET = $(BUILDDIR)/guild
# Find all source files
SRC = $(wildcard $(SRCDIR)/*.cpp)
CMD = $(wildcard $(CMDDIR)/*.cpp)
MAINSRC = main.cpp
# Generate object file names in build directory
OBJ = $(SRC:%.cpp=$(OBJDIR)/%.o)
CMDOBJ = $(CMD:%.cpp=$(OBJDIR)/%.o)
MAINOBJ = $(MAINSRC:%.cpp=$(OBJDIR)/%.o)
# Dependency files
DEPS = $(OBJ:.o=.d) $(CMDOBJ:.o=.d) $(MAINOBJ:.o=.d)
# Include directories
INCLUDES = -I./$(DEPDIR) -I./$(INCDIR) -I"$(SSL_DIR)/include"
# Default target
all: create_dirs $(TARGET)
# Create necessary directories
create_dirs:
@if not exist "$(BUILDDIR)" mkdir "$(BUILDDIR)"
@if not exist "$(OBJDIR)\$(SRCDIR)" mkdir "$(OBJDIR)\$(SRCDIR)"
@if not exist "$(OBJDIR)\$(CMDDIR)" mkdir "$(OBJDIR)\$(CMDDIR)"
# Link the final executable
$(TARGET): $(MAINOBJ) $(OBJ) $(CMDOBJ)
$(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS)
# Compile main source file
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
# Compile source files
$(OBJDIR)/$(SRCDIR)/%.o: $(SRCDIR)/%.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
# Compile command files
$(OBJDIR)/$(CMDDIR)/%.o: $(CMDDIR)/%.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
# Include dependency files
-include $(DEPS)
# Clean build files
clean:
@if exist "$(OBJDIR)" rmdir /s /q "$(OBJDIR)"
@if exist "$(TARGET)" del "$(TARGET)"
# Clean and rebuild
rebuild: clean all
.PHONY: all clean rebuild create_dirs