Makefile 3.71 KB
Newer Older
1
VERSION=0.0.2
Jordan Sissel's avatar
Jordan Sissel committed
2

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'
Jordan Sissel's avatar
Jordan Sissel committed
9
LIBS=-lzmq -ljemalloc -lssl -lcrypto -luuid -lz
Jordan Sissel's avatar
Jordan Sissel committed
10
#-llz4
Jordan Sissel's avatar
Jordan Sissel committed
11

12 13

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

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

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

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

Jordan Sissel's avatar
Jordan Sissel committed
27
clean:
Jordan Sissel's avatar
Jordan Sissel committed
28
	-@rm -fr lumberjack unixsock *.o build
Jordan Sissel's avatar
Jordan Sissel committed
29 30 31 32 33 34 35

vendor-clean:
	-make -C vendor/msgpack/ clean
	-make -C vendor/jansson/ clean
	-make -C vendor/jemalloc/ clean
	-make -C vendor/libuuid/ clean
	-make -C vendor/zeromq/ clean
Jordan Sissel's avatar
Jordan Sissel committed
36

Jordan Sissel's avatar
Jordan Sissel committed
37
rpm deb: | build/bin/lumberjack
Jordan Sissel's avatar
Jordan Sissel committed
38
	fpm -s dir -t $@ -n lumberjack -v $(VERSION) --prefix /opt/lumberjack \
Jordan Sissel's avatar
Jordan Sissel committed
39 40 41 42
		--exclude '*.a' --exclude 'lib/pkgconfig/zlib.pc' -C build \
		--description "a log shipping tool" \
		--url "https://github.com/jordansissel/lumberjack" \
		bin/lumberjack lib
43

Jordan Sissel's avatar
Jordan Sissel committed
44 45 46 47
#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
48 49
#unixsock.c: build/include/insist.h
backoff.c: backoff.h
Jordan Sissel's avatar
Jordan Sissel committed
50
harvester.c: harvester.h proto.h str.h build/include/insist.h build/include/zmq.h
Jordan Sissel's avatar
Jordan Sissel committed
51
emitter.c: emitter.h ring.h build/include/zmq.h 
Jordan Sissel's avatar
Jordan Sissel committed
52
lumberjack.c: build/include/insist.h build/include/zmq.h 
53
lumberjack.c: backoff.h harvester.h emitter.h
Jordan Sissel's avatar
Jordan Sissel committed
54
harvester.c lumberjack.c pushpull.c ring.c str.c: build/include/jemalloc/jemalloc.h
Jordan Sissel's avatar
Jordan Sissel committed
55
str.c: str.h
Jordan Sissel's avatar
Jordan Sissel committed
56
proto.c: proto.h str.h build/include/openssl/ssl.h
Jordan Sissel's avatar
Jordan Sissel committed
57
ring.c: ring.h
Jordan Sissel's avatar
Jordan Sissel committed
58

Jordan Sissel's avatar
Jordan Sissel committed
59
#proto.c: build/include/lz4.h
Jordan Sissel's avatar
Jordan Sissel committed
60

Jordan Sissel's avatar
Jordan Sissel committed
61 62 63 64
.PHONY: test
test: | build/test/test_ring
	build/test/test_ring

Jordan Sissel's avatar
Jordan Sissel committed
65 66 67 68 69 70 71 72
# 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
73

Jordan Sissel's avatar
Jordan Sissel committed
74
build/bin/lumberjack: | build/bin build/lib/libzmq.$(LIBEXT)
Jordan Sissel's avatar
Jordan Sissel committed
75
build/bin/lumberjack: | build/lib/libjemalloc.$(LIBEXT)
Jordan Sissel's avatar
Jordan Sissel committed
76
build/bin/lumberjack: | build/lib/libz.$(LIBEXT)
Jordan Sissel's avatar
Jordan Sissel committed
77 78
build/bin/lumberjack: | build/lib/libssl.$(LIBEXT)
build/bin/lumberjack: | build/lib/libcrypto.$(LIBEXT)
Jordan Sissel's avatar
Jordan Sissel committed
79
#build/bin/lumberjack: | build/lib/liblz4.$(LIBEXT)
Jordan Sissel's avatar
Jordan Sissel committed
80
build/bin/lumberjack: lumberjack.o backoff.o harvester.o emitter.o str.o proto.o ring.o
81
	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
Jordan Sissel's avatar
Jordan Sissel committed
82 83
	@echo " => Build complete: $@"
	@echo " => Run 'make rpm' to build an rpm (or deb or tarball)"
84

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

88
build/include/zmq.h build/lib/libzmq.$(LIBEXT): | build
Jordan Sissel's avatar
Jordan Sissel committed
89
	@echo " => Building zeromq"
90
	PATH=$$PWD:$$PATH $(MAKE) -C vendor/zeromq/ install PREFIX=$$PWD/build
91

Jordan Sissel's avatar
Jordan Sissel committed
92
build/include/msgpack.h build/lib/libmsgpack.$(LIBEXT): | build
Jordan Sissel's avatar
Jordan Sissel committed
93
	@echo " => Building msgpack"
Jordan Sissel's avatar
Jordan Sissel committed
94
	PATH=$$PWD:$$PATH $(MAKE) -C vendor/msgpack/ install PREFIX=$$PWD/build
95

Jordan Sissel's avatar
Jordan Sissel committed
96
build/include/jemalloc/jemalloc.h build/lib/libjemalloc.$(LIBEXT): | build
Jordan Sissel's avatar
Jordan Sissel committed
97
	@echo " => Building jemalloc"
98
	PATH=$$PWD:$$PATH $(MAKE) -C vendor/jemalloc/ install PREFIX=$$PWD/build
Jordan Sissel's avatar
Jordan Sissel committed
99

Jordan Sissel's avatar
Jordan Sissel committed
100
build/include/lz4.h build/lib/liblz4.$(LIBEXT): | build
Jordan Sissel's avatar
Jordan Sissel committed
101
	@echo " => Building lz4"
Jordan Sissel's avatar
Jordan Sissel committed
102
	PATH=$$PWD:$$PATH $(MAKE) -C vendor/lz4/ install PREFIX=$$PWD/build
Jordan Sissel's avatar
Jordan Sissel committed
103 104

build/include/zlib.h build/lib/libz.$(LIBEXT): | build
Jordan Sissel's avatar
Jordan Sissel committed
105
	@echo " => Building lz4"
Jordan Sissel's avatar
Jordan Sissel committed
106 107
	PATH=$$PWD:$$PATH $(MAKE) -C vendor/zlib/ install PREFIX=$$PWD/build

Jordan Sissel's avatar
Jordan Sissel committed
108 109 110 111
build/include/openssl/ssl.h build/lib/libssl.$(LIBEXT) build/lib/libcrypto.$(LIBEXT): | build
	@echo " => Building openssl"
	PATH=$$PWD:$$PATH $(MAKE) -C vendor/openssl install PREFIX=$$PWD/build

112 113 114
build:
	mkdir $@

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