From 9e483fd590595076fb614c023b588f0ffa6fa551 Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Thu, 10 Mar 2016 14:49:27 -0500 Subject: [PATCH 1/3] Makefile: consolidate apps sources deps --- Makefile | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index a44ab2806..e6a9b2ea4 100644 --- a/Makefile +++ b/Makefile @@ -3,39 +3,28 @@ DESTDIR= GOFLAGS= BINDIR=${PREFIX}/bin -NSQD_SRCS = $(wildcard apps/nsqd/*.go nsqd/*.go nsq/*.go internal/*/*.go) -NSQLOOKUPD_SRCS = $(wildcard apps/nsqlookupd/*.go nsqlookupd/*.go nsq/*.go internal/*/*.go) -NSQADMIN_SRCS = $(wildcard apps/nsqadmin/*.go nsqadmin/*.go nsqadmin/templates/*.go internal/*/*.go) -NSQ_PUBSUB_SRCS = $(wildcard apps/nsq_pubsub/*.go nsq/*.go internal/*/*.go) -NSQ_TO_NSQ_SRCS = $(wildcard apps/nsq_to_nsq/*.go nsq/*.go internal/*/*.go) -NSQ_TO_FILE_SRCS = $(wildcard apps/nsq_to_file/*.go nsq/*.go internal/*/*.go) -NSQ_TO_HTTP_SRCS = $(wildcard apps/nsq_to_http/*.go nsq/*.go internal/*/*.go) -NSQ_TAIL_SRCS = $(wildcard apps/nsq_tail/*.go nsq/*.go internal/*/*.go) -NSQ_STAT_SRCS = $(wildcard apps/nsq_stat/*.go internal/*/*.go) -TO_NSQ_SRCS = $(wildcard apps/to_nsq/*.go internal/*/*.go) - -APPS = nsqd nsqlookupd nsqadmin nsq_pubsub nsq_to_nsq nsq_to_file nsq_to_http nsq_tail nsq_stat to_nsq BLDDIR = build +APPS = nsqd nsqlookupd nsqadmin nsq_pubsub nsq_to_nsq nsq_to_file nsq_to_http nsq_tail nsq_stat to_nsq all: $(APPS) +$(BLDDIR)/nsqd: $(wildcard apps/nsqd/*.go nsqd/*.go nsq/*.go internal/*/*.go) +$(BLDDIR)/nsqlookupd: $(wildcard apps/nsqlookupd/*.go nsqlookupd/*.go nsq/*.go internal/*/*.go) +$(BLDDIR)/nsqadmin: $(wildcard apps/nsqadmin/*.go nsqadmin/*.go nsqadmin/templates/*.go internal/*/*.go) +$(BLDDIR)/nsq_pubsub: $(wildcard apps/nsq_pubsub/*.go nsq/*.go internal/*/*.go) +$(BLDDIR)/nsq_to_nsq: $(wildcard apps/nsq_to_nsq/*.go nsq/*.go internal/*/*.go) +$(BLDDIR)/nsq_to_file: $(wildcard apps/nsq_to_file/*.go nsq/*.go internal/*/*.go) +$(BLDDIR)/nsq_to_http: $(wildcard apps/nsq_to_http/*.go nsq/*.go internal/*/*.go) +$(BLDDIR)/nsq_tail: $(wildcard apps/nsq_tail/*.go nsq/*.go internal/*/*.go) +$(BLDDIR)/nsq_stat: $(wildcard apps/nsq_stat/*.go internal/*/*.go) +$(BLDDIR)/to_nsq: $(wildcard apps/to_nsq/*.go internal/*/*.go) + $(BLDDIR)/%: @mkdir -p $(dir $@) go build ${GOFLAGS} -o $@ ./apps/$* $(APPS): %: $(BLDDIR)/% -$(BLDDIR)/nsqd: $(NSQD_SRCS) -$(BLDDIR)/nsqlookupd: $(NSQLOOKUPD_SRCS) -$(BLDDIR)/nsqadmin: $(NSQADMIN_SRCS) -$(BLDDIR)/nsq_pubsub: $(NSQ_PUBSUB_SRCS) -$(BLDDIR)/nsq_to_nsq: $(NSQ_TO_NSQ_SRCS) -$(BLDDIR)/nsq_to_file: $(NSQ_TO_FILE_SRCS) -$(BLDDIR)/nsq_to_http: $(NSQ_TO_HTTP_SRCS) -$(BLDDIR)/nsq_tail: $(NSQ_TAIL_SRCS) -$(BLDDIR)/nsq_stat: $(NSQ_STAT_SRCS) -$(BLDDIR)/to_nsq: $(TO_NSQ_SRCS) - clean: rm -fr $(BLDDIR) From a645da68ca5f4ce8eeda9ab575bbdc65654eea3d Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Thu, 10 Mar 2016 14:51:08 -0500 Subject: [PATCH 2/3] Makefile: install: add .exe if building for windows, consolidate recipe --- Makefile | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index e6a9b2ea4..29e9ba363 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,10 @@ GOFLAGS= BINDIR=${PREFIX}/bin BLDDIR = build +EXT= +ifeq (${GOOS},windows) + EXT=.exe +endif APPS = nsqd nsqlookupd nsqadmin nsq_pubsub nsq_to_nsq nsq_to_file nsq_to_http nsq_tail nsq_stat to_nsq all: $(APPS) @@ -33,13 +37,4 @@ clean: install: $(APPS) install -m 755 -d ${DESTDIR}${BINDIR} - install -m 755 $(BLDDIR)/nsqlookupd ${DESTDIR}${BINDIR}/nsqlookupd - install -m 755 $(BLDDIR)/nsqd ${DESTDIR}${BINDIR}/nsqd - install -m 755 $(BLDDIR)/nsqadmin ${DESTDIR}${BINDIR}/nsqadmin - install -m 755 $(BLDDIR)/nsq_pubsub ${DESTDIR}${BINDIR}/nsq_pubsub - install -m 755 $(BLDDIR)/nsq_to_nsq ${DESTDIR}${BINDIR}/nsq_to_nsq - install -m 755 $(BLDDIR)/nsq_to_file ${DESTDIR}${BINDIR}/nsq_to_file - install -m 755 $(BLDDIR)/nsq_to_http ${DESTDIR}${BINDIR}/nsq_to_http - install -m 755 $(BLDDIR)/nsq_tail ${DESTDIR}${BINDIR}/nsq_tail - install -m 755 $(BLDDIR)/nsq_stat ${DESTDIR}${BINDIR}/nsq_stat - install -m 755 $(BLDDIR)/to_nsq ${DESTDIR}${BINDIR}/to_nsq + for APP in $^ ; do install -m 755 ${BLDDIR}/$$APP ${DESTDIR}${BINDIR}/$$APP${EXT} ; done From e7fb6e99619e1d652a4f8bfbdcf79c05cb3bfca6 Mon Sep 17 00:00:00 2001 From: Pierce Lopez Date: Thu, 10 Mar 2016 16:00:39 -0500 Subject: [PATCH 3/3] dist.sh: build and install in one make command so that install can see what GOOS was used --- dist.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist.sh b/dist.sh index 9d4dec16c..517fee0f4 100755 --- a/dist.sh +++ b/dist.sh @@ -34,8 +34,8 @@ for os in linux darwin freebsd windows; do echo "... building v$version for $os/$arch" BUILD=$(mktemp -d -t nsq) TARGET="nsq-$version.$os-$arch.$goversion" - GOOS=$os GOARCH=$arch CGO_ENABLED=0 make - make DESTDIR=$BUILD PREFIX=/$TARGET install + GOOS=$os GOARCH=$arch CGO_ENABLED=0 \ + make DESTDIR=$BUILD PREFIX=/$TARGET install pushd $BUILD if [ "$os" == "linux" ]; then cp -r $TARGET/bin $DIR/dist/docker/