Makefile: update make file.

This commit is contained in:
Nick Peng
2023-12-15 22:18:42 +08:00
parent 43b5d6a63d
commit c6e28d6087
3 changed files with 20 additions and 9 deletions

View File

@@ -15,8 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
BIN=smartdns
OBJS_LIB=lib/rbtree.o lib/art.o lib/bitops.o lib/radix.o lib/timer_wheel.o lib/idna.o lib/conf.o lib/nftset.o
OBJS_MAIN=smartdns.o fast_ping.o dns_client.o dns_server.o dns.o util.o tlog.o dns_conf.o dns_cache.o http_parse.o proxy.o timer.o
OBJS_LIB=$(patsubst %.c,%.o,$(wildcard lib/*.c))
OBJS_MAIN=$(patsubst %.c,%.o,$(wildcard *.c))
OBJS=$(OBJS_MAIN) $(OBJS_LIB)
# cflags
@@ -26,13 +26,23 @@ ifndef CFLAGS
else
CFLAGS = -O2
endif
CFLAGS +=-Wall -Wstrict-prototypes -fno-omit-frame-pointer -Wstrict-aliasing -funwind-tables -Wmissing-prototypes -Wshadow -Wextra -Wno-unused-parameter -Wno-implicit-fallthrough
CFLAGS +=-Wall -Wstrict-prototypes -fno-omit-frame-pointer -Wstrict-aliasing -funwind-tables -Wmissing-prototypes -Wshadow -Wextra -Wno-unused-parameter -Wno-implicit-fallthrough
endif
override CFLAGS +=-Iinclude
override CFLAGS += -DBASE_FILE_NAME='"$(notdir $<)"'
override CFLAGS += $(EXTRA_CFLAGS)
ifdef VER
override CFLAGS += -DSMARTDNS_VERION='"$(VER)"'
override CFLAGS += -DSMARTDNS_VERION='"$(VER)"'
else
HAS_GIT := $(shell command -v git 2> /dev/null)
ifdef HAS_GIT
IS_GIT_REPO := $(shell git rev-parse --is-inside-work-tree 2>/dev/null)
ifdef IS_GIT_REPO
override CFLAGS += -DSMARTDNS_VERION='"$(shell git describe --tags --always --dirty)"'
endif
endif
endif
CXXFLAGS=-O2 -g -Wall -std=c++11

View File

@@ -7167,10 +7167,11 @@ static struct addrinfo *_dns_server_getaddr(const char *host, const char *port,
const int s = getaddrinfo(host, port, &hints, &result);
if (s != 0) {
const char *error_str;
if (s == EAI_SYSTEM)
if (s == EAI_SYSTEM) {
error_str = strerror(errno);
else
} else {
error_str = gai_strerror(s);
}
tlog(TLOG_ERROR, "get addr info failed. %s.\n", error_str);
goto errout;
}

View File

@@ -23,9 +23,9 @@ CXXFLAGS += -g
CXXFLAGS += -DTEST
CXXFLAGS += -I./ -I../src -I../src/include
SMARTDNS_OBJS = lib/rbtree.o lib/art.o lib/bitops.o lib/radix.o lib/conf.o lib/nftset.o lib/timer_wheel.o lib/idna.o
SMARTDNS_OBJS += smartdns.o fast_ping.o dns_client.o dns_server.o dns.o util.o tlog.o dns_conf.o dns_cache.o http_parse.o proxy.o timer.o
OBJS = $(addprefix ../src/, $(SMARTDNS_OBJS))
OBJS_LIB=$(patsubst %.c,%.o,$(wildcard ../src/lib/*.c))
OBJS_MAIN=$(patsubst %.c,%.o,$(wildcard ../src/*.c))
OBJS = $(OBJS_LIB) $(OBJS_MAIN)
TEST_SOURCES := $(wildcard *.cc) $(wildcard */*.cc) $(wildcard */*/*.cc)
TEST_OBJECTS := $(patsubst %.cc, %.o, $(TEST_SOURCES))