Makefile 2.1 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 10
LIBS=-lzmq
#-lmsgpack
Jordan Sissel's avatar
Jordan Sissel committed
11
#-ljansson
12

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

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

Jordan Sissel's avatar
Jordan Sissel committed
18
clean:
Jordan Sissel's avatar
Jordan Sissel committed
19
	-@rm -fr lumberjack unixsock *.o build
Jordan Sissel's avatar
Jordan Sissel committed
20
	-@make -C vendor/msgpack/ clean
Jordan Sissel's avatar
Jordan Sissel committed
21 22
	-@make -C vendor/jansson/ clean
	-@make -C vendor/zeromq/ clean
Jordan Sissel's avatar
Jordan Sissel committed
23 24 25 26

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

Jordan Sissel's avatar
Jordan Sissel committed
28 29 30 31
#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
32 33
#unixsock.c: build/include/insist.h
backoff.c: backoff.h
Jordan Sissel's avatar
Jordan Sissel committed
34
harvester.c: harvester.h proto.h str.h build/include/insist.h build/include/zmq.h
Jordan Sissel's avatar
Jordan Sissel committed
35
emitter.c: emitter.h build/include/zmq.h
Jordan Sissel's avatar
Jordan Sissel committed
36
lumberjack.c: build/include/insist.h build/include/zmq.h build/include/msgpack.h
37
lumberjack.c: backoff.h harvester.h emitter.h
Jordan Sissel's avatar
Jordan Sissel committed
38 39
str.c: str.h
proto.c: proto.h str.h
Jordan Sissel's avatar
Jordan Sissel committed
40

Jordan Sissel's avatar
Jordan Sissel committed
41
build/bin/pushpull: | build/lib/libzmq.$(LIBEXT) build/lib/libmsgpack.$(LIBEXT) build/bin
Jordan Sissel's avatar
Jordan Sissel committed
42 43 44
build/bin/pushpull: pushpull.o
	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)

Jordan Sissel's avatar
Jordan Sissel committed
45
build/bin/lumberjack: | build/bin build/lib/libzmq.$(LIBEXT) build/lib/libmsgpack.$(LIBEXT)
Jordan Sissel's avatar
Jordan Sissel committed
46
build/bin/lumberjack: lumberjack.o backoff.o harvester.o emitter.o str.o proto.o
47
	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
Jordan Sissel's avatar
Jordan Sissel committed
48 49
	@echo " => Build complete: $@"
	@echo " => Run 'make rpm' to build an rpm (or deb or tarball)"
50

51 52 53 54

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

55
build/include/zmq.h build/lib/libzmq.$(LIBEXT): | build
56 57
	$(MAKE) -C vendor/zeromq/ install PREFIX=$$PWD/build

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

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

64 65 66 67 68 69
build:
	mkdir $@

build/include: | build
	mkdir $@

Jordan Sissel's avatar
Jordan Sissel committed
70 71
build/bin: | build
	mkdir $@