-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
96 lines (63 loc) · 2.32 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
target := $(shell echo $$PWD | sed s!.*/!! )
all: $(target)
.PHONY : clean test watch uninstall doxygen setup
.DELETE_ON_ERROR : $(wildcard build/*)
####################################################################### VALUES
COPTS = -Itoolbox/include
LIBOPTS = -Ltoolbox
COPTS += -Wall -Werror -g -O2 -fno-strict-aliasing -Wno-unused-result -IX11 -Ivr_core/include -DPROJECT_NAME=\"$(target)\"
CCOPTS += $(COPTS) -std=c++11
libs = GL GLEW m X11 Xmu Xi Xext Xcomposite Xdamage stdc++ pthread png gdbm jpeg drm cairo
LIBOPTS += -ltoolbox -z noexecstack
LIBOPTS += $(addprefix -l, $(libs))
srcpath = vr_core modules
srcs = $(foreach p, $(srcpath), $(shell find $(p) -name "*.cc" -o -name "*.c" -o -name "*.glsl"))
dirs = $(sort $(dir $(srcs)))
mods = $(basename $(srcs))
dmds= $(addprefix build/, $(mods))
objs = $(addsuffix .o, $(dmds)) $(exobjs)
deps = $(addsuffix .d, $(dmds))
################################################################### EXTRA RULES
######################################################################## RULES
$(target): makefile $(objs) $(exdeps)
@echo " LD $@" $(LIBOPTS)
@gcc $(CCOPTS) -Xlinker "-Map=$(target).map" -o $@ $(objs) $(LIBOPTS)
test: $(target)
./$(target) --verbose=2
setup:
@sudo cp data/10-vr_core.rules /etc/udev/rules.d
install: $(target)
@sudo cp $(target) /usr/local/bin
@sudo cp data/vr_core.rules /etc/udev/rules.d
uninstall:
@sudo rm -f /usr/local/bin/$(target)
@sudo rm -f /etc/udev/rules.d/10-wOCE.rules
clean:
rm -fr $(target) *.map build/* *.mp4 /tmp/$(target)cast* core *.orig */*.orig html
doxygen:
doxygen Doxyfile
################################################################# COMMON RULES
-include $(deps)
vpath %.o build
vpath % $(dirs)
build/%.o : %.cc makefile build/objdir
@echo " CC $@"
@$(CC) $(CCOPTS) -c -o $@ $<
build/%.o : %.c makefile build/objdir
@echo " CC $@"
@${CC} $(COPTS) -c -o $@ $<
build/%.o : %.glsl makefile build/objdir
@echo " OBJCOPY $@"
@objcopy -I binary -O elf64-x86-64 -B i386 $< $@
build/%.d : %.cc build/objdir
@echo " CPP $@"
@echo -n build/ > $@
@$(CPP) $(CCOPTS) -MM $< >> $@
build/%.d : %.c build/objdir
@echo " CPP $@"
@echo -n build/ > $@
@$(CPP) $(COPTS) -MM $< >> $@
build/objdir:
find vr_core -type d | xargs -I DIR mkdir -p build/DIR
find modules -type d | xargs -I DIR mkdir -p build/DIR
touch build/objdir