-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
110 lines (85 loc) · 3.14 KB
/
Makefile
File metadata and controls
110 lines (85 loc) · 3.14 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/make
export PREFIX :=
export CC := $(PREFIX)gcc
export CXX := $(PREFIX)g++
export LD := $(CXX)
export OBJCOPY := $(PREFIX)objcopy
export NM := $(PREFIX)nm
export SIZE := $(PREFIX)size
export BIN2O := bin2o
export GLSLANG := glslang
#-------------------------------------------------------------------------------
.SUFFIXES:
#-------------------------------------------------------------------------------
TARGET := brawshot
INCLUDES := include
SOURCES := src
GLSLSOURCES := glsl
BUILD := build
BRAWSDK := /usr/lib/blackmagic/BlackmagicRAWSDK/Linux
ASAN := #-fsanitize=address
OPTFLAGS := -O3 -g
DEFINES := -DUNIX -DGL_GLEXT_PROTOTYPES \
-DBRAWSDK_ROOT=\"$(BRAWSDK)\"
CFLAGS := $(OPTFLAGS) -Wall -std=c99 \
-ffunction-sections -fdata-sections \
$(INCLUDE) $(DEFINES) $(ASAN)
CXXFLAGS := $(OPTFLAGS) -Wall -std=c++11 \
-ffunction-sections -fdata-sections \
$(INCLUDE) $(DEFINES) $(ASAN)
LDFLAGS := $(OPTFLAGS) -Wl,-x -Wl,--gc-sections $(ASAN)
LIBS := -lGL -lEGL -lturbojpeg
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CXXFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
GLSLFILES := $(foreach dir,$(GLSLSOURCES),$(notdir $(wildcard $(dir)/*.glsl)))
ifneq ($(BUILD),$(notdir $(CURDIR)))
#-------------------------------------------------------------------------------
export DEPSDIR := $(CURDIR)/$(BUILD)
export OFILES := $(CFILES:.c=.o) $(CXXFILES:.cpp=.o) $(GLSLFILES:.glsl=.o) \
BlackmagicRawAPIDispatch.o
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(GLSLSOURCES),$(CURDIR)/$(dir)) $(CURDIR)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
-I$(CURDIR)/$(BUILD) \
-I$(BRAWSDK)/Include
export OUTPUT := $(CURDIR)/$(TARGET)
.PHONY: $(BUILD) clean all
$(BUILD):
@echo compiling...
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
all: $(BUILD)
clean:
@echo "[CLEAN]"
@rm -rf $(BUILD) $(TFILES) $(OFILES)
$(TARGET): $(TFILES)
else
#-------------------------------------------------------------------------------
# main target
#-------------------------------------------------------------------------------
.PHONY: all
all: $(OUTPUT)
$(OUTPUT): $(TARGET).elf
@cp $(TARGET).elf $(OUTPUT)
BlackmagicRawAPIDispatch.o: $(BRAWSDK)/Include/BlackmagicRawAPIDispatch.cpp
@echo "[CXX] $(notdir $@)"
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@
%.o: %.c
@echo "[CC] $(notdir $@)"
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@
@#$(CC) -S $(CFLAGS) -o $(@:.o=.s) $< # create assembly file
%.o: %.cpp
@echo "[CXX] $(notdir $@)"
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@
@#$(CXX) -S $(CXXFLAGS) -o $(@:.o=.s) $< # create assembly file
%.o: %.glsl
@echo "[GLSL] $(notdir $@)"
@$(GLSLANG) $<
@$(BIN2O) -t -l$(subst .,_,$(basename $@)) -i$< -o$@
$(TARGET).elf: $(OFILES)
@echo "[LD] $(notdir $@)"
@$(LD) $(LDFLAGS) $(OFILES) -o $@ -Wl,-Map=$(@:.elf=.map) $(LIBS)
-include $(DEPSDIR)/*.d
#-------------------------------------------------------------------------------
endif
#-------------------------------------------------------------------------------