Skip to content

Commit

Permalink
use autotools
Browse files Browse the repository at this point in the history
  • Loading branch information
clowwindy committed Jul 29, 2014
1 parent c6c9626 commit dbc22b2
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 21 deletions.
42 changes: 41 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -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
16 changes: 0 additions & 16 deletions Makefile

This file was deleted.

1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SUBDIRS = src
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ Install

* Linux / Unix

make
Download a [release].

./configure && make
src/chinadns -l iplist.txt

* OpenWRT

Expand Down Expand Up @@ -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
34 changes: 34 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -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], [[email protected]])
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
4 changes: 2 additions & 2 deletions openwrt/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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))
5 changes: 5 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bin_PROGRAMS = chinadns

chinadns_SOURCES = chinadns.c

chinadns_LDADD = -lresolv
10 changes: 9 additions & 1 deletion src/chinadns.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include <sys/socket.h>
#include <sys/types.h>

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

typedef struct {
time_t ts;
char *buf;
Expand All @@ -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";
Expand Down

0 comments on commit dbc22b2

Please sign in to comment.