Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

autoconf/automake support from evan

git-svn-id: http://code.sixapart.com/svn/memcached/trunk@20 b0b603af-a30f-0410-a34e-baf09ae79d0b
  • Loading branch information...
commit 1b533267341d3735a680ddc443f60bae0e6f4ee3 1 parent 1422dff
@bradfitz bradfitz authored
View
2  AUTHORS
@@ -0,0 +1,2 @@
+Anatoly Vorobey <mellon@pobox.com>
+Brad Fitzpatrick <brad@danga.com>
View
7 ChangeLog
@@ -0,0 +1,7 @@
+Fri, 13 Jun 2003 10:05:51 -0700 Evan Martin <martine@danga.com>
+
+ * configure.ac, autogen.sh, Makefile.am: Use autotools.
+ * items.c, memcached.c: #include <time.h> for time(),
+ printf time_t as %lu (is this correct?),
+ minor warnings fixes.
+
View
10 Makefile
@@ -1,10 +0,0 @@
-all: memcached
-
-memcached: memcached.c slabs.c items.c memcached.h
- $(CC) -I. -L. -static -o memcached memcached.c slabs.c items.c -levent -lJudy
-
-memcached-debug: memcached.c slabs.c items.c memcached.h
- $(CC) -g -I. -L. -static -o memcached-debug memcached.c slabs.c items.c -levent -lJudy
-
-clean:
- rm memcached memcached-debug
View
4 Makefile.am
@@ -0,0 +1,4 @@
+bin_PROGRAMS = memcached
+
+memcached_SOURCES = memcached.c slabs.c items.c memcached.h
+
View
4 README
@@ -1,7 +1,7 @@
Dependencies:
- -- Judy, http://judy.sf.net/
- -- libevent, http://www.monkey.org/~provos/libevent/
+ -- Judy, http://judy.sf.net/ (Debian package libjudy-dev)
+ -- libevent, http://www.monkey.org/~provos/libevent/ (libevent-dev)
If using Linux, you need a kernel with epoll. Sure, libevent will
work with normal select, but it sucks.
View
18 autogen.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+echo "aclocal..."
+ACLOCAL=${ACLOCAL:-aclocal-1.7}
+$ACLOCAL || exit 1
+
+echo "autoheader..."
+AUTOHEADER=${AUTOHEADER:-autoheader}
+$AUTOHEADER || exit 1
+
+echo "automake..."
+AUTOMAKE=${AUTOMAKE:-automake-1.7}
+$AUTOMAKE --gnu --add-missing || exit 1
+
+echo "autoconf..."
+AUTOCONF=${AUTOCONF:-autoconf}
+$AUTOCONF || exit 1
+
View
32 configure.ac
@@ -0,0 +1,32 @@
+AC_PREREQ(2.52)
+AC_INIT(memcached, 1.0.1, XXXzilla)
+AC_CONFIG_SRCDIR(memcached.c)
+AM_INIT_AUTOMAKE([dist-bzip2])
+AM_CONFIG_HEADER(config.h)
+
+AC_PROG_CC
+AC_PROG_INSTALL
+
+dnl Default to building a static executable.
+AC_ARG_ENABLE(static,
+ AC_HELP_STRING([--disable-static],[build a dynamically linked executable]),
+ , enable_static=yes)
+AC_MSG_CHECKING(whether to build a static executable)
+if test "$enable_static" = "no"; then
+ STATIC=
+ AC_MSG_RESULT(no)
+else
+ CFLAGS="$CFLAGS -static"
+ AC_MSG_RESULT(yes)
+fi
+
+JUDY_URL=http://judy.sf.net
+AC_CHECK_HEADERS(Judy.h, , [AC_MSG_ERROR(libJudy is required. You can get it from $JUDY_URL.)])
+AC_CHECK_LIB(Judy, Judy1Test, , [AC_MSG_ERROR(libJudy is required. You can get it from $JUDY_URL.)])
+
+LIBEVENT_URL=http://www.monkey.org/~provos/libevent/
+AC_CHECK_LIB(event, event_set, ,
+ [AC_MSG_ERROR(libevent is required. You can get it from $LIBEVENT_URL)])
+
+AC_CONFIG_FILES(Makefile)
+AC_OUTPUT
View
6 items.c
@@ -14,6 +14,7 @@
#include <unistd.h>
#include <netinet/in.h>
#include <errno.h>
+#include <time.h>
#include <event.h>
#include <malloc.h>
#include <Judy.h>
@@ -190,7 +191,7 @@ char *item_cachedump(unsigned int slabs_clsid, unsigned int limit, unsigned int
break;
if (!it)
break;
- sprintf(temp, "ITEM %s [%u b; %u s]\r\n", it->key, it->nbytes - 2, it->time);
+ sprintf(temp, "ITEM %s [%u b; %lu s]\r\n", it->key, it->nbytes - 2, it->time);
len = strlen(temp);
if (bufcurr + len +5 > memlimit) /* 5 is END\r\n */
break;
@@ -219,7 +220,7 @@ void item_stats(char *buffer, int buflen) {
for (i=0; i<LARGEST_ID; i++) {
if (tails[i])
- bufcurr += sprintf(bufcurr, "STAT items:%u:number %u\r\nSTAT items:%u:age %u\r\n",
+ bufcurr += sprintf(bufcurr, "STAT items:%u:number %u\r\nSTAT items:%u:age %lu\r\n",
i, sizes[i], i, now - tails[i]->time);
}
strcpy(bufcurr, "END");
@@ -237,7 +238,6 @@ char* item_stats_sizes(int *bytes) {
if (histogram) free(histogram);
if (buf) free(buf);
return 0;
- return;
}
/* build the histogram */
View
18 memcached.c
@@ -15,6 +15,7 @@
* $Id$
*/
+#include "config.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -28,7 +29,9 @@
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <errno.h>
+#include <time.h>
#include <event.h>
#include <malloc.h>
#include <Judy.h>
@@ -293,7 +296,7 @@ void process_stat(conn *c, char *command) {
char *pos = temp;
pos += sprintf(pos, "STAT pid %u\r\n", pid);
- pos += sprintf(pos, "STAT uptime %u\r\n", now - stats.started);
+ pos += sprintf(pos, "STAT uptime %lu\r\n", now - stats.started);
pos += sprintf(pos, "STAT curr_items %u\r\n", stats.curr_items);
pos += sprintf(pos, "STAT total_items %u\r\n", stats.total_items);
pos += sprintf(pos, "STAT bytes %llu\r\n", stats.curr_bytes);
@@ -306,7 +309,7 @@ void process_stat(conn *c, char *command) {
pos += sprintf(pos, "STAT get_misses %u\r\n", stats.get_misses);
pos += sprintf(pos, "STAT bytes_read %llu\r\n", stats.bytes_read);
pos += sprintf(pos, "STAT bytes_written %llu\r\n", stats.bytes_written);
- pos += sprintf(pos, "STAT limit_maxbytes %u\r\n", settings.maxbytes);
+ pos += sprintf(pos, "STAT limit_maxbytes %llu\r\n", settings.maxbytes);
pos += sprintf(pos, "STAT limit_maxitems %u\r\n", settings.maxitems);
pos += sprintf(pos, "END");
out_string(c, temp);
@@ -447,7 +450,7 @@ void process_command(conn *c, char *command) {
int len, res;
item *it;
- res = sscanf(command, "%s %s %u %u %d\n", s_comm, key, &flags, &expire, &len);
+ res = sscanf(command, "%s %s %u %lu %d\n", s_comm, key, &flags, &expire, &len);
if (res!=5 || strlen(key)==0 ) {
out_string(c, "CLIENT_ERROR bad command line format");
return;
@@ -693,7 +696,7 @@ int try_read_network(conn *c) {
int update_event(conn *c, int new_flags) {
if (c->ev_flags == new_flags)
- return;
+ return 0;
if (event_del(&c->event) == -1) return 0;
event_set(&c->event, c->sfd, new_flags, event_handler, (void *)c);
c->ev_flags = new_flags;
@@ -1061,6 +1064,7 @@ void delete_handler(int fd, short which, void *arg) {
}
void usage(void) {
+ printf(PACKAGE " " VERSION ".\n");
printf("-p <num> port number to listen on\n");
printf("-l <ip_addr> interface to listen on, default is INDRR_ANY\n");
printf("-s <num> maximum number of items to store, default is unlimited\n");
@@ -1126,7 +1130,7 @@ int main (int argc, char **argv) {
}
}
- /* initialize other stuff stuff */
+ /* initialize other stuff */
item_init();
event_init();
stats_init();
@@ -1139,7 +1143,7 @@ int main (int argc, char **argv) {
int res;
res = daemon(0, 0);
if (res == -1) {
- fprintf(stderr, "failed to fork() in order to daemonize\n");
+ fprintf(stderr, "failed to daemon() in order to daemonize\n");
return 1;
}
}
@@ -1170,6 +1174,6 @@ int main (int argc, char **argv) {
/* enter the loop */
event_loop(0);
- return;
+ return 0;
}
Please sign in to comment.
Something went wrong with that request. Please try again.