diff --git a/.gitignore b/.gitignore index 1ce28cf..437aae6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,41 @@ -chinadns +*.cmake +*.dSYM +*.exp +*.la +*.lo +*.log +*.o +*.plist +*.scan +*.sdf +*.status +*.tar.* +*~ +.DS_Store +.deps +.dirstamp +.done +.libs +Build +Makefile +Makefile.in +aclocal.m4 +autom4te.cache +build +compile +confdefs.h +config.* +configure +depcomp +android-toolchain +install-sh +libtool +ltmain.sh +m4/argz.m4 +m4/libtool.m4 +m4/ltoptions.m4 +m4/ltsugar.m4 +m4/ltversion.m4 +m4/lt~obsolete.m4 +src/chinadns +missing diff --git a/Makefile b/Makefile deleted file mode 100644 index ec218ed..0000000 --- a/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -CC ?= gcc -DESTDIR ?= /usr/local - -all: chinadns - -chinadns: src/chinadns.c - $(CC) -Wall -O3 src/chinadns.c -lresolv -o chinadns - -.PHONY: clean all install - -install: chinadns - install -d $(DESTDIR)/bin/ - install chinadns $(DESTDIR)/bin/ - -clean: - rm -f chinadns diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..af437a6 --- /dev/null +++ b/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/README.md b/README.md index 151904f..9fe26cc 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,10 @@ Install * Linux / Unix - make + Download a [release]. + + ./configure && make + src/chinadns -l iplist.txt * OpenWRT @@ -99,5 +102,6 @@ Mailing list: http://groups.google.com/group/shadowsocks [ChinaDNS]: https://github.com/clowwindy/ChinaDNS [Download]: https://sourceforge.net/projects/chinadns/files/dist/ [Issue Tracker]: https://github.com/clowwindy/ChinaDNS-C/issues?state=open +[release]: https://github.com/clowwindy/ChinaDNS-C/releases [SDK]: http://wiki.openwrt.org/doc/howto/obtain.firmware.sdk [Travis CI]: https://travis-ci.org/clowwindy/ChinaDNS-C diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..fd933df --- /dev/null +++ b/configure.ac @@ -0,0 +1,34 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.67]) +AC_INIT([ChinaDNS-C], [1.0.1], [clowwindy42@gmail.com]) +AC_CONFIG_SRCDIR([src/chinadns.c]) +AC_CONFIG_HEADERS([config.h]) + +AM_INIT_AUTOMAKE([foreign -Wall]) + +# Checks for programs. +AC_PROG_CC +AC_PROG_INSTALL + +# Checks for libraries. +# FIXME: Replace `main' with a function in `-lresolv': +AC_CHECK_LIB([resolv], [main]) + +# Checks for header files. +AC_HEADER_RESOLV +AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h stdlib.h string.h sys/socket.h unistd.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_TYPE_SIZE_T +AC_TYPE_SSIZE_T +AC_TYPE_UINT16_T + +# Checks for library functions. +AC_FUNC_MALLOC +AC_FUNC_REALLOC +AC_CHECK_FUNCS([inet_ntoa memset select socket strchr strdup]) + +AC_CONFIG_FILES([Makefile src/Makefile]) +AC_OUTPUT diff --git a/openwrt/Makefile b/openwrt/Makefile index 2ff0b32..0710db2 100644 --- a/openwrt/Makefile +++ b/openwrt/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=ChinaDNS-C -PKG_VERSION:=1.0.0 +PKG_VERSION:=1.0.1 PKG_RELEASE=$(PKG_SOURCE_VERSION) PKG_SOURCE_URL:=https://github.com/clowwindy/ChinaDNS-C/archive @@ -41,7 +41,7 @@ define Package/ChinaDNS-C/install $(INSTALL_CONF) ../iplist.txt $(1)/etc/chinadns_iplist.txt $(INSTALL_BIN) ./files/chinadns.init $(1)/etc/init.d/chinadns $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/chinadns $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/chinadns $(1)/usr/bin endef $(eval $(call BuildPackage,ChinaDNS-C)) diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..1292e9f --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,5 @@ +bin_PROGRAMS = chinadns + +chinadns_SOURCES = chinadns.c + +chinadns_LDADD = -lresolv diff --git a/src/chinadns.c b/src/chinadns.c index e972c3d..8b8792c 100644 --- a/src/chinadns.c +++ b/src/chinadns.c @@ -11,6 +11,10 @@ #include #include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + typedef struct { time_t ts; char *buf; @@ -36,7 +40,11 @@ static char global_buf[BUF_SIZE]; static int verbose = 0; -static const char *version = "ChinaDNS 1.0.0"; +#if defined(PACKAGE_STRING) +static const char *version = PACKAGE_STRING; +#else +static const char *version = "ChinaDNS"; +#endif static const char *default_dns_servers = "114.114.114.114,8.8.8.8,208.67.222.222";