-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
64 lines (46 loc) · 2.01 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
#----------------------------------------
# Prepare flags from make generator
#----------------------------------------
include build/conanbuildinfo.mak
CCFLAGS += $(CONAN_CFLAGS)
CXXFLAGS += $(CONAN_CXXFLAGS)
CPPFLAGS += $(addprefix -I, $(CONAN_INCLUDE_DIRS))
CPPFLAGS += $(addprefix -D, $(CONAN_DEFINES))
LDFLAGS += $(addprefix -L, $(CONAN_LIB_DIRS))
LDLIBS += $(addprefix -l, $(CONAN_LIBS))
EXELINKFLAGS += $(CONAN_EXELINKFLAGS)
CC = g++
#----------------------------------------
# Make variables for a sample App
#----------------------------------------
BINARY=oll
CODEDIRS=. src/ # look in both the `src` dir and in the `src/driver`
DRIVERDIR=. src/driver/
INCDIRS=. "src/include/", "src/OpenXR-SDK/include", "src/driver/include"# can be list
OINCDIRS=. src/OpenXR-SDK/include/openxr
# automatically add the -I onto each include directory
CFLAGS=-Wall -Wextra -g -std=c++20 $(foreach D,$(INCDIRS),-I$(D)) $(foreach D,$(OINCDIRS),-I$(D)) $(OPT) $(DEPFLAGS)
# do the exact same thing as the previous command, but only in the openxr directory.
#OFLAGS=-Wall -Wextra -g $(foreach D, $(OINCDIRS), -I$(D)) $(OPT) $(DEPFLAGS)
# for-style iteration (foreach) and regular expression completions (wildcard)
CFILES=$(foreach D,$(CODEDIRS),$(wildcard $(D)/*.cc))
DFILES=$(foreach D,$(DRIVERDIR), $(wildcard $(D)/*.cc))
# regular expression replacement
OBJECTS=$(patsubst %.cc,%.o,$(CFILES))
DEPFILES=$(patsubst %.cc,%.d,$(CFILES))
DOBJ=$(patsubst $.cc,%.o,$(DFILES))
DDEPFILE=$(patsubst %.cc,%.d,$(DFILES))
#----------------------------------------
# Make Rules
#----------------------------------------
all: $(BINARY)
$(BINARY): $(OBJECTS)
$(CC) $(OBJECTS) $(DOBJ) $(CXXFLAGS) $(LDFLAGS) $(LDLIBS) -lXau -lpthread -ldl -ludev -o $(BINARY)
mv $(BINARY) build/
#rm -rf $(OBJECTS) $(DEPFILES)
%.o: %.cpp %.cc
(CC) -c $(CPPFLAGS) $(CXXFLAGS) $(CFLAGS) $< -o $@
clean:
rm -rf $(BINARY)
rm -rf $(OBJECTS)
rm -rf $(DEPFILES)