-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (51 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
CXX = g++
BLDDIR = build
# Library Path Definitions
INCDIR = include
OBJDIR = obj
SRCDIR = src
SRCFILES = $(wildcard $(SRCDIR)/*.cpp)
OBJFILES = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCFILES))
TARGET = $(BLDDIR)/numcpp.a
# Library Compiler Definitinos
CXXFLAGS = -std=c++17 -Wall -Wextra -I$(INCDIR) -g
LIBS =
# Example Path Definitions
EXAMPLE_SRCDIR = examples
EXAMPLE_BLDDIR = build/examples
EXAMPLE_SRCFILES = $(wildcard $(EXAMPLE_SRCDIR)/*.cpp)
EXAMPLE_BINFILES = $(patsubst $(EXAMPLE_SRCDIR)/%.cpp,$(EXAMPLE_BLDDIR)/%,$(EXAMPLE_SRCFILES))
# Test Path Definitions
TEST_INCDIR = test/include
TEST_OBJDIR = test/obj
TEST_SRCDIR = test/src
TEST_SRCFILES = $(wildcard $(TEST_SRCDIR)/*.cpp)
TEST_OBJFILES = $(patsubst $(TEST_SRCDIR)/%.cpp,$(TEST_OBJDIR)/%.o,$(TEST_SRCFILES))
TEST_TARGET = $(BLDDIR)/test
TEST_TARGETSRC = test/test.cpp
# Test Compiler Definitions
TEST_CXXFLAGS = $(CXXFLAGS) -I$(TEST_INCDIR)
TEST_LIBS = $(LIBS)
# Library Build Instructions
all: $(TARGET) $(TEST_TARGET)
cleanall: clean all
$(TARGET): $(TARGETSRC) $(OBJFILES)
$(CXX) $(CXXFLAGS) -shared -fPIC $^ $(LIBS) -o $@
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
$(CXX) $(CXXFLAGS) -fPIC -c $< $(LIBS) -o $@
.PHONY: clean
clean: testclean
rm -f $(OBJDIR)/*.o $(TARGET)
# Example Build Instructions
examples: $(EXAMPLE_BINFILES)
$(EXAMPLE_BLDDIR)/%: $(EXAMPLE_SRCDIR)/%.cpp $(TARGET)
$(CXX) $(CXXFLAGS) $^ $(LIBS) -o $@
# Test Build Instructions
test: $(TEST_TARGET)
testcleantest: testclean test
$(TEST_TARGET): $(TEST_TARGETSRC) $(TEST_OBJFILES) $(TARGET)
$(CXX) $(TEST_CXXFLAGS) $^ $(TEST_LIBS) -o $@
$(TEST_OBJDIR)/%.o: $(TEST_SRCDIR)/%.cpp
$(CXX) $(TEST_CXXFLAGS) -c $< $(TEST_LIBS) -o $@
testclean:
rm -f $(TEST_OBJDIR)/*.o $(TEST_TARGET)