Commit 157334fb authored by Jordan Sissel's avatar Jordan Sissel

- Add zeromq vendoring/build from my experiments/deps project

parent db989c23
CFLAGS+=-Ibuild/include CFLAGS+=-Ibuild/include
#LDFLAGS+=-pthread #LDFLAGS+=-pthread
LDFLAGS=-Lbuild/lib -lzmq -rpath $$ORIGIN/build/lib
default: lumberjack default: lumberjack
include Makefile.ext
unixsock.c: build/include/insist.h unixsock.c: build/include/insist.h
lumberjack.c: build/include/insist.h backoff.h lumberjack.c: build/include/insist.h backoff.h build/include/zeromq.h
lumberjack: lumberjack.o backoff.o lumberjack: lumberjack.o backoff.o build/lib/libzmq.$(LIBEXT)
build/include/insist.h: | build/include build/include/insist.h: | build/include
curl -s -o $@ https://raw.github.com/jordansissel/experiments/master/c/better-assert/insist.h curl -s -o $@ https://raw.github.com/jordansissel/experiments/master/c/better-assert/insist.h
build/include/zeromq.h build/lib/libzmq.$(LIBEXT): | build
$(MAKE) -C vendor/zeromq/ PREFIX=$$PWD/build
build: build:
mkdir $@ mkdir $@
build/include: | build build/include: | build
mkdir $@ mkdir $@
clean:
-rm -fr lumberjack unixsock *.o build
default: fetch
UNAME?=$(shell uname)
ifeq ($(UNAME),Darwin)
LIBEXT=dylib
else
LIBEXT=so
endif
all:
make -C $(WORKDIR) $@
clean:
-rm -r $(WORKDIR)
distclean:
-rm -r $(TARBALL)
fetch: $(TARBALL)
$(TARBALL):
curl -s -o $@ "$(URL)"
@#wget -nv -O $@ $(URL)
$(PREFIX)/lib $(PREFIX)/include:
mkdir $@
workdir: $(WORKDIR)
$(WORKDIR): $(TARBALL)
tar $(TARFLAGS) -xf $<
configure-autoconf: $(WORKDIR)/Makefile
$(WORKDIR)/Makefile: | $(WORKDIR)
cd $(WORKDIR); ./configure --prefix=$(PREFIX)
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <insist.h> #include <insist.h>
#include <pthread.h> #include <pthread.h>
#include <unistd.h> /* for gethostname */
#include <string.h> /* for strerror(3) */ #include <string.h> /* for strerror(3) */
#include <errno.h> /* for errno */ #include <errno.h> /* for errno */
...@@ -21,6 +22,8 @@ static struct option options[] = { ...@@ -21,6 +22,8 @@ static struct option options[] = {
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
static char hostname[200];
void *harvest(void *arg) { void *harvest(void *arg) {
const char *path = (const char *)arg; const char *path = (const char *)arg;
int fd; int fd;
...@@ -44,6 +47,14 @@ void *harvest(void *arg) { ...@@ -44,6 +47,14 @@ void *harvest(void *arg) {
} else { } else {
backoff_clear(&sleeper); backoff_clear(&sleeper);
printf("got: %.*s\n", (int)bytes, buf); printf("got: %.*s\n", (int)bytes, buf);
/* Find newlines, emit an event */
/* Event contents:
* - hostname
* - file
* - message
*/
/* keep remainder in the buffer */
} }
} }
close(fd); close(fd);
...@@ -51,7 +62,6 @@ void *harvest(void *arg) { ...@@ -51,7 +62,6 @@ void *harvest(void *arg) {
return NULL; return NULL;
} /* harvest */ } /* harvest */
int main(int argc, char **argv) { int main(int argc, char **argv) {
int c, i; int c, i;
while (c = getopt_long_only(argc, argv, "+hv", options, &i), c != -1) { while (c = getopt_long_only(argc, argv, "+hv", options, &i), c != -1) {
...@@ -63,6 +73,8 @@ int main(int argc, char **argv) { ...@@ -63,6 +73,8 @@ int main(int argc, char **argv) {
insist(argc > 0, "No arguments given. What log files do you want shipped?"); insist(argc > 0, "No arguments given. What log files do you want shipped?");
gethostname(hostname, sizeof(hostname));
pthread_t *harvesters = calloc(argc, sizeof(pthread_t)); pthread_t *harvesters = calloc(argc, sizeof(pthread_t));
/* Start harvesters for each path given */ /* Start harvesters for each path given */
......
../Makefile.ext
\ No newline at end of file
VERSION=2.2.0
URL=http://download.zeromq.org/zeromq-$(VERSION).tar.gz
TARBALL=$(shell basename $(URL))
WORKDIR=zeromq-$(VERSION)
default: install
include ../Makefile.ext
CFLAGS=-I$(PREFIX)/include
LDFLAGS=-L$(PREFIX)/lib
CXXFLAGS=-I$(PREFIX)/include
#configure: dependencies
#dependencies: $(PREFIX)/lib/libuuid.so
#dependencies: $(PREFIX)/include/uuid/uuid.h
configure: | $(WORKDIR)/Makefile
$(WORKDIR)/Makefile: | $(WORKDIR)
cd $(WORKDIR); CFLAGS=$(CFLAGS) CXXFLAGS=$(CXXFLAGS) LDFLAGS=$(LDFLAGS) ./configure --prefix=$(PREFIX)
compile: | $(WORKDIR)/src/.libs/libzmq.$(LIBEXT)
$(WORKDIR)/src/.libs/libzmq.$(LIBEXT): | configure
$(MAKE) -C $(WORKDIR) CFLAGS=$(CFLAGS) CXXFLAGS=$(CXXFLAGS) LDFLAGS=$(LDFLAGS)
install: | compile $(PREFIX)/lib $(PREFIX)/include
ifeq ($(UNAME),Darwin)
cp $(WORKDIR)/src/.libs/libzmq.1.$(LIBEXT) $(PREFIX)/lib
ln -sf $(PREFIX)/lib/libzmq.1.$(LIBEXT) $(PREFIX)/lib/libzmq.$(LIBEXT)
else
cp $(WORKDIR)/src/.libs/libzmq.$(LIBEXT).1 $(PREFIX)/lib
ln -sf $(PREFIX)/lib/libzmq.$(LIBEXT).1 $(PREFIX)/lib/libzmq.$(LIBEXT)
endif
cp $(WORKDIR)/include/zmq.h $(PREFIX)/include
cp $(WORKDIR)/include/zmq_utils.h $(PREFIX)/include
$(PREFIX)/lib/libuuid.$(LIBEXT) $(PREFIX)/include/uuid/uuid.h:
$(MAKE) -C ../libuuid PREFIX=$(PREFIX) $@
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