Commit 4dad8ebe authored by Leigh Stoller's avatar Leigh Stoller

Isolate the pain of building threaded (and statically linked) event

system programs. Build two versions of the event library, one for non
threaded programs and another (libevent_r.a) for threaded versions.
Remove all that -pthread goo from all of the makefiles, except for the
scheduler (which is threaded); it gets linked as before, but with
-levent_r instead. If you try and use the threaded API without the
proper link, the library will print an error message and quit.
parent a86f0211
......@@ -9,23 +9,15 @@ all: delay-agent
include $(TESTBED_SRCDIR)/GNUmakerules
CFLAGS += -pthread
#CFLAGS += -DDEBUG
CFLAGS += -O -g -Wall
CFLAGS += -I. -I${OBJDIR} -I$(SRCDIR)/../lib -I$(TESTBED_SRCDIR)/lib/libtb
CFLAGS += `elvin-config --cflags vin4mt`
CFLAGS += `elvin-config --cflags vin4c`
LDFLAGS += -pthread -static
LDFLAGS += -static
LDFLAGS += -L../lib -L${OBJDIR}/lib/libtb
LIBS += -levent -ltb -lcipher
#
# 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
LIBS += -levent -ltb
LIBS += `elvin-config --libs vin4c`
OBJS = main.o callback.o
......
......@@ -12,21 +12,13 @@ all: $(PROGRAMS)
include $(TESTBED_SRCDIR)/GNUmakerules
CFLAGS += -DDEBUG
CFLAGS += -O -g -static -Wall -pthread
CFLAGS += -O -g -static -Wall
CFLAGS += -I. -I${OBJDIR} -I$(SRCDIR)/../lib -I$(TESTBED_SRCDIR)/lib/libtb
CFLAGS += `elvin-config --cflags vin4mt`
CFLAGS += `elvin-config --cflags vin4c`
LDFLAGS += -pthread -static -L../lib -L${OBJDIR}/lib/libtb
LDFLAGS += -static -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
LIBS += `elvin-config --libs vin4c`
tbrecv: tbrecv.o
$(CC) $(LDFLAGS) -o $@ tbrecv.o $(LIBS)
......
......@@ -5,7 +5,7 @@ SUBDIR = event/lib
include $(OBJDIR)/Makeconf
all: libevent.a
all: libevent.a libevent_r.a
include $(TESTBED_SRCDIR)/GNUmakerules
......@@ -14,12 +14,21 @@ CFLAGS += -O -g -static -I. -Wall -I$(TESTBED_SRCDIR)/lib/libtb
CFLAGS += `elvin-config --cflags vin4mt`
OBJS = event.o util.o
POBJS = event_r.o util.o
libevent.a: $(OBJS)
$(AR) crv $@ $(OBJS)
$(RANLIB) $@
libevent_r.a: $(POBJS)
$(AR) crv $@ $(POBJS)
$(RANLIB) $@
$(OBJS): event.h
$(POBJS): event.h
event_r.o: event.c
$(CC) $(CFLAGS) -DTHREADED -c -o event_r.o $<
install:
......
......@@ -24,7 +24,6 @@
static char hostname[MAXHOSTNAMELEN];
/*
* Register with the testbed event system. NAME specifies the name of
* the event server. Returns a pointer to a handle that may be passed
......@@ -70,6 +69,7 @@ event_register(char *name, int threaded)
/* Set up the Elvin interface pointers: */
if (threaded) {
#ifdef THREADED
handle->init = elvin_threaded_init_default;
handle->connect = elvin_threaded_connect;
handle->disconnect = elvin_threaded_disconnect;
......@@ -77,6 +77,11 @@ event_register(char *name, int threaded)
handle->mainloop = NULL; /* no mainloop for mt programs */
handle->notify = elvin_threaded_notify;
handle->subscribe = elvin_threaded_add_subscription;
#else
ERROR("Threaded API not linked in with the program!\n");
free(handle);
return 0;
#endif
} else {
handle->init = elvin_sync_init_default;
handle->connect = elvin_sync_connect;
......
......@@ -17,7 +17,7 @@ CFLAGS += `elvin-config --cflags vin4mt`
LDFLAGS += -pthread -static
LDFLAGS += -L../lib -L${OBJDIR}/lib/libtb
LIBS += -levent -ltb -lcipher -L/usr/local/lib/mysql -lmysqlclient -lz
LIBS += -levent_r -ltb -lcipher -L/usr/local/lib/mysql -lmysqlclient -lz
#
# XXX elvin-config adds -lc which is rather bogus, and messes up -pthread
......
......@@ -16,23 +16,13 @@ all: $(PROGRAMS)
include $(TESTBED_SRCDIR)/GNUmakerules
CFLAGS += -DDEBUG
CFLAGS += -O -g -static -Wall -pthread
CFLAGS += -O -g -static -Wall
CFLAGS += -I. -I${OBJDIR} -I$(SRCDIR)/../lib -I$(TESTBED_SRCDIR)/lib/libtb
CFLAGS += `elvin-config --cflags vin4mt`
CFLAGS += `elvin-config --cflags vin4c`
LDFLAGS += -pthread -L../lib -L${OBJDIR}/lib/libtb
LDFLAGS += -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
# 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
LIBS += `elvin-config --libs vin4c`
tevc: tevc.o
$(CC) $(LDFLAGS) -static -o $@ tevc.o $(LIBS)
......
#!/bin/csh
TBDIR=@prefix@
set TBDIR=@prefix@
killall tevd
exec ${TBDIR}/sbin/tevd >>& $TBDIR/log/tevd.log
......
......@@ -31,26 +31,18 @@ all: tg2.0 $(PROGRAMS)
include $(TESTBED_SRCDIR)/GNUmakerules
CFLAGS += -DDEBUG
CFLAGS += -O -g -static -pthread #-Wall
CFLAGS += -O -g -static #-Wall
CFLAGS += -I. -I$(TGSRCDIR) -I${OBJDIR}
CFLAGS += -I$(SRCDIR)/../lib -I$(TESTBED_SRCDIR)/lib/libtb
CFLAGS += `elvin-config --cflags vin4mt`
CFLAGS += `elvin-config --cflags vin4c`
CFLAGS += -DFREEBSD -DUSEEVENTS
YCFLAGS += -I. -DFREEBSD -DUSEEVENTS
LDFLAGS += -pthread -L../lib -L${OBJDIR}/lib/libtb
LDFLAGS += -L../lib -L${OBJDIR}/lib/libtb
LIBS += -levent -ltb
LIBS += -lcipher -lc_r
LIBS += -ll -lcompat
#
# 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
LIBS += `elvin-config --libs vin4c`
lex.yy.c: scan.l
@echo 'Expect non-portable character class warning (ASCII assumed).'
......
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