Makefile 1.86 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 
5
LDFLAGS+=-pthread
6
LDFLAGS+=-Lbuild/lib -Wl,-rpath,'$$ORIGIN/../lib'
Jordan Sissel's avatar
Jordan Sissel committed
7
LIBS=-lzmq -ljansson
8

Jordan Sissel's avatar
Jordan Sissel committed
9 10
PREFIX?=/opt/lumberjack

Jordan Sissel's avatar
Jordan Sissel committed
11
default: build/bin/lumberjack
12 13
include Makefile.ext

Jordan Sissel's avatar
Jordan Sissel committed
14
clean:
Jordan Sissel's avatar
Jordan Sissel committed
15 16 17
	-@rm -fr lumberjack unixsock *.o build
	-@make -C vendor/jansson/ clean
	-@make -C vendor/zeromq/ clean
Jordan Sissel's avatar
Jordan Sissel committed
18 19 20 21

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

Jordan Sissel's avatar
Jordan Sissel committed
23 24 25 26
#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
27 28 29
#unixsock.c: build/include/insist.h
backoff.c: backoff.h
harvester.c: harvester.h
30
emitter.c: emitter.h
31
lumberjack.c: build/include/insist.h build/include/zmq.h build/include/jansson.h
32
lumberjack.c: backoff.h harvester.h emitter.h
Jordan Sissel's avatar
Jordan Sissel committed
33

Jordan Sissel's avatar
Jordan Sissel committed
34 35 36 37
build/bin/pushpull: | build/lib/libzmq.$(LIBEXT) build/lib/libjansson.$(LIBEXT) build/bin
build/bin/pushpull: pushpull.o
	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)

Jordan Sissel's avatar
Jordan Sissel committed
38
build/bin/lumberjack: | build/bin build/lib/libzmq.$(LIBEXT) build/lib/libjansson.$(LIBEXT)
39
build/bin/lumberjack: lumberjack.o backoff.o harvester.o emitter.o
40
	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
Jordan Sissel's avatar
Jordan Sissel committed
41 42
	@echo " => Build complete: $@"
	@echo " => Run 'make rpm' to build an rpm (or deb or tarball)"
43

44 45 46 47

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

48
build/include/zmq.h build/lib/libzmq.$(LIBEXT): | build
49 50
	$(MAKE) -C vendor/zeromq/ install PREFIX=$$PWD/build

Jordan Sissel's avatar
Jordan Sissel committed
51 52 53 54 55
#build/include/msgpack.h build/lib/libmsgpack.$(LIBEXT): | build
#	$(MAKE) -C vendor/msgpack/ install PREFIX=$$PWD/build

build/include/jansson.h build/lib/libjansson.$(LIBEXT): | build
	$(MAKE) -C vendor/jansson/ install PREFIX=$$PWD/build
56

57 58 59 60 61 62
build:
	mkdir $@

build/include: | build
	mkdir $@

Jordan Sissel's avatar
Jordan Sissel committed
63 64
build/bin: | build
	mkdir $@