X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=Makefile;h=f256c1bd846a84f59bdff3e5cb8f72422edf022c;hb=b90bf44d37438096ca0928e08faa8799a8743023;hp=8c5855592c0a921715684aebfcf0510a787bec0f;hpb=60974e66c57cacdc2483d74718c4bb0a993d2183;p=src%2Fxds%2Fxds-gdb.git diff --git a/Makefile b/Makefile index 8c58555..f256c1b 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ # Makefile used to build xds-gdb commands # Application Version -VERSION := 0.0.1 - +VERSION := 0.1.0 +TARGET=xds-gdb # Retrieve git tag/commit to set sub-version string ifeq ($(origin SUB_VERSION), undefined) @@ -10,7 +10,8 @@ ifeq ($(origin SUB_VERSION), undefined) ifneq ($(SUB_VERSION), ) VERSION := $(firstword $(subst -, ,$(SUB_VERSION))) SUB_VERSION := $(word 2,$(subst -, ,$(SUB_VERSION))) - else + endif + ifeq ($(SUB_VERSION), ) SUB_VERSION := $(shell git rev-parse --short HEAD) ifeq ($(SUB_VERSION), ) SUB_VERSION := unknown-dev @@ -21,6 +22,7 @@ endif HOST_GOOS=$(shell go env GOOS) HOST_GOARCH=$(shell go env GOARCH) ARCH=$(HOST_GOOS)-$(HOST_GOARCH) +REPOPATH=github.com/iotbzh/$(TARGET) EXT= ifeq ($(HOST_GOOS), windows) @@ -42,23 +44,31 @@ VERBOSE_2 := -v -x # Release or Debug mode ifeq ($(filter 1,$(RELEASE) $(REL)),) - GORELEASE= + GO_LDFLAGS= + # disable compiler optimizations and inlining + GO_GCFLAGS=-N -l BUILD_MODE="Debug mode" else # optimized code without debug info - GORELEASE= -s -w + GO_LDFLAGS=-s -w + GO_GCFLAGS= BUILD_MODE="Release mode" endif -REPOPATH=github.com/iotbzh/xds-gdb -TARGET := xds-gdb -build: $(TARGET) +ifeq ($(SUB_VERSION), ) + PACKAGE_ZIPFILE := $(TARGET)_$(ARCH)-v$(VERSION).zip +else + PACKAGE_ZIPFILE := $(TARGET)_$(ARCH)-v$(VERSION)_$(SUB_VERSION).zip +endif -xds-gdb: vendor - @echo "### Build $@ (version $(VERSION), subversion $(SUB_VERSION)) - $(BUILD_MODE)"; - @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(BINDIR)/$@$(EXT) -ldflags "$(GORELEASE) -X main.AppVersion=$(VERSION) -X main.AppSubVersion=$(SUB_VERSION)" . - @([ "$(HOST_GOOS)" = "linux" ] && { cd $(BINDIR) && ln -sf $@ $(subst xds-,,$@); } || { true; } ) +.PHONY: all +all: vendor build + +.PHONY: build +build: + @echo "### Build $(TARGET) (version $(VERSION), subversion $(SUB_VERSION)) - $(BUILD_MODE)"; + @cd $(ROOT_SRCDIR); $(BUILD_ENV_FLAGS) go build $(VERBOSE_$(V)) -i -o $(BINDIR)/$(TARGET)$(EXT) -ldflags "$(GO_LDFLAGS) -X main.AppVersion=$(VERSION) -X main.AppSubVersion=$(SUB_VERSION)" -gcflags "$(GO_GCFLAGS)" . test: tools/glide go test --race $(shell ./tools/glide novendor) @@ -80,20 +90,30 @@ distclean: clean release: RELEASE=1 make -f $(ROOT_SRCDIR)/Makefile clean build -package: clean build - @mkdir -p $(PACKAGE_DIR)/xds-gdb - @cp -a $(BINDIR)/*gdb$(EXT) $(PACKAGE_DIR)/xds-gdb - @cd $(PACKAGE_DIR) && zip --symlinks -r $(ROOT_SRCDIR)/xds-gdb_$(ARCH)-v$(VERSION)_$(SUB_VERSION).zip ./xds-gdb +package: clean vendor build + @mkdir -p $(PACKAGE_DIR)/$(TARGET) + @cp -a $(BINDIR)/*gdb$(EXT) $(PACKAGE_DIR)/$(TARGET) + @cp -r $(ROOT_SRCDIR)/conf.d $(ROOT_SRCDIR)/scripts $(PACKAGE_DIR)/$(TARGET) + cd $(PACKAGE_DIR) && zip -r $(ROOT_SRCDIR)/$(PACKAGE_ZIPFILE) ./$(TARGET) .PHONY: package-all package-all: @echo "# Build linux amd64..." GOOS=linux GOARCH=amd64 RELEASE=1 make -f $(ROOT_SRCDIR)/Makefile package @echo "# Build windows amd64..." -# GOOS=windows GOARCH=amd64 RELEASE=1 make -f $(ROOT_SRCDIR)/Makefile package - @echo " WARNING: build on Windows not supported for now." + GOOS=windows GOARCH=amd64 RELEASE=1 make -f $(ROOT_SRCDIR)/Makefile package @echo "# Build darwin amd64..." GOOS=darwin GOARCH=amd64 RELEASE=1 make -f $(ROOT_SRCDIR)/Makefile package + make -f $(ROOT_SRCDIR)/Makefile clean + +.PHONY: install +install: + @test -e $(LOCAL_BINDIR)/$(TARGET)$(EXT) || { echo "Please execute first: make all\n"; exit 1; } + export DESTDIR=$(DESTDIR) && $(ROOT_SRCDIR)/scripts/install.sh + +.PHONY: uninstall +uninstall: + export DESTDIR=$(DESTDIR) && $(ROOT_SRCDIR)/scripts/install.sh uninstall vendor: tools/glide glide.yaml ./tools/glide install --strip-vendor @@ -110,10 +130,12 @@ tools/glide: help: @echo "Main supported rules:" - @echo " build (default)" + @echo " all (default)" + @echo " build" @echo " release" @echo " clean" @echo " package" + @echo " install / uninstall" @echo " distclean" @echo "" @echo "Influential make variables:"