-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (61 loc) · 1.9 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
72
73
74
75
76
77
78
#Architecture
ARCH := $(shell uname -m)
#Compilers
CC := g++ -std=c++14 -Wno-psabi
DGEN := doxygen
#The Target Binary Program
TARGET := vendingmachine
#The Directories, Source, Includes, Objects, Binary and Resources
SRCDIR := ./src
INCDIR := ./include
BUILDDIR := ./build
TARGETDIR := ./bin
SRCEXT := cc
#Asan library
ifeq ($(ARCH),armv7l)
ASAN := -static-libasan
else
ASAN := -lasan
endif
#Flags, Libraries and Includes
CFLAGS := -fsanitize=address -ggdb
LIB := -L../lib -lgtest -lpthread $(ASAN) -lelma -lssl -lcrypto -lcurses
INC := -I$(INCDIR)
INCDEP := -I$(INCDIR)
#Files
HEADERS := $(wildcard ./include/*.h)
SOURCES := $(wildcard ./src/*.cc)
SOURCES := $(filter-out ./src/unit_test.cc,$(SOURCES))
OBJECTS := $(patsubst %.cc, $(BUILDDIR)/%.o, $(notdir $(SOURCES)))
NON_MAIN_OBJECTS := $(filter-out ./build/main.o,$(OBJECTS))
DGENCONFIG := docs.config
#Defauilt Make
all: directories $(TARGETDIR)/$(TARGET) bin/test
docs: docs/index.html
docs/index.html: $(SOURCES) $(HEADERS) README.md docs.config
$(DGEN) $(DGENCONFIG)
cp .nojekyll docs
#Remake
remake: spotless all
#Make the Directories
directories:
@mkdir -p $(TARGETDIR)
@mkdir -p $(BUILDDIR)
#Clean only Objects
clean:
@$(RM) -rf $(BUILDDIR)/*.o *.o bin/*
#Full Clean, Objects and Binaries
spotless: clean
@$(RM) -rf $(TARGETDIR)/$(TARGET) *.db
@$(RM) -rf build bin html latex
#Unit Tester
bin/test: $(NON_MAIN_OBJECTS) $(HEADERS) ./src/unit_test.cc ./src/test_main.cpp
$(CC) $(CFLAGS) $(INC) -c -o test_main.o ./src/test_main.cpp
$(CC) $(CFLAGS) -o bin/test test_main.o $(NON_MAIN_OBJECTS) $(LIB)
#Link
$(TARGETDIR)/$(TARGET): $(OBJECTS) $(HEADERS)
$(CC) $(CFLAGS) -o $(TARGETDIR)/$(TARGET) $(OBJECTS) $(LIB)
#Compile
$(BUILDDIR)/%.o: $(SRCDIR)/%.cc $(HEADERS)
$(CC) $(CFLAGS) $(INC) -c -o $@ $<
.PHONY: directories remake clean cleaner apidocs $(BUILDDIR) $(TARGETDIR)