Makefile 3.03 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

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
		--exclude '*.a' -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
emitter.c: emitter.h ring.h build/include/zmq.h build/include/zlib.h
Jordan Sissel's avatar
Jordan Sissel committed
46
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
.PHONY: test
test: | build/test/test_ring
	build/test/test_ring

Jordan Sissel's avatar
Jordan Sissel committed
57 58 59 60 61 62 63 64
# 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
65

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

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

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

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

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

Jordan Sissel's avatar
Jordan Sissel committed
86 87 88 89 90 91
#build/include/lz4.h build/lib/liblz4.$(LIBEXT): | build
#	PATH=$$PWD:$$PATH $(MAKE) -C vendor/lz4/ install PREFIX=$$PWD/build

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

92 93 94
build:
	mkdir $@

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