-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
40 lines (29 loc) · 837 Bytes
/
Makefile
File metadata and controls
40 lines (29 loc) · 837 Bytes
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
#Generic makefile for this project
SHELL := /bin/bash
SRC_PATH := src
INC_PATH := include
BUILD_PATH := build
BIN_PATH := bin
CXX := g++
CXXFLAGS += -g -std=c++17 -Wall -Wextra -pedantic
EXECUTABLE := snmp_agent
BIN := $(BIN_PATH)/$(EXECUTABLE)
SRC_CPP_EXT := cpp
SOURCES := $(shell find $(SRC_PATH) -type f -name *.$(SRC_CPP_EXT))
OBJECTS := $(patsubst $(SRC_PATH)/%, $(BUILD_PATH)/%, $(SOURCES:.$(SRC_CPP_EXT)=.o))
INC := -I $(INC_PATH)
$(BIN): $(OBJECTS)
@mkdir -p $(BIN_PATH)
@echo "Linking $(BIN)..."
$(CXX) $^ $(CXXFLAGS) -o $(BIN).elf
@echo "Linking done"
@echo "Build done"
$(BUILD_PATH)/%.o: $(SRC_PATH)/%.$(SRC_CPP_EXT)
@mkdir -p $(BUILD_PATH)
@echo "Compiling $<..."
$(CXX) -c $(CXXFLAGS) $(INC) $< -o $@
@echo ""
.PHONY: clean
clean:
@echo "Cleaning project..."
rm -r $(BUILD_PATH)/* $(BIN_PATH)/*