@@ -1,19 +1,6 @@ | |||||
# http://www.gnu.org/software/automake | |||||
Makefile.in | |||||
# http://www.gnu.org/software/autoconf | |||||
/autom4te.cache | |||||
/aclocal.m4 | |||||
/compile | |||||
/configure | |||||
/depcomp | |||||
/install-sh | |||||
/missing | |||||
# Dependency files | # Dependency files | ||||
.deps | .deps | ||||
# Object files and libraries | # Object files and libraries | ||||
*.o | *.o | ||||
*.a | *.a | ||||
@@ -0,0 +1,87 @@ | |||||
# btpd - BitTorrent Protocol Daemon | |||||
# See LICENSE file for copyright and license details. | |||||
BTPD_SRC = ${wildcard btpd/*.c} | |||||
BTPD_DEPS = ${wildcard btpd/*.h} | |||||
BTPD_OBJ = ${BTPD_SRC:.c=.o} | |||||
BTCLI_SRC = ${wildcard cli/*.c} | |||||
BTCLI_DEPS = ${wildcard cli/*.h} | |||||
BTCLI_OBJ = ${BTCLI_SRC:.c=.o} | |||||
BTINFO_SRC = ${wildcard info/*.c} | |||||
BTINFO_DEPS = ${wildcard info/*.h} | |||||
BTINFO_OBJ = ${BTINFO_SRC:.c=.o} | |||||
MISC_SRC = ${wildcard misc/*.c} | |||||
MISC_DEPS = ${wildcard misc/*.h} | |||||
MISC_OBJ = ${MISC_SRC:.c=.o} | |||||
EVLOOP_SRC = ${wildcard evloop/*.c} | |||||
EVLOOP_DEPS = ${wildcard evloop/*.h} | |||||
EVLOOP_OBJ = ${EVLOOP_SRC:.c=.o} | |||||
include config.mk | |||||
all: options btpd btinfo btcli | |||||
options: | |||||
@echo btpd build options: | |||||
@echo "CFLAGS = ${CFLAGS}" | |||||
@echo "LDFLAGS = ${LDFLAGS}" | |||||
@echo "CC = ${CC}" | |||||
.c.o: | |||||
${CC} -c ${DEFS} ${CPPFLAGS} ${CFLAGS} $< -o $@ | |||||
${%_OBJ}: ${%_DEPS} | |||||
libmisc.a: ${MISC_OBJ} | |||||
ar rcs misc/$@ ${MISC_OBJ} | |||||
libevloop.a: ${EVLOOP_OBJ} | |||||
ar rcs evloop/$@ ${EVLOOP_OBJ} | |||||
btpd: ${BTPD_OBJ} libmisc.a libevloop.a | |||||
${CC} ${CFLAGS} -o btpd/$@ ${BTPD_OBJ} misc/libmisc.a evloop/libevloop.a ${LDFLAGS} | |||||
btinfo: ${BTINFO_OBJ} libmisc.a | |||||
${CC} ${CFLAGS} -o info/$@ ${BTINFO_OBJ} misc/libmisc.a ${LDFLAGS} | |||||
btcli: ${BTCLI_OBJ} libmisc.a | |||||
${CC} ${CFLAGS} -o cli/$@ ${BTCLI_OBJ} misc/libmisc.a ${LDFLAGS} | |||||
clean: | |||||
rm -f btpd/btpd cli/btcli info/btinfo\ | |||||
**/*.o **/*.a\ | |||||
btpd-${VERSION}.tar.gz | |||||
dist: clean | |||||
mkdir -p btpd-${VERSION} | |||||
cp -R COPYRIGHT Makefile README CHANGES configure config.mk btpd cli doc evloop info misc\ | |||||
btpd-${VERSION} | |||||
tar -cf btpd-${VERSION}.tar btpd-${VERSION} | |||||
gzip btpd-${VERSION}.tar | |||||
rm -rf btpd-${VERSION} | |||||
install: all | |||||
mkdir -p ${DESTDIR}${PREFIX}/bin | |||||
cp -f btpd/btpd cli/btcli info/btinfo ${DESTDIR}${PREFIX}/bin | |||||
chmod 755 ${DESTDIR}${PREFIX}/bin/btpd | |||||
chmod 755 ${DESTDIR}${PREFIX}/bin/btcli | |||||
chmod 755 ${DESTDIR}${PREFIX}/bin/btinfo | |||||
mkdir -p ${DESTDIR}${MANPREFIX}/man1 | |||||
cp -f doc/*.1 ${DESTDIR}${MANPREFIX}/man1 | |||||
chmod 644 ${DESTDIR}${MANPREFIX}/man1/btpd.1 | |||||
chmod 644 ${DESTDIR}${MANPREFIX}/man1/btcli.1 | |||||
chmod 644 ${DESTDIR}${MANPREFIX}/man1/btinfo.1 | |||||
uninstall: | |||||
rm -f ${DESTDIR}${PREFIX}/bin/btpd\ | |||||
${DESTDIR}${PREFIX}/bin/btcli\ | |||||
${DESTDIR}${PREFIX}/bin/btinfo\ | |||||
${DESTDIR}${MANPREFIX}/man1/btpd.1\ | |||||
${DESTDIR}${MANPREFIX}/man1/btcli.1\ | |||||
${DESTDIR}${MANPREFIX}/man1/btinfo.1 | |||||
.PHONY: all options clean dist install uninstall |
@@ -1,57 +0,0 @@ | |||||
AM_CFLAGS=-std=c99 -Wall @WARNNPS@ | |||||
AM_CPPFLAGS=-D_FILE_OFFSET_BITS=64 -D@EVLOOP_METHOD@ -I$(top_srcdir)/misc -I$(top_srcdir)/evloop @openssl_CPPFLAGS@ | |||||
AM_LDFLAGS=@openssl_LDFLAGS@ | |||||
bin_PROGRAMS=btpd/btpd cli/btcli cli/btinfo | |||||
noinst_LIBRARIES=misc/libmisc.a evloop/libevloop.a | |||||
dist_man1_MANS=doc/btcli.1 doc/btinfo.1 doc/btpd.1 | |||||
EXTRA_DIST=COPYRIGHT CHANGES | |||||
# btpd | |||||
btpd_btpd_SOURCES=\ | |||||
btpd/active.c btpd/active.h btpd/addrinfo.c\ | |||||
btpd/btpd.c btpd/btpd.h\ | |||||
btpd/cli_if.c btpd/content.c btpd/content.h\ | |||||
btpd/download.c btpd/download_subr.c btpd/download.h\ | |||||
btpd/http_tr_if.c\ | |||||
btpd/main.c\ | |||||
btpd/nameconn.c btpd/net.c btpd/net.h btpd/net_types.h\ | |||||
btpd/net_buf.c btpd/net_buf.h\ | |||||
btpd/opts.c btpd/opts.h\ | |||||
btpd/peer.c btpd/peer.h\ | |||||
btpd/thread_cb.c btpd/tlib.c btpd/tlib.h btpd/torrent.c btpd/torrent.h\ | |||||
btpd/tracker_req.c btpd/tracker_req.h\ | |||||
btpd/upload.c btpd/upload.h\ | |||||
btpd/util.c | |||||
btpd_btpd_CFLAGS=@TD_CFLAGS@ $(AM_CFLAGS) | |||||
btpd_btpd_LDADD=@TD_LIBS@ misc/libmisc.a evloop/libevloop.a -lcrypto -lm @CLOCKLIB@ @INETLIBS@ | |||||
# btinfo | |||||
cli_btinfo_SOURCES=cli/btinfo.c | |||||
cli_btinfo_LDADD=misc/libmisc.a -lcrypto -lm | |||||
# btcli | |||||
cli_btcli_SOURCES=cli/btcli.c cli/btcli.h cli/add.c cli/del.c cli/list.c cli/rate.c cli/kill.c cli/start.c cli/stop.c cli/stat.c | |||||
cli_btcli_LDADD=misc/libmisc.a -lcrypto -lm @INETLIBS@ | |||||
# libmisc | |||||
misc_libmisc_a_SOURCES=\ | |||||
misc/benc.c misc/benc.h\ | |||||
misc/btpd_if.c misc/btpd_if.h misc/ipcdefs.h\ | |||||
misc/metainfo.c misc/metainfo.h\ | |||||
misc/hashtable.c misc/hashtable.h\ | |||||
misc/http_client.c misc/http_client.h\ | |||||
misc/iobuf.c misc/iobuf.h\ | |||||
misc/queue.h\ | |||||
misc/stream.c misc/stream.h\ | |||||
misc/subr.c misc/subr.h\ | |||||
misc/utils.h | |||||
# evloop | |||||
EXTRA_evloop_libevloop_a_SOURCES=evloop/epoll.c evloop/kqueue.c evloop/poll.c | |||||
evloop_libevloop_a_SOURCES=\ | |||||
evloop/evloop.h\ | |||||
evloop/timeheap.c evloop/timeheap.h evloop/timer.c | |||||
evloop_libevloop_a_LIBADD=@EVLOOP_IMPL@ | |||||
evloop_libevloop_a_DEPENDENCIES=@EVLOOP_IMPL@ |
@@ -0,0 +1,26 @@ | |||||
# btpd version | |||||
NAME = btpd | |||||
VERSION = 0.16 | |||||
# paths | |||||
PREFIX = /usr | |||||
MANPREFIX = ${PREFIX}/share/man | |||||
MISC = ./misc | |||||
EVLOOP = ./evloop | |||||
# includes and libs | |||||
INCS = -I${MISC} -I${EVLOOP} | |||||
LIBS = -lcrypto -lm | |||||
# flags | |||||
CPPFLAGS = ${INCS} -DHAVE_CLOCK_MONOTONIC=1 -DEVLOOP_NONE | |||||
CFLAGS = -march=native -pipe -O3 -fno-math-errno | |||||
LDFLAGS = ${LIBS} | |||||
DEFS = -DPACKAGE_NAME=\"${NAME}\" -DPACKAGE_VERSION=\"${VERSION}\" | |||||
# compiler | |||||
CC = gcc | |||||
# excluded | |||||
EVLOOP_SRC := ${filter-out evloop/poll.c evloop/epoll.c evloop/kqueue.c, ${EVLOOP_SRC}} |
@@ -0,0 +1,43 @@ | |||||
#!/bin/sh | |||||
evloop=POLL | |||||
for arg in "$@"; do | |||||
case "$arg" in | |||||
--with-evloop-method=*) | |||||
evloop=`echo $arg | sed 's/--with-evloop-method=//'` | |||||
;; | |||||
--help|-h|*) | |||||
echo 'usage: ./configure [options]' | |||||
echo 'options:' | |||||
echo ' --with-evloop-method=<option>: select evloop method (EPOLL,POLL,KQUEUE)' | |||||
echo ' --help: show this' | |||||
exit 0 | |||||
;; | |||||
esac | |||||
done | |||||
case "$evloop" in | |||||
POLL|EPOLL|KQUEUE) | |||||
sed -i "s/DEVLOOP_.*/DEVLOOP_$evloop/g" config.mk | |||||
case "$evloop" in | |||||
POLL) | |||||
sed -i "s|filter-out .*|filter-out evloop/epoll.c evloop/kqueue.c, \${EVLOOP_SRC}}|g" config.mk | |||||
;; | |||||
EPOLL) | |||||
sed -i "s|filter-out .*|filter-out evloop/poll.c evloop/kqueue.c, \${EVLOOP_SRC}}|g" config.mk | |||||
;; | |||||
KQUEUE) | |||||
sed -i "s|filter-out .*|filter-out evloop/poll.c evloop/epoll.c, \${EVLOOP_SRC}}|g" config.mk | |||||
;; | |||||
esac | |||||
;; | |||||
*) | |||||
sed -i "s/DEVLOOP_.*/DEVLOOP_NONE/g" config.mk | |||||
sed -i "s|filter-out .*|filter-out evloop/poll.c evloop/epoll.c evloop/kqueue.c, \${EVLOOP_SRC}}|g" config.mk | |||||
;; | |||||
esac |
@@ -1,153 +0,0 @@ | |||||
AC_PREREQ(2.61) | |||||
AC_INIT(btpd, 0.16+, btpd-users@googlegroups.com) | |||||
AM_INIT_AUTOMAKE([1.10 foreign subdir-objects]) | |||||
AC_CONFIG_FILES([Makefile]) | |||||
AC_PROG_CC | |||||
AM_PROG_CC_C_O | |||||
AC_PROG_RANLIB | |||||
AC_USE_SYSTEM_EXTENSIONS | |||||
AC_DEFUN([PROG_SILENT_IFELSE], | |||||
ac_output=`$1 2>&1` | |||||
if test x"$ac_output" != x; then | |||||
echo $1 nonsilent >&AS_MESSAGE_LOG_FD | |||||
echo $ac_output >&AS_MESSAGE_LOG_FD | |||||
[$3] | |||||
else | |||||
[$2] | |||||
fi) | |||||
AC_DEFUN([CC_ARGS_OK_IFELSE], | |||||
AC_LANG_PUSH(C) | |||||
AC_LANG_CONFTEST([int foo(void) { return 12; }]) | |||||
AC_LANG_POP(C) | |||||
PROG_SILENT_IFELSE([$CC $1 -c conftest.c], | |||||
rm -f conftest.c conftest.$OBJEXT | |||||
[$2], | |||||
rm -f conftest.c conftest.$OBJEXT | |||||
[$3])) | |||||
AC_ARG_WITH(openssl, | |||||
[ --with-openssl=dir use openssl installed in dir], | |||||
[ | |||||
AC_SUBST(openssl_LDFLAGS,["-L${withval}/lib -Wl,-R,${withval}/lib"]) | |||||
AC_SUBST(openssl_CPPFLAGS,"-I${withval}/include") | |||||
]) | |||||
AC_ARG_WITH(evloop-method, | |||||
[ --with-evloop-method select evloop method (epoll,poll,kqueue)], | |||||
evloop_methods=$withval, | |||||
evloop_methods="epoll kqueue poll") | |||||
old_LIBS=$LIBS | |||||
LIBS="" | |||||
AC_SEARCH_LIBS(inet_ntop, nsl,,AC_MSG_FAILURE(btpd needs inet_ntop)) | |||||
AC_SEARCH_LIBS(bind, socket,,AC_MSG_FAILURE(btpd needs bind)) | |||||
AC_SUBST(INETLIBS,$LIBS) | |||||
LIBS=$old_LIBS | |||||
AC_CHECK_FUNCS(asprintf) | |||||
AC_MSG_CHECKING(for CLOCK_MONOTONIC) | |||||
AC_COMPILE_IFELSE([ | |||||
#include <sys/time.h> | |||||
#include <time.h> | |||||
int main(void) { return clock_gettime(CLOCK_MONOTONIC, (void *)0); } | |||||
], clock_gettime=yes, clock_gettime=no) | |||||
AC_MSG_RESULT($clock_gettime) | |||||
if test $clock_gettime = yes; then | |||||
old_LIBS=$LIBS | |||||
LIBS="" | |||||
AC_SEARCH_LIBS(clock_gettime,rt,clock_gettime=yes,clock_gettime=no) | |||||
AC_SUBST(CLOCKLIB,$LIBS) | |||||
LIBS=$old_LIBS | |||||
AC_DEFINE(HAVE_CLOCK_MONOTONIC) | |||||
fi | |||||
if test $clock_gettime = no; then | |||||
AC_CHECK_FUNCS(mach_absolute_time,, | |||||
AC_MSG_FAILURE(no supported time mechanism found)) | |||||
fi | |||||
AC_MSG_CHECKING(whether compiler accepts -Wno-pointer-sign) | |||||
CC_ARGS_OK_IFELSE(-Wno-pointer-sign, | |||||
AC_SUBST(WARNNPS,"-Wno-pointer-sign") | |||||
AC_MSG_RESULT(yes) | |||||
, | |||||
AC_MSG_RESULT(no)) | |||||
old_LDFLAGS="$LDFLAGS" | |||||
LDFLAGS="$LDFLAGS $openssl_LDFLAGS" | |||||
AC_CHECK_LIB(crypto, SHA1_Final,:,AC_MSG_FAILURE(btpd needs openssl's libraries and headers)) | |||||
LDFLAGS=$old_LDFLAGS | |||||
for m in $evloop_methods; do | |||||
case $m in | |||||
epoll) | |||||
AC_CHECK_FUNC(epoll_wait,[ | |||||
AC_SUBST(EVLOOP_IMPL,"evloop/epoll.${OBJEXT}") | |||||
AC_SUBST(EVLOOP_METHOD,EVLOOP_EPOLL) | |||||
break]) | |||||
;; | |||||
kqueue) | |||||
AC_CHECK_FUNC(kqueue,[ | |||||
AC_SUBST(EVLOOP_IMPL,"evloop/kqueue.${OBJEXT}") | |||||
AC_SUBST(EVLOOP_METHOD,EVLOOP_KQUEUE) | |||||
break]) | |||||
;; | |||||
poll) | |||||
AC_CHECK_FUNC(poll,[ | |||||
AC_SUBST(EVLOOP_IMPL,"evloop/poll.${OBJEXT}") | |||||
AC_SUBST(EVLOOP_METHOD,EVLOOP_POLL) | |||||
break]) | |||||
break | |||||
;; | |||||
*) | |||||
AC_MSG_ERROR($m is not a valid evloop method) | |||||
exit 1 | |||||
;; | |||||
esac | |||||
done | |||||
if test x"$EVLOOP_METHOD" = x; then | |||||
AC_MSG_FAILURE(no suitable evloop method found) | |||||
exit 1 | |||||
else | |||||
AC_MSG_NOTICE(selected evloop method $EVLOOP_METHOD) | |||||
fi | |||||
for i in 0 1 2 3 4 5 6 7; do | |||||
case $i in | |||||
0) if test x"$TD_CFLAGS$TD_LIBS" = x; then continue; fi;; | |||||
1) TD_CFLAGS=-pthread;; | |||||
2) TD_CFLAGS=-pthreads;; | |||||
3) TD_CFLAGS=-kthread;; | |||||
4) TD_CFLAGS=-mt;; | |||||
5) TD_LIBS=-lpthread;; | |||||
6) ;; | |||||
7) AC_MSG_FAILURE(how do you build with pthreads on this system?);; | |||||
esac | |||||
AC_MSG_CHECKING(whether pthreads compiles with flags \"$TD_CFLAGS $TD_LIBS\") | |||||
CC_ARGS_OK_IFELSE($TD_CFLAGS $CFLAGS $TD_LIBS $LIBS,, | |||||
AC_MSG_RESULT(no) | |||||
TD_CFLAGS=""; TD_LIBS="" | |||||
continue) | |||||
old_CFLAGS=$CFLAGS; old_LIBS=$LIBS | |||||
CFLAGS="$TD_CFLAGS $CFLAGS"; LIBS="$TD_LIBS $LIBS" | |||||
AC_LINK_IFELSE([ | |||||
#include <pthread.h> | |||||
int main(void) { return pthread_create(0,0,0,0);} | |||||
], [ | |||||
AC_MSG_RESULT(yes) | |||||
CFLAGS=$old_CFLAGS; LIBS=$old_LIBS | |||||
break | |||||
], [ | |||||
AC_MSG_RESULT(no) | |||||
TD_CFLAGS=""; TD_LIBS="" | |||||
CFLAGS=$old_CFLAGS; LIBS=$old_LIBS | |||||
]) | |||||
done | |||||
AC_SUBST(TD_CFLAGS) | |||||
AC_SUBST(TD_LIBS) | |||||
AC_OUTPUT |