forked from iqiyi/dpvs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
88 lines (67 loc) · 2.19 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
#
# DPVS is a software load balancer (Virtual Server) based on DPDK.
#
# Copyright (C) 2021 iQIYI (www.iqiyi.com).
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# Makefile for dpvs (DPVS main program).
#
TARGET := dpvs
ifneq ("$(wildcard VERSION)","")
VERSION_STRING := $(shell ./VERSION)
else
VERSION_STRING := $(shell git describe --tags --always)
endif
DATE_STRING := $(shell date +%Y.%m.%d.%H:%M:%S)
# same path of THIS Makefile
SRCDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
# Addtional libs below are needed when using dynamic link.
LIBS += -lpthread -lnuma -lrt -lm -ldl -lcrypto
ifeq ($(shell pkg-config --exists libssl && echo 0),0)
CFLAGS += $(shell pkg-config --cflags libssl)
LIBS += $(shell pkg-config --static --libs libssl)
endif
include $(SRCDIR)/config.mk
include $(SRCDIR)/dpdk.mk
INCDIRS += -I $(SRCDIR)/../include
# for dpvs main program.
CFLAGS += -D __DPVS__ -DDPVS_VERSION=\"$(VERSION_STRING)\" -DDPVS_BUILD_DATE=\"$(DATE_STRING)\"
CFLAGS += -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -mcmodel=medium
ifeq ($(shell test $(GCC_VERSION) -ge 70 && echo 1), 1)
CFLAGS += -Wno-format-truncation
CFLAGS += -Wno-stringop-truncation
CFLAGS += -Wno-address-of-packed-member
CFLAGS += -Wstringop-overflow=0
endif
ifneq ($(CONFIG_DEBUG), y)
CFLAGS += -O3
else
CFLAGS += -g -O0 -D DEBUG
CFLAGS += -rdynamic
endif
CFLAGS += $(INCDIRS)
OBJS := $(shell find $(SRCDIR) -name '*.c' | sort)
OBJS := $(patsubst %.c,%.o,$(OBJS))
all: $(TARGET)
$(TARGET): $(OBJS)
@echo " $(notdir $@)"
$(Q)$(CC) $(CFLAGS) $^ $(LIBS) -o $@
%.o: %.c
@echo " $(notdir $@)"
$(Q)$(CC) -c $(CFLAGS) $< -o $@
clean:
find $(SRCDIR) -name '*.o' | xargs rm -f
rm -f ./$(TARGET)
install:
install -m 744 $(TARGET) $(INSDIR)