-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (65 loc) · 1.84 KB
/
Makefile
File metadata and controls
81 lines (65 loc) · 1.84 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
LANG:=C++
OUTPUT:=avc-vision
LIBS:= $(shell pkg-config --cflags --libs opencv)
FLAGS:= -O2
ifeq "$(LANG)" "C++"
EXT:=cpp
STD:=c++11
CC:=$(CXX)
else ifeq "$(LANG)" "C"
EXT:=c
STD:=c99
CC:=$(CC)
else
$(error Invalid language specified)
endif
SRC:=$(shell find src -name *.${EXT})
OBJ:=$(SRC:src/%.${EXT}=obj/%.o)
DEP:=$(OBJ:%.o=%.d)
CFLAGS:= -std=$(STD) $(FLAGS)
SHELL := /bin/bash
INSTALL_DIR := /usr/sbin/
build : compile remove_unused_objects
rebuild : clean build
install : build
@install ./$(OUTPUT) $(INSTALL_DIR)
@install -D values.txt /etc/avc.conf.d/values.txt
@echo Install complete!
uninstall :
-@rm $(INSTALL_DIR)/$(OUTPUT)
@echo Uninstall complete!
compile : $(OBJ)
@$(CC) $^ -o $(OUTPUT) $(CFLAGS) $(LIBS)
@echo "Linking done. Compilation successful."
obj/%.o : src/%.$(EXT)
@mkdir -p $(@D) # $(@D) <- Gets directory part of target path
@if $(CC) $< -o $@ $(CFLAGS) -c -MMD -MP; then\
echo -e "Compiled `tput bold``tput setaf 3`$<`tput sgr0`.";\
fi
-include $(DEP)
-FILES_IN_OBJ = $(shell find obj -name *.o)
remove_unused_objects :
ifneq '' '$(filter-out $(OBJ), $(FILES_IN_OBJ))' # finds out which object files no longer have an associated source file
@rm -r $(filter-out $(OBJ), $(FILES_IN_OBJ))
-@rm -r $(filter-out $(DEP), $(FILES_IN_OBJ:%.o=%.d))
@echo "Cleaned out unused .o and .dep files"
else
@echo "No object files require deletion."
endif
cleanImages:
@rm -f $$(find . -name "*-step??-*.png");
clean : cleanImages
@rm -fr obj/* $(shell find . -name $(OUTPUT)*)
@echo "Cleaned out object files and binaries."
debug :
@echo Language Selected: $(LANG)
@echo Compiler: $(CC)
@echo Standard Library: $(STD)
@echo Libraries: $(LIBS)
@echo
@echo Binary Name: $(OUTPUT)
@echo Source Files: $(SRC)
@echo Object Files: $(OBJ)
@echo Dependencies: $(DEP)
@echo All files in Object folder: $(FILES_IN_OBJ)
@echo