-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (60 loc) · 2.12 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
ifeq ($(OS),Windows_NT)
CXX=cl
else
CXX=g++
endif
ARCH=x64
BUILDDIR=build
RESOURCEDIR=resources
LIBDIR=lib
ifeq ($(OS),Windows_NT)
TARGET=lostLuggage.exe
else
TARGET=lostLuggage
endif
SRC=$(wildcard src/*.cpp)
OBJ=$(patsubst src/%, $(BUILDDIR)/%, $(SRC:%.cpp=%.obj))
DGE_SRC=$(wildcard dge/src/*.cpp)
DGE_OBJ=$(patsubst dge/src/%, $(BUILDDIR)/%, $(DGE_SRC:%.cpp=%.obj))
IMGUI_SRC=$(wildcard imgui/*.cpp)
IMGUI_OBJ=$(patsubst imgui/%, $(BUILDDIR)/%, $(IMGUI_SRC:%.cpp=%.obj))
ifeq ($(OS),Windows_NT)
COMMONFLAGS= -nologo -Z7
LINKFLAGS= -incremental:no -manifest:no -SUBSYSTEM:CONSOLE -LIBPATH:lib/$(ARCH)
LINKLIBS= OpenGL32.lib SDL2.lib SDL2main.lib
LINKCOMPILEFLAGS= -Fe$(BUILDDIR)/$(TARGET) -link $(LINKFLAGS) $(LINKLIBS)
COMPILEFLAGS= -c -Iinclude -Idge/src -Iinclude/SDL -Isrc -W4 -D_CRT_SECURE_NO_WARNINGS -Fo
else
COMMONFLAGS= -g --std=c++11
LINKCOMPILEFLAGS= -o $(BUILDDIR)/$(TARGET) -lGL -ldl `sdl2-config --libs`
COMPILEFLAGS= -c `sdl2-config --cflags` -Iinclude -Idge/src -Isrc -D_CRT_SECURE_NO_WARNINGS -Wall -Wconversion -o
endif
ifeq ($(OS),Windows_NT)
RESOURCEDIRCMD=@cmd //c "IF NOT EXIST $(BUILDDIR)\$(RESOURCEDIR) mklink /D $(BUILDDIR)\$(RESOURCEDIR) ..\$(RESOURCEDIR)"
BUILDLIBDIRCMD=@cp $(LIBDIR)/$(ARCH)/SDL2.dll $(BUILDDIR)/
RESOURCECLEANCMD=-rmdir $(BUILDDIR)/$(RESOURCEDIR)
else
RESOURCEDIRCMD=ln -s ../$(RESOURCEDIR) $(BUILDDIR)/$(RESOURCEDIR)
BUILDLIBDIRCMD=
RESOURCECLEANCMD=-rm $(BUILDDIR)/$(RESOURCEDIR)
endif
$(TARGET): $(BUILDDIR) $(BUILDDIR)/$(RESOURCEDIR) $(OBJ) $(DGE_OBJ) $(IMGUI_OBJ)
$(CXX) $(OBJ) $(DGE_OBJ) $(IMGUI_OBJ) $(COMMONFLAGS) $(LINKCOMPILEFLAGS)
run:
@cd $(BUILDDIR); ./$(TARGET)
$(BUILDDIR)/%.obj: src/%.cpp
$(CXX) $< $(COMMONFLAGS) $(COMPILEFLAGS)$@
$(BUILDDIR)/%.obj: dge/src/%.cpp
$(CXX) $< $(COMMONFLAGS) $(COMPILEFLAGS)$@
$(BUILDDIR)/%.obj: imgui/%.cpp
$(CXX) $< $(COMMONFLAGS) $(COMPILEFLAGS)$@
clean:
@# Note that we cannot use rm -r here because that will delete the contents of the symlink'd directory
$(RESOURCECLEANCMD)
rm -r $(BUILDDIR)
$(BUILDDIR)/$(RESOURCEDIR): $(BUILDDIR)
$(RESOURCECLEANCMD)
$(RESOURCEDIRCMD)
$(BUILDDIR):
@mkdir -p $(BUILDDIR)
$(BUILDLIBDIRCMD)