Makefile 2.55 KB
Newer Older
1
VERSION=0.1.0
Jordan Sissel's avatar
Jordan Sissel committed
2

3 4
# By default, all dependencies (zeromq, etc) will be downloaded and installed
# locally. You can change this if you are deploying your own.
5
VENDOR?=zeromq libsodium
6 7 8 9 10

# Where to install to.
PREFIX?=/opt/lumberjack

FETCH=sh fetch.sh
11
MAKE?=make
12 13
CFLAGS+=-Ibuild/include 
LDFLAGS+=-Lbuild/lib -Wl,-rpath,'$$ORIGIN/../lib'
Jordan Sissel's avatar
Jordan Sissel committed
14

15 16
default: build-all
build-all: build/bin/lumberjack build/bin/lumberjack.sh
17 18
include Makefile.ext

Jordan Sissel's avatar
Jordan Sissel committed
19
clean:
Jordan Sissel's avatar
Jordan Sissel committed
20
	-@rm -fr lumberjack unixsock *.o build
21 22 23 24
deps-clean:
	rm -fr src/code.google.com/
	rm -fr src/github.com/ugorji/go-msgpack
	rm -fr src/github.com/alecthomas/gozmq
Jordan Sissel's avatar
Jordan Sissel committed
25 26

vendor-clean:
27 28 29 30 31 32 33 34 35 36
	$(MAKE) -C vendor/apr/ clean
	$(MAKE) -C vendor/jansson/ clean
	$(MAKE) -C vendor/jemalloc/ clean
	$(MAKE) -C vendor/libsodium/ clean
	$(MAKE) -C vendor/libuuid/ clean
	$(MAKE) -C vendor/lz4/ clean
	$(MAKE) -C vendor/msgpack/ clean
	$(MAKE) -C vendor/openssl/ clean
	$(MAKE) -C vendor/zeromq/ clean
	$(MAKE) -C vendor/zlib/ clean
Jordan Sissel's avatar
Jordan Sissel committed
37

38
rpm deb: | build-all
Jordan Sissel's avatar
Jordan Sissel committed
39
	fpm -s dir -t $@ -n lumberjack -v $(VERSION) --prefix /opt/lumberjack \
Jordan Sissel's avatar
Jordan Sissel committed
40 41 42
		--exclude '*.a' --exclude 'lib/pkgconfig/zlib.pc' -C build \
		--description "a log shipping tool" \
		--url "https://github.com/jordansissel/lumberjack" \
43
		bin/lumberjack bin/lumberjack.sh lib
44

Jordan Sissel's avatar
Jordan Sissel committed
45
# Vendor'd dependencies
46 47
# If VENDOR contains 'zeromq' download and build it.
ifeq ($(filter zeromq,$(VENDOR)),zeromq)
48 49 50
bin/lumberjack: | build/bin build/lib/libzmq.$(LIBEXT)
pkg/linux_amd64/github.com/alecthomas/gozmq.a: | build/lib/libzmq.$(LIBEXT)
src/github.com/alecthomas/gozmq/zmq.go: | build/lib/libzmq.$(LIBEXT)
51 52
endif # zeromq

53 54 55
ifeq ($(filter libsodium,$(VENDOR)),libsodium)
bin/keygen: | build/bin build/lib/libsodium.$(LIBEXT)
endif # libsodium
56

57 58
build/bin/lumberjack.sh: lumberjack.sh | build/bin
	install -m 755 $^ $@
Jordan Sissel's avatar
Jordan Sissel committed
59

60 61
build/bin/lumberjack: | build/bin bin/lumberjack
	cp bin/lumberjack build/bin/lumberjack
Jordan Sissel's avatar
Jordan Sissel committed
62

63 64
bin/lumberjack: pkg/linux_amd64/github.com/alecthomas/gozmq.a
	go install -ldflags '-r $$ORIGIN/../lib' lumberjack
Jordan Sissel's avatar
Jordan Sissel committed
65

66 67 68 69
# gozmq
src/github.com/alecthomas/gozmq/zmq.go:
	go get -d github.com/alecthomas/gozmq
	#rm src/github.com/alecthomas/gozmq/zmq_2_*.go
Jordan Sissel's avatar
Jordan Sissel committed
70

71 72 73
pkg/linux_amd64/github.com/alecthomas/gozmq.a: src/github.com/alecthomas/gozmq/zmq.go
	PKG_CONFIG_PATH=$$PWD/build/lib/pkgconfig \
	  go install -tags zmq_3_x github.com/alecthomas/gozmq
74

75 76
bin/keygen:
	go install -ldflags '-r $$ORIGIN/../lib' lumberjack
77

78
build/include/zmq.h build/lib/libzmq.$(LIBEXT): | build
Jordan Sissel's avatar
Jordan Sissel committed
79
	@echo " => Building zeromq"
Jordan Sissel's avatar
Jordan Sissel committed
80
	PATH=$$PWD:$$PATH $(MAKE) -C vendor/zeromq/ install PREFIX=$$PWD/build DEBUG=$(DEBUG)
81

82 83 84
build:
	mkdir $@

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