-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
33 lines (22 loc) · 663 Bytes
/
Copy pathMakefile
File metadata and controls
33 lines (22 loc) · 663 Bytes
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
CXX := g++
CXXFLAGS := -std=c++17 -Wall -Wextra -I include -I .
SRC_DIR := src
BUILD_DIR := build
LIB := libtinytransformer.a
SRCS := $(wildcard $(SRC_DIR)/*.cpp)
OBJS := $(patsubst $(SRC_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(SRCS))
MAIN_SRC := main.cpp
TARGET := tinytransformer
.PHONY: all lib clean
all: lib $(if $(wildcard $(MAIN_SRC)), $(TARGET))
lib: $(BUILD_DIR) $(LIB)
$(LIB): $(OBJS)
ar rcs $@ $^
$(TARGET): $(MAIN_SRC) $(LIB)
$(CXX) $(CXXFLAGS) $< -L. -ltinytransformer -o $@
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
clean:
rm -rf $(BUILD_DIR) $(LIB) $(TARGET)