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
Jordan Sissel's avatar
Jordan Sissel committed
21

22 23 24 25
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
26 27

vendor-clean:
28 29 30 31 32 33 34 35 36 37
	$(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
38

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

Jordan Sissel's avatar
Jordan Sissel committed
46
# Vendor'd dependencies
47 48
# If VENDOR contains 'zeromq' download and build it.
ifeq ($(filter zeromq,$(VENDOR)),zeromq)
49 50 51
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)
52 53
endif # zeromq

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

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

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

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

67 68 69 70
# 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
71

72 73 74
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
75

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

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

83 84 85
build:
	mkdir $@

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