-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
75 lines (68 loc) · 1.93 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
.PHONY: all build test clean
CC = gcc
SOURCES = $(wildcard src/*.c)
TEST = false
BUILD_FLAGS = \
-std=gnu11 -pedantic -Wall \
-Wno-missing-braces -Wextra -Wno-missing-field-initializers -Wformat=2 \
-Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith \
-Wbad-function-cast -Wstrict-overflow=5 -Wstrict-prototypes -Winline \
-Wundef -Wnested-externs -Wcast-qual -Wshadow -Wunreachable-code \
-Wlogical-op -Wfloat-equal -Wstrict-aliasing=2 -Wredundant-decls \
-Wold-style-definition -Wno-pedantic-ms-format -Werror \
-g -O0 \
-fno-omit-frame-pointer -ffloat-store -fno-common
ifeq ($(OS),Windows_NT)
NULL_CMD = cd.
INCLUDE_FLAGS = -I"C:\Program Files\OpenSSL-Win64\include"
LINK_FLAGS = -lWs2_32 -L"C:\Program Files\OpenSSL-Win64\bin" -llibcrypto-3-x64
BUILD_SHARED_OUT = bin/cdtp.dll
MOVE_OBJECTS = move /y *.o bin >NUL
CLEAN_OBJECTS = del bin\*.o
TEST_BINARY = bin\test
POST_BUILD_CMD = $(NULL_CMD)
CLEAN_CMD = del bin\libcdtp.so bin\cdtp.dll bin\test bin\test.exe bin\*.o *.o
else
NULL_CMD = :
INCLUDE_FLAGS =
LINK_FLAGS = -lpthread -L/usr/src/openssl-3.0.7 -l:libcrypto.so.3
BUILD_SHARED_OUT = bin/libcdtp.so
MOVE_OBJECTS = mv *.o bin/
CLEAN_OBJECTS = rm -f bin/*.o
TEST_BINARY = ./bin/test
POST_BUILD_CMD = chmod +x ./bin/test
CLEAN_CMD = rm -f bin/libcdtp.so bin/cdtp.dll bin/test bin/test.exe bin/*.o *.o
endif
ifeq ($(TEST),true)
BUILD_DIRECTIVES = -DCDTP_TEST
BUILD_TEST_BINARY_CMD = \
$(CC) -o bin/test \
$(INCLUDE_FLAGS) \
$(BUILD_FLAGS) \
test/*.c -L./bin -Wl,-rpath=./bin -lcdtp
else
BUILD_DIRECTIVES =
BUILD_TEST_BINARY_CMD = $(NULL_CMD)
endif
all: build
build:
$(CC) -c \
-fPIC \
$(INCLUDE_FLAGS) \
$(BUILD_FLAGS) \
$(BUILD_DIRECTIVES) \
$(SOURCES) && \
$(MOVE_OBJECTS) && \
$(CC) -o $(BUILD_SHARED_OUT) \
-fPIC \
-shared \
$(BUILD_FLAGS) \
bin/*.o \
$(LINK_FLAGS) && \
$(BUILD_TEST_BINARY_CMD) && \
$(POST_BUILD_CMD) && \
$(CLEAN_OBJECTS)
test:
$(TEST_BINARY)
clean:
$(CLEAN_CMD)