Makefile 3.09 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'
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
	-@make -C vendor/msgpack/ clean
Jordan Sissel's avatar
Jordan Sissel committed
30
	-@make -C vendor/jansson/ clean
Jordan Sissel's avatar
Jordan Sissel committed
31 32
	-@make -C vendor/jemalloc/ clean
	-@make -C vendor/libuuid/ clean
Jordan Sissel's avatar
Jordan Sissel committed
33
	-@make -C vendor/zeromq/ clean
Jordan Sissel's avatar
Jordan Sissel committed
34 35 36

rpm deb:
	fpm -s dir -t $@ -n lumberjack -v $(VERSION) --prefix /opt/lumberjack \
Jordan Sissel's avatar
Jordan Sissel committed
37
		--exclude '*.a' -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 55
proto.c: build/include/lz4.h

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
82
	PATH=$$PWD:$$PATH $(MAKE) -C vendor/zeromq/ install PREFIX=$$PWD/build
83

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

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

Jordan Sissel's avatar
Jordan Sissel committed
90 91
build/include/lz4.h build/lib/liblz4.$(LIBEXT): | build
	PATH=$$PWD:$$PATH $(MAKE) -C vendor/lz4/ install PREFIX=$$PWD/build
Jordan Sissel's avatar
Jordan Sissel committed
92 93 94 95

build/include/zlib.h build/lib/libz.$(LIBEXT): | build
	PATH=$$PWD:$$PATH $(MAKE) -C vendor/zlib/ install PREFIX=$$PWD/build

96 97 98
build:
	mkdir $@

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