Nick Peng 2 лет назад
Родитель
Сommit
c6e28d6087
3 измененных файлов с 20 добавлено и 9 удалено
  1. 14 4
      src/Makefile
  2. 3 2
      src/dns_server.c
  3. 3 3
      test/Makefile

+ 14 - 4
src/Makefile

@@ -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 

+ 3 - 2
src/dns_server.c

@@ -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;
 	}

+ 3 - 3
test/Makefile

@@ -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))