This repository has been archived by the owner on Mar 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathg++Makefile
87 lines (71 loc) · 2.33 KB
/
g++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
79
80
81
82
83
84
85
86
CXX := g++-6
SRCDIR := src
BUILDDIR := build
INCDIR := include
TARGET := bin/main
SRCEXT := cpp
INCEXT := hpp
SOURCES := $(shell find $(SRCDIR) -type f -name "*.$(SRCEXT)")
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
LIB := -lboost_system -lboost_thread -lboost_filesystem -lboost_chrono -lssl -lcrypto -lpthread -lboost_atomic -lboost_date_time
LIBDIR :=
CXXFLAGS := -Wall
INC := -I include/ -I ~/Simple-Web-Server/
MAINOBJS := $(OBJECTS) $(BUILDDIR)/main.o
EXAMOBJS := $(OBJECTS) $(BUILDDIR)/example.o
#Compile Target
$(TARGET): $(MAINOBJS)
@echo " Linking... $(OBJECTS)"
$(CXX) $^ -o $(TARGET) $(LIB) $(LIBDIR)
#Include dependencies which are created
-include $(OBJECTS:.o=.d)
#Create object files
$(BUILDDIR)/%.o: %.$(SRCEXT)
#Make build directory
@mkdir -p $(BUILDDIR)
#Compile object
$(CXX) $(CXXFLAGS) $(INC) -c -o $@ $<
#Make dependency list/object
$(CXX) $(CXXFLAGS) $(INC) -MM $< > $(BUILDDIR)/$*.d
#Fancy deleting/copying
#Handles files that no longer exist
@cp -f $(BUILDDIR)/$*.d $(BUILDDIR)/$*.d.tmp
@sed -e 's/.*://' -e 's/\\$$//' < $(BUILDDIR)/$*.d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $(BUILDDIR)/$*.d
@rm -f $(BUILDDIR)/$*.d.tmp
$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
#Make build directory
@mkdir -p $(BUILDDIR)
#Compile object
$(CXX) $(CXXFLAGS) $(INC) -c -o $@ $<
#Make dependency list/object
$(CXX) $(CXXFLAGS) $(INC) -MM $< > $(BUILDDIR)/$*.d
#Fancy deleting/copying
#Handles files that no longer exist
@cp -f $(BUILDDIR)/$*.d $(BUILDDIR)/$*.d.tmp
@sed -e 's/.*://' -e 's/\\$$//' < $(BUILDDIR)/$*.d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $(BUILDDIR)/$*.d
@rm -f $(BUILDDIR)/$*.d.tmp
$(BUILDDIR)/%.o: test/%.$(SRCEXT)
#Make build directory
@mkdir -p $(BUILDDIR)
#Compile object
$(CXX) $(CXXFLAGS) $(INC) -c -o $@ $<
#Make dependency list/object
$(CXX) $(CXXFLAGS) $(INC) -MM $< > $(BUILDDIR)/$*.d
#Fancy deleting/copying
#Handles files that no longer exist
@cp -f $(BUILDDIR)/$*.d $(BUILDDIR)/$*.d.tmp
@sed -e 's/.*://' -e 's/\\$$//' < $(BUILDDIR)/$*.d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $(BUILDDIR)/$*.d
@rm -f $(BUILDDIR)/$*.d.tmp
#Clean
clean:
@echo " Cleaning...";
$(RM) -r $(BUILDDIR) $(TARGET)
.PHONY: clean
#Basic example
Example: $(EXAMOBJS)
#Prevents failure if dependency does not exist
$(BUILDDIR)/%.d: ;
.PRECIOUS: $(DEPDIR)/%.d