Makefile 2.18 KB
Newer Older
Jordan Sissel's avatar
Jordan Sissel committed
1 2
VERSION=0.0.1

Jordan Sissel's avatar
Jordan Sissel committed
3 4
CFLAGS+=-Ibuild/include 
CFLAGS+=-D_POSIX_C_SOURCE=199309 -std=c99 -Wall -Wextra -Werror -pipe -g 
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
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 28
	-@make -C vendor/jansson/ clean
	-@make -C vendor/zeromq/ clean
Jordan Sissel's avatar
Jordan Sissel committed
29 30 31 32

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

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

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

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

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

60
build/include/zmq.h build/lib/libzmq.$(LIBEXT): | build
61 62
	$(MAKE) -C vendor/zeromq/ install PREFIX=$$PWD/build

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

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

69 70 71 72 73 74
build:
	mkdir $@

build/include: | build
	mkdir $@

Jordan Sissel's avatar
Jordan Sissel committed
75 76
build/bin: | build
	mkdir $@