Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1388 from kunalkushwaha/makefile
Breaking Makefile into platform specific files.
  • Loading branch information
crosbymichael committed Aug 22, 2017
2 parents 89da512 + 1c98958 commit 0648ec3
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 22 deletions.
27 changes: 5 additions & 22 deletions Makefile
Expand Up @@ -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}
Expand All @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions 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
5 changes: 5 additions & 0 deletions Makefile.darwin
@@ -0,0 +1,5 @@
#darwin specific settings
COMMANDS += containerd-shim

# supports go test -race
TESTFLAGS_RACE= -race
5 changes: 5 additions & 0 deletions Makefile.freebsd
@@ -0,0 +1,5 @@
#freebsd specific settings
COMMANDS += containerd-shim

# supports go test -race
TESTFLAGS_RACE= -race
5 changes: 5 additions & 0 deletions Makefile.linux
@@ -0,0 +1,5 @@
#linux specific settings
COMMANDS += containerd-shim

# supports go test -race
TESTFLAGS_RACE= -race
6 changes: 6 additions & 0 deletions 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
9 changes: 9 additions & 0 deletions 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

0 comments on commit 0648ec3

Please sign in to comment.