forked from reyanvaldes/S7-cpp-for-Snap7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (41 loc) · 1.31 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
LIBNAME = S7-cpp-for-Snap7
SOURCEFILES_LIST = \
s7.cpp
CXX ?= g++
LINK.a = ar $(ARFLAGS) $@ $%
CXXSTD = -std=c++98
OPTIMIZED = -O2
# For trivial projects, where this is not recursively called
OBJDIR ?= .
# common flags (common for C and C++ compiler)
CCFLAGS += $(ARCHITECTURE) -g -DDMSG -D_REENTRANT -Wall -Wextra -Wshadow
CCFLAGS += $(OPTIMIZED) $(DEBUG) $(POSINDEPCODE)
# C++ compiler flags
CXXFLAGS += $(CXXSTD)
# Does the user want more detailed build output?
ifneq (${V},1)
VERBOSE_DO=@
else
VERBOSE_DO=
endif
ALLTHINGS = $(OBJDIR)/$(LIBNAME).a
OBJECTS = $(patsubst %.cpp,$(OBJDIR)/%.o,$(patsubst %.cc,$(OBJDIR)/%.o,$(SOURCEFILES_LIST)))
DEPENDS = $(OBJECTS:%.o=%.d)
all: $(OBJDIR) $(ALLTHINGS)
-include $(DEPENDS)
$(OBJDIR)/%.o : %.cpp
@echo "CXX $(subst $(OBJDIR)/,,$<)"
$(VERBOSE_DO)$(CXX) $(CPPFLAGS) $(CCFLAGS) $(CXXFLAGS) -MMD -c $< -o $@
$(OBJDIR)/$(LIBNAME).a: $(OBJECTS)
@echo "AR $@"
$(VERBOSE_DO)$(LINK.a) $^ > /dev/null 2>&1
$(OBJDIR):
@test -d $@ || echo "MKDIR $@" && mkdir -p $@
.PHONY: clean
clean:
@echo "RM $(subst $(OBJDIR)/,,$(OBJECTS))"
@rm -f $(OBJECTS)
@echo "RM $(subst $(OBJDIR)/,,$(ALLTHINGS))"
@rm -f $(ALLTHINGS)
@echo "RM $(subst $(OBJDIR)/,,$(DEPENDS))"
@rm -f $(DEPENDS)