-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
74 lines (60 loc) · 1.82 KB
/
makefile
File metadata and controls
74 lines (60 loc) · 1.82 KB
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
#######################
# cppcraft makefile #
#######################
# build options
# -Ofast -mfpmath=both -march=native
#
#BUILDOPT = -ggdb3 -fstack-protector -fexceptions
#BUILDOPT = -Ofast -ffast-math -march=native
BUILDOPT = -ggdb3 -fstack-protector -fexceptions -g
# output file
OUTPUT = ./Debug/cppcraft
# code folder
SOURCE = source
# resource file
ifeq ($(OS),Windows_NT)
RESOURCES = res/cppcraft.rc
endif
##############################################################
# compiler
CC = g++ $(BUILDOPT) -std=c++11
# compiler flags
CCFLAGS = -c -Wall -Wextra -pedantic -Iinc
# linker flags
LFLAGS = -Llib -llibrary -lbass -llzo2 -llattice -lGLEW -DGLEW_STATIC `pkg-config --static --libs glfw3` -Wl,-rpath,../lib
ifeq ($(OS),Windows_NT)
LFLAGS = -Llib -static -llibrary -lpthread -lbassdll -lglfw3 -lgdi32 -lglew32s -lopengl32 -llzo2 -llattice -lws2_32
endif
# resource builder
RES = windres
# resource builder flags
RFLAGS = -O coff
##############################################################
# make pipeline
DIRECTORIES = $(SOURCE)
CCDIRS = $(foreach dir, $(DIRECTORIES), $(dir)/*.c)
CCMODS = $(wildcard $(CCDIRS))
CXXDIRS = $(foreach dir, $(DIRECTORIES), $(dir)/*.cpp)
CXXMODS = $(wildcard $(CXXDIRS))
# compile each .c to .o
.c.o:
$(CC) $(CCFLAGS) $< -o $@
# compile each .cpp to .o
.cpp.o:
$(CC) $(CCFLAGS) $< -o $@
# recipe for building .o from .rc files
%.o : %.rc
$(RES) $(RFLAGS) $< -o $@
# convert .c to .o
CCOBJS = $(CCMODS:.c=.o)
# convert .cpp to .o
CXXOBJS = $(CXXMODS:.cpp=.o)
# resource .rc to .o
CCRES = $(RESOURCES:.rc=.o)
.PHONY: clean all
# link all OBJS using CC and link with LFLAGS, then output to OUTPUT
all: $(CXXOBJS) $(CCOBJS) $(CCRES)
$(CC) $(CXXOBJS) $(CCOBJS) $(CCRES) $(LFLAGS) -o $(OUTPUT)
# remove each known .o file, and output
clean:
$(RM) $(CXXOBJS) $(CCOBJS) $(CCRES) *~ $(OUTPUT).*