Merge pull request #1388 from kunalkushwaha/makefile
Breaking Makefile into platform specific files.
This commit is contained in:
		
							
								
								
									
										27
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								Makefile
									
									
									
									
									
								
							| @@ -19,21 +19,11 @@ endif | |||||||
| WHALE = "🇩" | WHALE = "🇩" | ||||||
| ONI = "👹" | ONI = "👹" | ||||||
| FIX_PATH = $1 | FIX_PATH = $1 | ||||||
| ifeq ("$(OS)", "Windows_NT") |  | ||||||
| 	WHALE="+" |  | ||||||
| 	ONI="-" |  | ||||||
| 	FIX_PATH = $(subst /,\,$1) |  | ||||||
| endif |  | ||||||
|  |  | ||||||
| RELEASE=containerd-$(VERSION:v%=%).${GOOS}-${GOARCH} | RELEASE=containerd-$(VERSION:v%=%).${GOOS}-${GOARCH} | ||||||
|  |  | ||||||
| PKG=github.com/containerd/containerd | 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. | # Project packages. | ||||||
| PACKAGES=$(shell go list ./... | grep -v /vendor/) | PACKAGES=$(shell go list ./... | grep -v /vendor/) | ||||||
| INTEGRATION_PACKAGE=${PKG} | INTEGRATION_PACKAGE=${PKG} | ||||||
| @@ -49,24 +39,17 @@ TEST_REQUIRES_ROOT_PACKAGES=$(filter \ | |||||||
|  |  | ||||||
| # Project binaries. | # Project binaries. | ||||||
| COMMANDS=ctr containerd containerd-stress | COMMANDS=ctr containerd containerd-stress | ||||||
| ifneq ("$(GOOS)", "windows") |  | ||||||
| 	COMMANDS += containerd-shim |  | ||||||
| endif |  | ||||||
| BINARIES=$(addprefix bin/,$(COMMANDS)) | BINARIES=$(addprefix bin/,$(COMMANDS)) | ||||||
| ifeq ("$(GOOS)", "windows") |  | ||||||
| 	BINARY_SUFFIX=".exe" |  | ||||||
| endif |  | ||||||
|  |  | ||||||
| GO_TAGS=$(if $(BUILDTAGS),-tags "$(BUILDTAGS)",) | 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_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= | TESTFLAGS_RACE= | ||||||
| ifeq ($(filter \ |  | ||||||
|     linux/amd64 freebsd/amd64 darwin/amd64 windows/amd64, \ | #Detect the target os | ||||||
|     $(GOOS)/$(GOARCH)),$(GOOS)/$(GOARCH)) | include Makefile.OS | ||||||
| 	TESTFLAGS_RACE= -race | #include platform specific makefile | ||||||
| endif | include Makefile.$(target_os) | ||||||
|  |  | ||||||
| # Flags passed to `go test` | # Flags passed to `go test` | ||||||
| TESTFLAGS ?= -v $(TESTFLAGS_RACE) | TESTFLAGS ?= -v $(TESTFLAGS_RACE) | ||||||
|   | |||||||
							
								
								
									
										19
									
								
								Makefile.OS
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								Makefile.OS
									
									
									
									
									
										Normal file
									
								
							| @@ -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
									
								
								Makefile.darwin
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								Makefile.darwin
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | |||||||
|  | #darwin specific settings | ||||||
|  | COMMANDS += containerd-shim | ||||||
|  |  | ||||||
|  | # supports go test -race | ||||||
|  | TESTFLAGS_RACE= -race | ||||||
							
								
								
									
										5
									
								
								Makefile.freebsd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								Makefile.freebsd
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | |||||||
|  | #freebsd specific settings | ||||||
|  | COMMANDS += containerd-shim | ||||||
|  |  | ||||||
|  | # supports go test -race | ||||||
|  | TESTFLAGS_RACE= -race | ||||||
							
								
								
									
										5
									
								
								Makefile.linux
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								Makefile.linux
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | |||||||
|  | #linux specific settings | ||||||
|  | COMMANDS += containerd-shim | ||||||
|  |  | ||||||
|  | # supports go test -race | ||||||
|  | TESTFLAGS_RACE= -race | ||||||
							
								
								
									
										6
									
								
								Makefile.solaris
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								Makefile.solaris
									
									
									
									
									
										Normal file
									
								
							| @@ -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
									
								
								Makefile.windows
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								Makefile.windows
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | #Windows specific settings. | ||||||
|  | WHALE = "+" | ||||||
|  | ONI = "-" | ||||||
|  | FIX_PATH = $(subst /,\,$1) | ||||||
|  |  | ||||||
|  | BINARY_SUFFIX=".exe" | ||||||
|  |  | ||||||
|  | # supports go test -race | ||||||
|  | TESTFLAGS_RACE= -race | ||||||
		Reference in New Issue
	
	Block a user
	 Michael Crosby
					Michael Crosby