-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
27 lines (27 loc) · 907 Bytes
/
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
TARGET := cvgrab
CC := gcc
CXX := g++
LD := g++
LDLIBS := -lopencv_core -lopencv_imgproc -lopencv_objdetect -lopencv_highgui -lrt -lpthread -llz4 -lturbojpeg
MODULES := ./
SRC_DIR := $(addprefix src/,$(MODULES))
BUILD_DIR := $(addprefix build/,$(MODULES))
SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c))
OBJ := $(patsubst src/%.c,build/%.o,$(SRC))
INCLUDES := $(addprefix -I,$(SRC_DIR))
CPPFLAGS := -Wall -ggdb3 -Wno-int-to-pointer-cast
vpath %.c $(SRC_DIR)
define make-goal
$1/%.o: %.c
$(CXX) $(INCLUDES) $(CPPFLAGS) $(LDLIBS) -c $$< -o $$@
endef
.PHONY: all checkdirs clean
all: checkdirs build/$(TARGET)
build/$(TARGET): $(OBJ)
$(LD) $(LDLIBS) $^ -o $@
checkdirs: $(BUILD_DIR)
$(BUILD_DIR):
@mkdir -p $@
clean:
@$(foreach bdir,$(BUILD_DIR),echo "Cleaning: $(bdir)"; rm -rf $(bdir)*.o;)
$(foreach bdir,$(BUILD_DIR),$(eval $(call make-goal,$(bdir))))