-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
80 lines (65 loc) · 2.57 KB
/
Copy pathMakefile
File metadata and controls
80 lines (65 loc) · 2.57 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
75
76
77
78
79
80
.PHONY: all release clean FORCE
all: range steam-haptics-player measure
release: all
CXXFLAGS = -std=c++20 -Wall -Werror
DEBUG_FLAGS = -g -Og
# -Os results in linker error regarding std::basic_string ???? but -O2 compiles and works fine????
RELEASE_FLAGS = -O2
ifeq ($(filter release,$(MAKECMDGOALS)), release)
CXXFLAGS += $(RELEASE_FLAGS)
else
CXXFLAGS += $(DEBUG_FLAGS)
endif
ifeq ($(OS),Windows_NT)
HIDAPI_PKG ?= hidapi
UNICODE_FLAG ?= -municode
LDFLAGS += -static
BUILD_DIR := build/win
else
HIDAPI_PKG ?= hidapi-hidraw
CXXFLAGS += -fPIC
LDFLAGS += -pie
BUILD_DIR := build/linux
endif
CXXFLAGS += $(shell pkg-config --cflags $(HIDAPI_PKG))
CXXFLAGS +=-IsharedSrc -ITritonLib/include
LDLIBS += $(shell pkg-config --libs $(HIDAPI_PKG))
SHARED_SRC = $(wildcard sharedSrc/*.cpp sharedSrc/*/*.cpp sharedSrc/*.c sharedSrc/*/*.c)
TRITON_SRC := $(wildcard TritonLib/src/*.cpp TritonLib/src/*/*.cpp TritonLib/src/*.c TritonLib/src/*/*.c)
RANGE_SRC = $(wildcard rangeSrc/*.cpp rangeSrc/*/*.cpp rangeSrc/*.c rangeSrc/*/*.c)
PCM_SRC = $(wildcard playPCMSrc/*.cpp playPCMSrc/*/*.cpp playPCMSrc/*.c playPCMSrc/*/*.c)
MEASURE_SRC = $(wildcard measureSrc/*.cpp measureSrc/*/*.cpp measureSrc/*.c measureSrc/*/*.c)
objects = $(patsubst %.cpp,$(BUILD_DIR)/%.o,$(filter %.cpp,$(1))) $(patsubst %.c,$(BUILD_DIR)/%.o,$(filter %.c,$(1)))
SHARED_OBJ := $(call objects,$(SHARED_SRC))
TRITON_OBJ := $(call objects,$(TRITON_SRC))
RANGE_OBJ := $(call objects,$(RANGE_SRC))
PCM_OBJ := $(call objects,$(PCM_SRC))
MEASURE_OBJ := $(call objects,$(MEASURE_SRC))
ALL_OBJ := $(SHARED_OBJ) $(TRITON_OBJ) $(RANGE_OBJ) $(PCM_OBJ) $(MEASURE_OBJ)
DEPENDENCY_FILES := $(ALL_OBJ:.o=.d)
FLAGS_FILE := $(BUILD_DIR)/.compiler-flags
FORCE:
$(FLAGS_FILE): FORCE
@mkdir -p $(dir $@)
@printf '%s\n' '$(CXXFLAGS)' | cmp -s - $@ || printf '%s\n' '$(CXXFLAGS)' > $@
range: $(RANGE_OBJ) $(SHARED_OBJ) $(TRITON_OBJ)
g++ $(LDFLAGS) -o range $(RANGE_OBJ) $(SHARED_OBJ) $(TRITON_OBJ) $(LDLIBS)
ifeq ($(filter release,$(MAKECMDGOALS)), release)
strip $@
endif
steam-haptics-player: $(PCM_OBJ) $(SHARED_OBJ) $(TRITON_OBJ)
g++ $(LDFLAGS) $(UNICODE_FLAG) -o $@ $(PCM_OBJ) $(SHARED_OBJ) $(TRITON_OBJ) $(LDLIBS)
ifeq ($(filter release,$(MAKECMDGOALS)), release)
strip $@
endif
measure: $(MEASURE_OBJ) $(SHARED_OBJ) $(TRITON_OBJ)
g++ $(LDFLAGS) -o measure $(MEASURE_OBJ) $(SHARED_OBJ) $(TRITON_OBJ) $(LDLIBS)
ifeq ($(filter release,$(MAKECMDGOALS)), release)
strip $@
endif
$(BUILD_DIR)/%.o: %.cpp $(FLAGS_FILE)
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) -MMD -MP -c $< -o $@
-include $(DEPENDENCY_FILES)
clean:
rm -rf $(BUILD_DIR) range steam-haptics-player measure