-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
100 lines (79 loc) · 2.5 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
.SILENT:
MAKEFLAGS += --jobs=$(shell nproc)
WITH_DEBUG ?= yes
WITH_SANITIZERS ?= yes
WITH_TLS ?= yes
STATIC ?= no
CC = clang
CXX = clang++
CLANG_WARNINGS = -Weverything \
-Wno-c++98-compat \
-Wno-c++98-compat-pedantic \
-Wno-old-style-cast \
-Wno-shadow-field-in-constructor \
-Wno-padded \
-Wno-exit-time-destructors \
-Wno-double-promotion \
-Wno-implicit-int-float-conversion \
-Wno-unsafe-buffer-usage
COMPILE_FLAGS = -DOCPP_LOG_LEVEL=4 \
-DOCPP_STATE_CALLBACKS \
-gdwarf-4 \
-fPIC \
-O0 \
${CLANG_WARNINGS} \
-fdiagnostics-color=always \
-I../tfjson/src \
-Ilib/ArduinoJson \
-Ilib/mongoose \
-Isrc \
-fno-exceptions \
-fno-rtti \
-DOCPP_METER_VALUES_ALIGNED_DATA_MAX_LENGTH=20 \
-DOCPP_DEFAULT_CLOCK_ALIGNED_DATA_INTERVAL=60 \
-DOCPP_DEFAULT_METER_VALUES_ALIGNED_DATA="\"Energy.Active.Import.Register\"" \
-DOCPP_METER_VALUES_SAMPLED_DATA_MAX_LENGTH=20 \
-DOCPP_DEFAULT_METER_VALUE_SAMPLE_INTERVAL=60 \
-DOCPP_DEFAULT_METER_VALUES_SAMPLED_DATA="\"Energy.Active.Import.Register\"" \
-D_POSIX_C_SOURCE # for localtime_r and gmtime_r
ifeq ($(WITH_SANITIZERS),yes)
COMPILE_FLAGS += -fsanitize=address,undefined,leak
LDFLAGS += -fsanitize=address,undefined,leak
LIB_LD_FLAGS = -shared-libasan
endif
ifeq ($(WITH_DEBUG),yes)
COMPILE_FLAGS += -g -ggdb
endif
ifeq ($(WITH_TLS),yes)
LIBS += -lssl -lcrypto
COMPILE_FLAGS += -DMG_ENABLE_OPENSSL=1
endif
CFLAGS += -std=c99 ${COMPILE_FLAGS}
CXXFLAGS += -std=c++11 -stdlib=libc++ ${COMPILE_FLAGS}
LDFLAGS += -pthread
STATIC_FLAG =
ifeq ($(STATIC),yes)
LIBS += ./libwebsockets.a
STATIC_FLAG += -static
else
LIBS += -lwebsockets -lc++
endif
SOURCES := $(wildcard src/ocpp/*.cpp) \
lib/mongoose/mongoose.cpp \
src/platforms/LinuxWS.cpp
CFILES := src/lib/musl_libc_timegm.c \
$(wildcard src/lib/libiso8601/*.c)
SOURCES_LIB := $(SOURCES) src/platforms/TestPlatform.cpp
SOURCES_EXEC := $(SOURCES) src/platforms/LinuxPlatform.cpp
OBJECTS_LIB := ${SOURCES_LIB:.cpp=.o} ${CFILES:.c=.o}
OBJECTS_EXEC := ${SOURCES_EXEC:.cpp=.o} ${CFILES:.c=.o}
$(OBJECTS_LIB): CXXFLAGS := $(CXXFLAGS) -DOCPP_PLATFORM_TEST
$(OBJECTS_EXEC): CXXFLAGS := $(CXXFLAGS) -DOCPP_PLATFORM_LINUX
all: libocpp.so ocpp_linux
libocpp.so: $(OBJECTS_LIB)
$(CXX) $(OBJECTS_LIB) $(LIBS) $(LDFLAGS) $(LIB_LD_FLAGS) -shared -o $@
ocpp_linux: $(OBJECTS_EXEC)
$(CXX) $(OBJECTS_EXEC) $(LIBS) $(LDFLAGS) -o $@ $(STATIC_FLAG)
.PHONY: all clean
clean: Makefile
$(E)$(RM) $(OBJECTS_LIB) $(OBJECTS_EXEC) libocpp.so