-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
57 lines (44 loc) · 1.67 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
# Compiler and compilation flags
CXX := g++
CXXFLAGS := -std=c++11 -Wall -Wextra
BUILD_DIR := build
LDFLAGS := -L$(BUILD_DIR) -llogger
# Directories
SRC_DIR := src
INCLUDE_DIRS := src external/logger # Add submodule headers path here
WWW_DIR := www
TESTS_DIR := tests
SUBMODULE_DIR:=external/logger
# Source files and object files
SOURCES := $(wildcard $(SRC_DIR)/*.cpp)
OBJECTS := $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(SOURCES))
# Library name
LIBRARY_NAME := libcappuccin.a
# Library and submodule targets
SUBMODULE_LIB := $(BUILD_DIR)/liblogger.so # Assuming the .so file is named liblogger.so
# Default target
all: $(BUILD_DIR) $(SUBMODULE_LIB) $(OBJECTS) $(LIBRARY_NAME) www_files tests
# Create the build directory
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
# Build the submodule library
$(SUBMODULE_LIB):
cd $(SUBMODULE_DIR) && $(MAKE) # Run `make` in the submodule directory
cp $(SUBMODULE_DIR)/liblogger.so $(BUILD_DIR) # Copy the built .so file to the build directory
# Build the static library (if needed)
$(LIBRARY_NAME): $(OBJECTS)
ar rcs $@ $(OBJECTS)
# Compile the source files into object files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) $(foreach dir,$(INCLUDE_DIRS),-I$(dir)) -c $< -o $@
# Target to copy static files to the build directory
www_files:
cp -r $(WWW_DIR) $(BUILD_DIR)/
# Build and run the tests
tests: $(BUILD_DIR) $(OBJECTS) $(TESTS_DIR)/*.cpp
$(CXX) $(CXXFLAGS) $(foreach dir,$(INCLUDE_DIRS),-I$(dir)) -I$(TESTS_DIR) $(TESTS_DIR)/*.cpp $(OBJECTS) $(LDFLAGS) -o $(BUILD_DIR)/tests
LD_LIBRARY_PATH=$(BUILD_DIR) ./$(BUILD_DIR)/tests
# Clean build files
clean:
cd $(SUBMODULE_DIR) && $(MAKE) clean
rm -rf $(BUILD_DIR) $(LIBRARY_NAME)