diff --git a/Makefile b/Makefile index b6f3b2735..bf7ee965d 100644 --- a/Makefile +++ b/Makefile @@ -19,21 +19,11 @@ endif WHALE = "🇩" ONI = "👹" FIX_PATH = $1 -ifeq ("$(OS)", "Windows_NT") - WHALE="+" - ONI="-" - FIX_PATH = $(subst /,\,$1) -endif RELEASE=containerd-$(VERSION:v%=%).${GOOS}-${GOARCH} PKG=github.com/containerd/containerd -# on SunOS default to gnu utilities for things like grep, sed, etc. -ifeq ($(shell uname -s),SunOS) - export PATH := /usr/gnu/bin:$(PATH) -endif - # Project packages. PACKAGES=$(shell go list ./... | grep -v /vendor/) INTEGRATION_PACKAGE=${PKG} @@ -49,24 +39,17 @@ TEST_REQUIRES_ROOT_PACKAGES=$(filter \ # Project binaries. COMMANDS=ctr containerd containerd-stress -ifneq ("$(GOOS)", "windows") - COMMANDS += containerd-shim -endif BINARIES=$(addprefix bin/,$(COMMANDS)) -ifeq ("$(GOOS)", "windows") - BINARY_SUFFIX=".exe" -endif GO_TAGS=$(if $(BUILDTAGS),-tags "$(BUILDTAGS)",) GO_LDFLAGS=-ldflags "-X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PKG) $(EXTRA_LDFLAGS)" -# go test -race is only supported on the patforms listed below. TESTFLAGS_RACE= -ifeq ($(filter \ - linux/amd64 freebsd/amd64 darwin/amd64 windows/amd64, \ - $(GOOS)/$(GOARCH)),$(GOOS)/$(GOARCH)) - TESTFLAGS_RACE= -race -endif + +#Detect the target os +include Makefile.OS +#include platform specific makefile +include Makefile.$(target_os) # Flags passed to `go test` TESTFLAGS ?= -v $(TESTFLAGS_RACE) diff --git a/Makefile.OS b/Makefile.OS new file mode 100644 index 000000000..09a1e770d --- /dev/null +++ b/Makefile.OS @@ -0,0 +1,19 @@ +#Detect the OS, and return installos value same as GOOS +target_os = +ifeq ($(OS),Windows_NT) + target_os = windows +else + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S),Linux) + target_os = linux + endif + ifeq ($(UNAME_S),Darwin) + target_os = darwin + endif + ifeq ($(UNAME_S),FreeBSD) + target_os = freebsd + endif + ifeq ($(UNAME_S),SunOS) + target_os = solaris + endif +endif diff --git a/Makefile.darwin b/Makefile.darwin new file mode 100644 index 000000000..ab8ac344f --- /dev/null +++ b/Makefile.darwin @@ -0,0 +1,5 @@ +#darwin specific settings +COMMANDS += containerd-shim + +# supports go test -race +TESTFLAGS_RACE= -race diff --git a/Makefile.freebsd b/Makefile.freebsd new file mode 100644 index 000000000..675d6caa5 --- /dev/null +++ b/Makefile.freebsd @@ -0,0 +1,5 @@ +#freebsd specific settings +COMMANDS += containerd-shim + +# supports go test -race +TESTFLAGS_RACE= -race diff --git a/Makefile.linux b/Makefile.linux new file mode 100644 index 000000000..0bf02ec3a --- /dev/null +++ b/Makefile.linux @@ -0,0 +1,5 @@ +#linux specific settings +COMMANDS += containerd-shim + +# supports go test -race +TESTFLAGS_RACE= -race diff --git a/Makefile.solaris b/Makefile.solaris new file mode 100644 index 000000000..bfdfda022 --- /dev/null +++ b/Makefile.solaris @@ -0,0 +1,6 @@ +#solaris specific settings + +# on SunOS default to gnu utilities for things like grep, sed, etc. +export PATH := /usr/gnu/bin:$(PATH) + +COMMANDS += containerd-shim diff --git a/Makefile.windows b/Makefile.windows new file mode 100644 index 000000000..6db1e603d --- /dev/null +++ b/Makefile.windows @@ -0,0 +1,9 @@ +#Windows specific settings. +WHALE = "+" +ONI = "-" +FIX_PATH = $(subst /,\,$1) + +BINARY_SUFFIX=".exe" + +# supports go test -race +TESTFLAGS_RACE= -race