Skip to content

Commit 1b53326

Browse files
committed
autoconf/automake support from evan
git-svn-id: http://code.sixapart.com/svn/memcached/trunk@20 b0b603af-a30f-0410-a34e-baf09ae79d0b
1 parent 1422dff commit 1b53326

9 files changed

+79
-22
lines changed

AUTHORS

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Anatoly Vorobey <[email protected]>
2+
Brad Fitzpatrick <[email protected]>

ChangeLog

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Fri, 13 Jun 2003 10:05:51 -0700 Evan Martin <[email protected]>
2+
3+
* configure.ac, autogen.sh, Makefile.am: Use autotools.
4+
* items.c, memcached.c: #include <time.h> for time(),
5+
printf time_t as %lu (is this correct?),
6+
minor warnings fixes.
7+

Makefile

-10
This file was deleted.

Makefile.am

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bin_PROGRAMS = memcached
2+
3+
memcached_SOURCES = memcached.c slabs.c items.c memcached.h
4+

README

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Dependencies:
22

3-
-- Judy, http://judy.sf.net/
4-
-- libevent, http://www.monkey.org/~provos/libevent/
3+
-- Judy, http://judy.sf.net/ (Debian package libjudy-dev)
4+
-- libevent, http://www.monkey.org/~provos/libevent/ (libevent-dev)
55

66
If using Linux, you need a kernel with epoll. Sure, libevent will
77
work with normal select, but it sucks.

autogen.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
echo "aclocal..."
4+
ACLOCAL=${ACLOCAL:-aclocal-1.7}
5+
$ACLOCAL || exit 1
6+
7+
echo "autoheader..."
8+
AUTOHEADER=${AUTOHEADER:-autoheader}
9+
$AUTOHEADER || exit 1
10+
11+
echo "automake..."
12+
AUTOMAKE=${AUTOMAKE:-automake-1.7}
13+
$AUTOMAKE --gnu --add-missing || exit 1
14+
15+
echo "autoconf..."
16+
AUTOCONF=${AUTOCONF:-autoconf}
17+
$AUTOCONF || exit 1
18+

configure.ac

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
AC_PREREQ(2.52)
2+
AC_INIT(memcached, 1.0.1, XXXzilla)
3+
AC_CONFIG_SRCDIR(memcached.c)
4+
AM_INIT_AUTOMAKE([dist-bzip2])
5+
AM_CONFIG_HEADER(config.h)
6+
7+
AC_PROG_CC
8+
AC_PROG_INSTALL
9+
10+
dnl Default to building a static executable.
11+
AC_ARG_ENABLE(static,
12+
AC_HELP_STRING([--disable-static],[build a dynamically linked executable]),
13+
, enable_static=yes)
14+
AC_MSG_CHECKING(whether to build a static executable)
15+
if test "$enable_static" = "no"; then
16+
STATIC=
17+
AC_MSG_RESULT(no)
18+
else
19+
CFLAGS="$CFLAGS -static"
20+
AC_MSG_RESULT(yes)
21+
fi
22+
23+
JUDY_URL=http://judy.sf.net
24+
AC_CHECK_HEADERS(Judy.h, , [AC_MSG_ERROR(libJudy is required. You can get it from $JUDY_URL.)])
25+
AC_CHECK_LIB(Judy, Judy1Test, , [AC_MSG_ERROR(libJudy is required. You can get it from $JUDY_URL.)])
26+
27+
LIBEVENT_URL=http://www.monkey.org/~provos/libevent/
28+
AC_CHECK_LIB(event, event_set, ,
29+
[AC_MSG_ERROR(libevent is required. You can get it from $LIBEVENT_URL)])
30+
31+
AC_CONFIG_FILES(Makefile)
32+
AC_OUTPUT

items.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <unistd.h>
1515
#include <netinet/in.h>
1616
#include <errno.h>
17+
#include <time.h>
1718
#include <event.h>
1819
#include <malloc.h>
1920
#include <Judy.h>
@@ -190,7 +191,7 @@ char *item_cachedump(unsigned int slabs_clsid, unsigned int limit, unsigned int
190191
break;
191192
if (!it)
192193
break;
193-
sprintf(temp, "ITEM %s [%u b; %u s]\r\n", it->key, it->nbytes - 2, it->time);
194+
sprintf(temp, "ITEM %s [%u b; %lu s]\r\n", it->key, it->nbytes - 2, it->time);
194195
len = strlen(temp);
195196
if (bufcurr + len +5 > memlimit) /* 5 is END\r\n */
196197
break;
@@ -219,7 +220,7 @@ void item_stats(char *buffer, int buflen) {
219220

220221
for (i=0; i<LARGEST_ID; i++) {
221222
if (tails[i])
222-
bufcurr += sprintf(bufcurr, "STAT items:%u:number %u\r\nSTAT items:%u:age %u\r\n",
223+
bufcurr += sprintf(bufcurr, "STAT items:%u:number %u\r\nSTAT items:%u:age %lu\r\n",
223224
i, sizes[i], i, now - tails[i]->time);
224225
}
225226
strcpy(bufcurr, "END");
@@ -237,7 +238,6 @@ char* item_stats_sizes(int *bytes) {
237238
if (histogram) free(histogram);
238239
if (buf) free(buf);
239240
return 0;
240-
return;
241241
}
242242

243243
/* build the histogram */

memcached.c

+11-7
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* $Id$
1616
*/
1717

18+
#include "config.h"
1819
#include <sys/types.h>
1920
#include <sys/stat.h>
2021
#include <sys/time.h>
@@ -28,7 +29,9 @@
2829
#include <string.h>
2930
#include <unistd.h>
3031
#include <netinet/in.h>
32+
#include <arpa/inet.h>
3133
#include <errno.h>
34+
#include <time.h>
3235
#include <event.h>
3336
#include <malloc.h>
3437
#include <Judy.h>
@@ -293,7 +296,7 @@ void process_stat(conn *c, char *command) {
293296
char *pos = temp;
294297

295298
pos += sprintf(pos, "STAT pid %u\r\n", pid);
296-
pos += sprintf(pos, "STAT uptime %u\r\n", now - stats.started);
299+
pos += sprintf(pos, "STAT uptime %lu\r\n", now - stats.started);
297300
pos += sprintf(pos, "STAT curr_items %u\r\n", stats.curr_items);
298301
pos += sprintf(pos, "STAT total_items %u\r\n", stats.total_items);
299302
pos += sprintf(pos, "STAT bytes %llu\r\n", stats.curr_bytes);
@@ -306,7 +309,7 @@ void process_stat(conn *c, char *command) {
306309
pos += sprintf(pos, "STAT get_misses %u\r\n", stats.get_misses);
307310
pos += sprintf(pos, "STAT bytes_read %llu\r\n", stats.bytes_read);
308311
pos += sprintf(pos, "STAT bytes_written %llu\r\n", stats.bytes_written);
309-
pos += sprintf(pos, "STAT limit_maxbytes %u\r\n", settings.maxbytes);
312+
pos += sprintf(pos, "STAT limit_maxbytes %llu\r\n", settings.maxbytes);
310313
pos += sprintf(pos, "STAT limit_maxitems %u\r\n", settings.maxitems);
311314
pos += sprintf(pos, "END");
312315
out_string(c, temp);
@@ -447,7 +450,7 @@ void process_command(conn *c, char *command) {
447450
int len, res;
448451
item *it;
449452

450-
res = sscanf(command, "%s %s %u %u %d\n", s_comm, key, &flags, &expire, &len);
453+
res = sscanf(command, "%s %s %u %lu %d\n", s_comm, key, &flags, &expire, &len);
451454
if (res!=5 || strlen(key)==0 ) {
452455
out_string(c, "CLIENT_ERROR bad command line format");
453456
return;
@@ -693,7 +696,7 @@ int try_read_network(conn *c) {
693696

694697
int update_event(conn *c, int new_flags) {
695698
if (c->ev_flags == new_flags)
696-
return;
699+
return 0;
697700
if (event_del(&c->event) == -1) return 0;
698701
event_set(&c->event, c->sfd, new_flags, event_handler, (void *)c);
699702
c->ev_flags = new_flags;
@@ -1061,6 +1064,7 @@ void delete_handler(int fd, short which, void *arg) {
10611064
}
10621065

10631066
void usage(void) {
1067+
printf(PACKAGE " " VERSION ".\n");
10641068
printf("-p <num> port number to listen on\n");
10651069
printf("-l <ip_addr> interface to listen on, default is INDRR_ANY\n");
10661070
printf("-s <num> maximum number of items to store, default is unlimited\n");
@@ -1126,7 +1130,7 @@ int main (int argc, char **argv) {
11261130
}
11271131
}
11281132

1129-
/* initialize other stuff stuff */
1133+
/* initialize other stuff */
11301134
item_init();
11311135
event_init();
11321136
stats_init();
@@ -1139,7 +1143,7 @@ int main (int argc, char **argv) {
11391143
int res;
11401144
res = daemon(0, 0);
11411145
if (res == -1) {
1142-
fprintf(stderr, "failed to fork() in order to daemonize\n");
1146+
fprintf(stderr, "failed to daemon() in order to daemonize\n");
11431147
return 1;
11441148
}
11451149
}
@@ -1170,6 +1174,6 @@ int main (int argc, char **argv) {
11701174
/* enter the loop */
11711175
event_loop(0);
11721176

1173-
return;
1177+
return 0;
11741178
}
11751179

0 commit comments

Comments
 (0)