Makefile 3.29 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
29 30 31 32 33
	-@#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
34

Jordan Sissel's avatar
Jordan Sissel committed
35
rpm deb: | build/bin/lumberjack
Jordan Sissel's avatar
Jordan Sissel committed
36
	fpm -s dir -t $@ -n lumberjack -v $(VERSION) --prefix /opt/lumberjack \
Jordan Sissel's avatar
Jordan Sissel committed
37
		--exclude '*.a' --exclude 'lib/pkgconfig/zlib.pc' -C build bin/lumberjack lib
38

Jordan Sissel's avatar
Jordan Sissel committed
39 40 41 42
#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
43 44
#unixsock.c: build/include/insist.h
backoff.c: backoff.h
Jordan Sissel's avatar
Jordan Sissel committed
45
harvester.c: harvester.h proto.h str.h build/include/insist.h build/include/zmq.h
Jordan Sissel's avatar
Jordan Sissel committed
46
emitter.c: emitter.h ring.h build/include/zmq.h 
Jordan Sissel's avatar
Jordan Sissel committed
47
lumberjack.c: build/include/insist.h build/include/zmq.h 
48
lumberjack.c: backoff.h harvester.h emitter.h
Jordan Sissel's avatar
Jordan Sissel committed
49
harvester.c lumberjack.c pushpull.c ring.c str.c: build/include/jemalloc/jemalloc.h
Jordan Sissel's avatar
Jordan Sissel committed
50 51
str.c: str.h
proto.c: proto.h str.h
Jordan Sissel's avatar
Jordan Sissel committed
52
ring.c: ring.h
Jordan Sissel's avatar
Jordan Sissel committed
53

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

Jordan Sissel's avatar
Jordan Sissel committed
56 57 58 59
.PHONY: test
test: | build/test/test_ring
	build/test/test_ring

Jordan Sissel's avatar
Jordan Sissel committed
60 61 62 63 64 65 66 67
# 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
68

Jordan Sissel's avatar
Jordan Sissel committed
69
build/bin/lumberjack: | build/bin build/lib/libzmq.$(LIBEXT)
Jordan Sissel's avatar
Jordan Sissel committed
70
build/bin/lumberjack: | build/lib/libjemalloc.$(LIBEXT)
Jordan Sissel's avatar
Jordan Sissel committed
71
build/bin/lumberjack: | build/lib/libz.$(LIBEXT)
Jordan Sissel's avatar
Jordan Sissel committed
72
#build/bin/lumberjack: | build/lib/liblz4.$(LIBEXT)
Jordan Sissel's avatar
Jordan Sissel committed
73
build/bin/lumberjack: lumberjack.o backoff.o harvester.o emitter.o str.o proto.o ring.o
74
	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
Jordan Sissel's avatar
Jordan Sissel committed
75 76
	@echo " => Build complete: $@"
	@echo " => Run 'make rpm' to build an rpm (or deb or tarball)"
77

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

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

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

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

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

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

101 102 103
build:
	mkdir $@

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