Makefile 2.52 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
CFLAGS+=-D_POSIX_C_SOURCE=199309 -std=c99 -Wall -Wextra -Werror -pipe -O2
Jordan Sissel's avatar
Jordan Sissel committed
5 6
# msgpack fails to compile without this.
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
Jordan Sissel's avatar
Jordan Sissel committed
10

Jordan Sissel's avatar
Jordan Sissel committed
11
#-lmsgpack
Jordan Sissel's avatar
Jordan Sissel committed
12
#-ljansson
13

Jordan Sissel's avatar
Jordan Sissel committed
14 15
PREFIX?=/opt/lumberjack

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

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

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

rpm deb:
	fpm -s dir -t $@ -n lumberjack -v $(VERSION) --prefix /opt/lumberjack \
		bin/lumberjack build/lib
35

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

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

Jordan Sissel's avatar
Jordan Sissel committed
54
build/bin/lumberjack: | build/bin build/lib/libzmq.$(LIBEXT) build/lib/libmsgpack.$(LIBEXT)
Jordan Sissel's avatar
Jordan Sissel committed
55
build/bin/lumberjack: | build/lib/libjemalloc.$(LIBEXT)
Jordan Sissel's avatar
Jordan Sissel committed
56
build/bin/lumberjack: lumberjack.o backoff.o harvester.o emitter.o str.o proto.o
57
	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
Jordan Sissel's avatar
Jordan Sissel committed
58 59
	@echo " => Build complete: $@"
	@echo " => Run 'make rpm' to build an rpm (or deb or tarball)"
60

61 62 63
build/include/insist.h: | build/include
	curl -s -o $@ https://raw.github.com/jordansissel/experiments/master/c/better-assert/insist.h

64
build/include/zmq.h build/lib/libzmq.$(LIBEXT): | build
65 66
	$(MAKE) -C vendor/zeromq/ install PREFIX=$$PWD/build

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

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

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

76 77 78 79 80 81
build:
	mkdir $@

build/include: | build
	mkdir $@

Jordan Sissel's avatar
Jordan Sissel committed
82 83
build/bin: | build
	mkdir $@