-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (45 loc) · 1.38 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
# - inc/
# - *.h
# - src/
# - *.c
# - *.cpp
# - obj/
# - *.o
# - main
ifeq ($(shell echo $$OS),$$OS)
MAKEDIR = if not exist "$(1)" mkdir "$(1)"
RM = if exist "$(1)" del /F /S /Q "$(1)"
else
MAKEDIR = '$(SHELL)' -c "mkdir -p \"$(1)\""
RM = '$(SHELL)' -c "rm -rf \"$(1)\""
endif
TARGET := main
BUILD := build
SRCDIR := src
INCDIR := include
SOURCES := $(wildcard $(SRCDIR)/*.c $(SRCDIR)/*.cpp)
OBJECTS := $(patsubst $(SRCDIR)%, $(BUILD)%, $(patsubst %.c,%.o, $(patsubst %.cpp,%.o,$(SOURCES))))
HEADERPATH := /usr/lib/aarch64-linux-gnu/hdf5/serial/include
INCLUDE := -I. -I./$(INCDIR) -I$(HEADERPATH)
LIBPATH := -L /usr/lib/aarch64-linux-gnu/hdf5/serial
LIBS := -lncursesw -lwiringPi -li2c -lpthread -lhdf5 -lhdf5_hl_cpp -lhx711 -llgpio
FLAGS := -Wall -g -otest
CCFLAGS := $(FLAGS) -std=c99
CXXFLAGS := $(FLAGS) -std=c++2a
CC := gcc
CXX := g++
all: $(TARGET)
$(TARGET): $(OBJECTS)
$(CXX) $(CXXFLAGS) $(INCLUDE) $(OBJECTS) -o $(TARGET) $(LIBPATH) $(LIBS)
$(BUILD)/%.o: $(SRCDIR)/%.c | $(BUILD)
$(CC) $(CCFLAGS) $(INCLUDE) -c $< -o $@
$(BUILD):
$(call MAKEDIR,$(BUILD))
$(BUILD)/%.o: $(SRCDIR)/%.cpp | $(BUILD)
$(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@
.PHONY: clean help
clean:
$(call RM,$(BUILD))
$(call RM,$(TARGET))
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'