forked from richkmeli/Richkware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (53 loc) · 1.43 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
# Copyright 2016 Riccardo Melioli.
# executable name
TARGET = Richkware
ifeq ($(OS),Windows_NT)
CXX=g++
RM=cmd /C rmdir /Q /S
MKDIR=mkdir
else
CXX=x86_64-w64-mingw32-g++
RM=rm -rf
MKDIR=mkdir -p
endif
# directories
SRCDIR = src
OBJDIR = obj
BINDIR = bin
TESTDIR = test
INCLUDES = -I($(HOME)/include
LIBINCLUDES = -L $(HOME)/lib
# files
SOURCES := $(wildcard $(SRCDIR)/*.cpp)
INCLUDES := $(wildcard $(SRCDIR)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
EXECUTABLE := $(BINDIR)/$(TARGET).exe
TESTS := $(wildcard $(TESTDIR)/*.cpp)
EXECUTABLE_TEST := $(TESTDIR)/$(TARGET)_TEST.exe
INC = $(INCLUDES) $(LIBINCLUDES)
# flags
CXXFLAGS= -c -std=c++11 -O3 -Wall -I include/
LDFLAGS= -static-libgcc -static-libstdc++ -static -Wall
EFLAG= -lws2_32
.PHONY : all
all: clean make_directories build
.PHONY : build
build: $(EXECUTABLE)
.PHONY : make_directories
make_directories:
$(MKDIR) $(OBJDIR) $(BINDIR)
.PHONY : clean
clean:
-$(RM) $(OBJDIR) $(BINDIR)
.PHONY : test
test: clean make_directories $(EXECUTABLE_TEST)
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp
$(CXX) $(CXXFLAGS) $< -o $@
$(EXECUTABLE): $(OBJECTS) main.o
$(CXX) $(LDFLAGS) $(OBJECTS) $(OBJDIR)/main.o $(EFLAG) -o $@
main.o:
$(CXX) $(CXXFLAGS) main.cpp -o $(OBJDIR)/main.o
$(EXECUTABLE_TEST): $(OBJECTS) test.o
$(CXX) $(LDFLAGS) $(OBJECTS) $(TESTDIR)/test.o $(EFLAG) -o $@
test.o:
$(CXX) $(CXXFLAGS) $(TESTDIR)/test.cpp -o $(TESTDIR)/test.o