Commit 1082e7f6 authored by Leigh Stoller's avatar Leigh Stoller

Move sample client to its own directory (event/example) for clarity.

parent 93ed773b
......@@ -8,7 +8,7 @@ SUBDIR = event
include $(OBJDIR)/Makeconf
SUBDIRS = lib sched tbgen
SUBDIRS = lib sched tbgen example
all: $(SUBDIRS)
......@@ -23,8 +23,8 @@ sched:
tbgen:
@$(MAKE) -C tbgen all
test:
@$(MAKE) -C test all
example:
@$(MAKE) -C example all
install:
@$(MAKE) -C lib install
......@@ -37,14 +37,15 @@ subdir-clean:
@$(MAKE) -C lib clean
@$(MAKE) -C sched clean
@$(MAKE) -C tbgen clean
@$(MAKE) -C test clean
@$(MAKE) -C example clean
distclean: subdir-distclean
subdir-distclean:
@$(MAKE) -C lib clean
@$(MAKE) -C sched clean
@$(MAKE) -C test clean
@$(MAKE) -C lib distclean
@$(MAKE) -C sched distclean
@$(MAKE) -C tbgen distclean
@$(MAKE) -C example distclean
.PHONY: $(SUBDIRS)
SRCDIR = @srcdir@
TESTBED_SRCDIR = @top_srcdir@
OBJDIR = ../..
SUBDIR = event/example
PROGRAMS = example
include $(OBJDIR)/Makeconf
all: $(PROGRAMS)
include $(TESTBED_SRCDIR)/GNUmakerules
CFLAGS += -DDEBUG
CFLAGS += -O -g -static -Wall -pthread
CFLAGS += -I. -I${OBJDIR} -I$(SRCDIR)/../lib -I$(TESTBED_SRCDIR)/lib/libtb
CFLAGS += `elvin-config --cflags vin4mt`
LDFLAGS += -pthread -L../lib -L${OBJDIR}/lib/libtb
LIBS += -levent -ltb
LIBS += -lcipher -lc_r
#
# XXX elvin-config adds -lc which is rather bogus, and messes up -pthread
# build on freebsd. I made a vain attempt to filter it out, but
# gave up quickly. Deal with it later.
#
#LIBS += `elvin-config --libs vin4mt`
LIBS += -L/usr/local/lib -lvin4mt -lvin4c -lvin4 -lssl -lcrypto -lm
example: example.o
$(CC) $(LDFLAGS) -static -o $@ example.o $(LIBS)
$(PROGRAMS): ../lib/libevent.a ../lib/event.h
install:
clean:
/bin/rm -f *.o $(PROGRAMS)
......@@ -12,6 +12,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <time.h>
#include "log.h"
#include "event.h"
static char *progname;
......@@ -56,6 +57,8 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
loginit("sample", 0);
/*
* Get our IP address. Thats how we name ourselves to the
* Testbed Event System.
......@@ -65,13 +68,11 @@ main(int argc, char **argv)
struct in_addr myip;
if (gethostname(buf, sizeof(buf)) < 0) {
ERROR("could not get hostname\n");
return 1;
fatal("could not get hostname");
}
if (! (he = gethostbyname(buf))) {
ERROR("could not get IP address from hostname\n");
return 1;
fatal("could not get IP address from hostname");
}
memcpy((char *)&myip, he->h_addr, he->h_length);
strcpy(ipbuf, inet_ntoa(myip));
......@@ -97,8 +98,7 @@ main(int argc, char **argv)
*/
tuple = address_tuple_alloc();
if (tuple == NULL) {
ERROR("could not allocate an address tuple\n");
return 1;
fatal("could not allocate an address tuple");
}
/*
* Change this stuff as needed.
......@@ -116,16 +116,14 @@ main(int argc, char **argv)
*/
handle = event_register(server, 0);
if (handle == NULL) {
ERROR("could not register with event system\n");
return 1;
fatal("could not register with event system");
}
/*
* Subscribe to the event we specified above.
*/
if (! event_subscribe(handle, callback, tuple, NULL)) {
ERROR("could not subscribe to event\n");
return 1;
fatal("could not subscribe to event");
}
/*
......@@ -137,8 +135,7 @@ main(int argc, char **argv)
* Unregister with the event system:
*/
if (event_unregister(handle) == 0) {
ERROR("could not unregister with event system\n");
return 1;
fatal("could not unregister with event system");
}
return 0;
......
......@@ -3,7 +3,11 @@ TESTBED_SRCDIR = @top_srcdir@
OBJDIR = ../..
SUBDIR = event/tbgen
PROGRAMS = tbmevc tbmevd sample-client tbmevd.restart
SYSTEM := $(shell uname -s)
PROGRAMS = tbmevc
ifneq ($(SYSTEM),Linux)
PROGRAMS += tbmevd tbmevd.restart
endif
include $(OBJDIR)/Makeconf
......@@ -11,11 +15,16 @@ all: $(PROGRAMS)
include $(TESTBED_SRCDIR)/GNUmakerules
CFLAGS += -O -g -static -I. -I$(SRCDIR)/../lib -Wall -pthread -DDEBUG
CFLAGS += -DDEBUG
CFLAGS += -O -g -static -Wall -pthread
CFLAGS += -I. -I${OBJDIR} -I$(SRCDIR)/../lib -I$(TESTBED_SRCDIR)/lib/libtb
CFLAGS += `elvin-config --cflags vin4mt`
LDFLAGS += -static -pthread -L../lib
LIBS += -levent -lcipher -lc_r
LDFLAGS += -pthread -L../lib -L${OBJDIR}/lib/libtb
LIBS += -levent -ltb
ifneq ($(SYSTEM),Linux)
LIBS += -lcipher -lc_r
endif
#
# XXX elvin-config adds -lc which is rather bogus, and messes up -pthread
......@@ -26,13 +35,11 @@ LIBS += -levent -lcipher -lc_r
LIBS += -L/usr/local/lib -lvin4mt -lvin4c -lvin4 -lssl -lcrypto -lm
tbmevc: tbmevc.o
$(CC) $(LDFLAGS) -o $@ tbmevc.o $(LIBS)
$(CC) $(LDFLAGS) -static -o $@ tbmevc.o $(LIBS)
tbmevd: tbmevd.o
$(CC) $(LDFLAGS) -o $@ tbmevd.o $(LIBS)
sample-client: sample-client.o
$(CC) $(LDFLAGS) -o $@ sample-client.o $(LIBS)
$(CC) $(LDFLAGS) -o $@ tbmevd.o \
-L/usr/local/lib/mysql -lmysqlclient $(LIBS)
$(PROGRAMS): ../lib/libevent.a ../lib/event.h
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment