Makefile 2.74 KB
Newer Older
Jordan Sissel's avatar
Jordan Sissel committed
1 2
VERSION=0.0.1

Jordan Sissel's avatar
Jordan Sissel committed
3
CFLAGS+=-Ibuild/include 
Jordan Sissel's avatar
Jordan Sissel committed
4 5
CFLAGS+=-D_POSIX_C_SOURCE=199309 -std=c99 -Wall -Wextra -Werror -pipe
CFLAGS+=-g
Jordan Sissel's avatar
Jordan Sissel committed
6
CFLAGS+=-Wno-unused-function
7
LDFLAGS+=-pthread
8
LDFLAGS+=-Lbuild/lib -Wl,-rpath,'$$ORIGIN/../lib'
Philip Reynolds's avatar
Philip Reynolds committed
9
LIBS=-lzmq -ljemalloc -lssl -lcrypto -luuid
Jordan Sissel's avatar
Jordan Sissel committed
10

11 12

FETCH=sh fetch.sh
Jordan Sissel's avatar
Jordan Sissel committed
13
#-lmsgpack
Jordan Sissel's avatar
Jordan Sissel committed
14
#-ljansson
15

Jordan Sissel's avatar
Jordan Sissel committed
16 17
PREFIX?=/opt/lumberjack

Jordan Sissel's avatar
Jordan Sissel committed
18
default: build/bin/lumberjack
19 20
include Makefile.ext

Jordan Sissel's avatar
Jordan Sissel committed
21 22 23 24 25
ifeq ($(UNAME),Linux)
# clock_gettime is in librt on linux.
LIBS+=-lrt
endif

Jordan Sissel's avatar
Jordan Sissel committed
26
clean:
Jordan Sissel's avatar
Jordan Sissel committed
27
	-@rm -fr lumberjack unixsock *.o build
Jordan Sissel's avatar
Jordan Sissel committed
28
	-@make -C vendor/msgpack/ clean
Jordan Sissel's avatar
Jordan Sissel committed
29
	-@make -C vendor/jansson/ clean
Jordan Sissel's avatar
Jordan Sissel committed
30 31
	-@make -C vendor/jemalloc/ clean
	-@make -C vendor/libuuid/ clean
Jordan Sissel's avatar
Jordan Sissel committed
32
	-@make -C vendor/zeromq/ clean
Jordan Sissel's avatar
Jordan Sissel committed
33 34 35

rpm deb:
	fpm -s dir -t $@ -n lumberjack -v $(VERSION) --prefix /opt/lumberjack \
Jordan Sissel's avatar
Jordan Sissel committed
36
		-C build bin/lumberjack lib
37

Jordan Sissel's avatar
Jordan Sissel committed
38 39 40 41
#install: build/bin/lumberjack build/lib/libzmq.$(LIBEXT)
# install -d -m 755 build/bin/* $(PREFIX)/bin/lumberjack
# install -d build/lib/* $(PREFIX)/lib

Jordan Sissel's avatar
Jordan Sissel committed
42 43
#unixsock.c: build/include/insist.h
backoff.c: backoff.h
Jordan Sissel's avatar
Jordan Sissel committed
44
harvester.c: harvester.h proto.h str.h build/include/insist.h build/include/zmq.h
Jordan Sissel's avatar
Jordan Sissel committed
45 46
emitter.c: emitter.h ring.h build/include/zmq.h
lumberjack.c: build/include/insist.h build/include/zmq.h 
47
lumberjack.c: backoff.h harvester.h emitter.h
Jordan Sissel's avatar
Jordan Sissel committed
48
harvester.c lumberjack.c pushpull.c ring.c str.c: build/include/jemalloc/jemalloc.h
Jordan Sissel's avatar
Jordan Sissel committed
49 50
str.c: str.h
proto.c: proto.h str.h
Jordan Sissel's avatar
Jordan Sissel committed
51
ring.c: ring.h
Jordan Sissel's avatar
Jordan Sissel committed
52

Jordan Sissel's avatar
Jordan Sissel committed
53 54 55 56 57 58 59 60
# Tests
test_ring.c: ring.h build/include/jemalloc/jemalloc.h build/include/insist.h
build/test/test_ring: test_ring.o ring.o  | build/test
	$(CC) $(LDFLAGS) -o $@ $^ -ljemalloc

#build/bin/pushpull: | build/lib/libzmq.$(LIBEXT) build/lib/libmsgpack.$(LIBEXT) build/bin
#build/bin/pushpull: pushpull.o
#	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
Jordan Sissel's avatar
Jordan Sissel committed
61

Jordan Sissel's avatar
Jordan Sissel committed
62
build/bin/lumberjack: | build/bin build/lib/libzmq.$(LIBEXT)
Jordan Sissel's avatar
Jordan Sissel committed
63
build/bin/lumberjack: | build/lib/libjemalloc.$(LIBEXT)
Jordan Sissel's avatar
Jordan Sissel committed
64
build/bin/lumberjack: lumberjack.o backoff.o harvester.o emitter.o str.o proto.o ring.o
65
	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
Jordan Sissel's avatar
Jordan Sissel committed
66 67
	@echo " => Build complete: $@"
	@echo " => Run 'make rpm' to build an rpm (or deb or tarball)"
68

69
build/include/insist.h: | build/include
70
	PATH=$$PWD:$$PATH fetch.sh -o $@ https://raw.github.com/jordansissel/experiments/master/c/better-assert/insist.h
71

72
build/include/zmq.h build/lib/libzmq.$(LIBEXT): | build
73
	PATH=$$PWD:$$PATH $(MAKE) -C vendor/zeromq/ install PREFIX=$$PWD/build
74

Jordan Sissel's avatar
Jordan Sissel committed
75 76 77
#build/include/msgpack.h build/lib/libmsgpack.$(LIBEXT): | build
#	$(MAKE) -C vendor/msgpack/ install PREFIX=$$PWD/build

Jordan Sissel's avatar
Jordan Sissel committed
78
build/include/msgpack.h build/lib/libmsgpack.$(LIBEXT): | build
79
	PATH=$$PWD:$$PATH $(MAKE) -C vendor/msgpack/ install PREFIX=$$PWD/build
80

Jordan Sissel's avatar
Jordan Sissel committed
81
build/include/jemalloc/jemalloc.h build/lib/libjemalloc.$(LIBEXT): | build
82
	PATH=$$PWD:$$PATH $(MAKE) -C vendor/jemalloc/ install PREFIX=$$PWD/build
Jordan Sissel's avatar
Jordan Sissel committed
83

84 85 86
build:
	mkdir $@

Jordan Sissel's avatar
Jordan Sissel committed
87
build/include build/bin build/test: | build
Jordan Sissel's avatar
Jordan Sissel committed
88
	mkdir $@