-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (43 loc) · 1.29 KB
/
Copy pathMakefile
File metadata and controls
54 lines (43 loc) · 1.29 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
# Template for Makefile from: https://www.geeksforgeeks.org/cpp/makefile-in-c-and-its-applications/
# Compiler
CXX = g++
NVCC = nvcc
# Compiler flags
CXXFLAGS = -Wall -g -O3
NVCC_FLAGS = -g -O3
# Target executable
BUILD_DIR = build
TARGET = $(BUILD_DIR)/main
# Source files
SRCS = src/main.cpp src/img.cpp src/convolution-cpu.cpp
HEADERS = src/img.hpp
CU_SRCS = \
src/setup.cu \
src/convolution-kernel.cu \
src/grayscale-kernel.cu \
src/grayscale-dither-kernel.cu \
src/mask-generators/gradient-mask-generator.cu \
src/apply-mask-kernel.cu \
src/inversion-kernel.cu \
src/mirror-kernel.cu \
src/mask-generators/radial-mask-generator.cu
# Object files
OBJS := $(addprefix $(BUILD_DIR)/, $(SRCS:.cpp=.o))
CU_OBJS := $(addprefix $(BUILD_DIR)/, $(CU_SRCS:.cu=.o))
# Default rule to build and run the executable
all: $(TARGET)
# Rule to link object files into the target executable
$(TARGET): $(OBJS) $(CU_OBJS)
$(NVCC) $(NVCC_FLAGS) -o $@ $^
$(BUILD_DIR)/%.o: %.cpp | $(BUILD_DIR)
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o: %.cu | $(BUILD_DIR)
@mkdir -p $(dir $@)
$(NVCC) $(NVCC_FLAGS) -c $< -o $@
# Make sure the build directory is present
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
# Clean rule to remove generated files
clean:
rm -rf $(BUILD_DIR)