Skip to content

Commit

Permalink
Cleanup makefile (#299)
Browse files Browse the repository at this point in the history
* ignore glide executable

* clean up makefile

properly `clean` results of compilation and packaging
added `distclean` to remove artifacts related to building (glide and vendor)
default target is `all` now instead of `help` to match common Makefile behavior
update README accordingly

* removed obsolete nxmock program
  • Loading branch information
kroepke authored and mpfz0r committed Oct 11, 2018
1 parent d223338 commit 5fc78e3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 60 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ dist/collectors/
.filebeat

/sidecar.yml

# Dependency management
/glide
25 changes: 12 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,26 @@ ifeq ($(strip $(COLLECTOR_VERSION)),)
$(error COLLECTOR_VERSION is not set)
endif

targets = graylog-sidecar sidecar-collector build dist/cache dist/tmp-build dist/tmp-dest dist/pkg dist/collectors
dist_targets = vendor glide

GIT_REV=$(shell git rev-parse --short HEAD)
BUILD_OPTS = -ldflags "-s -X github.com/Graylog2/collector-sidecar/common.GitRevision=$(GIT_REV) -X github.com/Graylog2/collector-sidecar/common.CollectorVersion=$(COLLECTOR_VERSION) -X github.com/Graylog2/collector-sidecar/common.CollectorVersionSuffix=$(COLLECTOR_VERSION_SUFFIX)"
GLIDE_VERSION = v0.13.1

TEST_SUITE = \
github.com/Graylog2/collector-sidecar/common

all: clean misc build

misc: ## Build NXMock for testing sidecar
$(GO) build -o misc/nxmock/nxlog misc/nxmock/main.go
all: deps build

fmt: ## Run gofmt
@GOFMT=$(GOFMT) sh ./format.sh

clean: ## Remove binaries
@rm -rf build
@rm -rf dist/cache
@rm -rf dist/tmp-build
@rm -rf dist/tmp-dest
@rm -rf dist/pkg
@rm -rf dist/collectors
-rm -rf $(targets)

distclean: clean
-rm -rf $(dist_targets)

deps: glide
./glide install
Expand All @@ -54,7 +52,8 @@ test: ## Run tests
build: ## Build sidecar binary for local target system
$(GO) build $(BUILD_OPTS) -v -i -o graylog-sidecar

build-all: build-linux build-linux32 build-darwin build-windows build-windows32
# does not include build-darwin as that only runs with homebrew on a Mac
build-all: build-linux build-linux32 build-windows build-windows32

build-linux: ## Build sidecar binary for Linux
@mkdir -p build/$(COLLECTOR_VERSION)/linux/amd64
Expand Down Expand Up @@ -118,6 +117,6 @@ package-tar: ## Create tar archive for all platforms
help:
@grep -hE '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | $(AWK) 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.DEFAULT_GOAL := help
.DEFAULT_GOAL := all

.PHONY: all build build-all build-linux build-linux32 build-darwin build-windows build-windows32 misc fmt clean help package-linux package-windows
.PHONY: all build build-all build-linux build-linux32 build-darwin build-freebsd build-windows build-windows32 fmt clean distclean help package-all package-linux package-linux32 package-windows package-tar
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,6 @@ There are a couple of configuration settings for the Sidecar:
## Compile

* Clone the repository into your `$GOPATH` under `src/github.com/Graylog2/collector-sidecar`
* Install the [glide package manager](https://glide.sh)
* run `glide install` in the collector-sidecar directory
* (for Go <1.6 `export GO15VENDOREXPERIMENT=1`)
* run `make build`
* run `make` to install the dependencies and build the binary for the local platform
* run `make help` to see more targets

## Development

There is a collector mock program in order to use the sidecar without actually running a collector like NXLog. Simply build it with
`make misc` und use the option `binary_path: misc/nxmock/nxlog`.
39 changes: 0 additions & 39 deletions misc/nxmock/main.go

This file was deleted.

0 comments on commit 5fc78e3

Please sign in to comment.