forked from NVIDIA/nvidia-docker
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
79 lines (63 loc) · 2.59 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
NV_DOCKER ?= docker
prefix ?= /usr/local
exec_prefix ?= $(prefix)
bindir ?= $(exec_prefix)/bin
CR_NAME := NVIDIA CORPORATION
CR_EMAIL := digits@nvidia.com
PKG_NAME := nvidia-docker
PKG_VERS := 1.0.1
PKG_REV := 1
ifneq ($(MAKECMDGOALS),rpm)
PKG_ARCH := amd64
else
PKG_ARCH := x86_64
endif
BIN_DIR := $(CURDIR)/bin
DIST_DIR := $(CURDIR)/dist
BUILD_DIR := $(CURDIR)/build
DOCKER_BIN := $(BIN_DIR)/nvidia-docker
PLUGIN_BIN := $(BIN_DIR)/nvidia-docker-plugin
DOCKER_VERS := $(shell $(NV_DOCKER) version -f '{{.Client.Version}}')
DOCKER_VERS_MAJ := $(shell echo $(DOCKER_VERS) | cut -d. -f1)
DOCKER_VERS_MIN := $(shell echo $(DOCKER_VERS) | cut -d. -f2)
DOCKER_RMI := $(NV_DOCKER) rmi
DOCKER_RUN := $(NV_DOCKER) run --rm --net=host
DOCKER_IMAGES := $(NV_DOCKER) images -q $(PKG_NAME)
DOCKER_BUILD := $(NV_DOCKER) build --build-arg USER_ID="$(shell id -u)" \
--build-arg CR_NAME="$(CR_NAME)" \
--build-arg CR_EMAIL="$(CR_EMAIL)" \
--build-arg PKG_NAME="$(PKG_NAME)" \
--build-arg PKG_VERS="$(PKG_VERS)" \
--build-arg PKG_REV="$(PKG_REV)" \
--build-arg PKG_ARCH="$(PKG_ARCH)"
.PHONY: all build install uninstall clean distclean tarball deb rpm
all: build
build: distclean
@mkdir -p $(BIN_DIR)
@$(DOCKER_BUILD) -t $(PKG_NAME):$@ -f Dockerfile.$@ $(CURDIR)
@$(DOCKER_RUN) -v $(BIN_DIR):/go/bin:Z $(PKG_NAME):$@
install: build
install -D -m 755 -t $(bindir) $(DOCKER_BIN)
install -D -m 755 -t $(bindir) $(PLUGIN_BIN)
uninstall:
$(RM) $(bindir)/$(notdir $(DOCKER_BIN))
$(RM) $(bindir)/$(notdir $(PLUGIN_BIN))
clean:
-@$(DOCKER_IMAGES) | xargs $(DOCKER_RMI) 2> /dev/null
-@$(DOCKER_RMI) golang:1.5 ubuntu:14.04 centos:7 2> /dev/null
distclean:
@rm -rf $(BIN_DIR)
@rm -rf $(DIST_DIR)
tarball: build
@mkdir -p $(DIST_DIR)
tar --transform='s;.*/;$(PKG_NAME)/;' -caf $(DIST_DIR)/$(PKG_NAME)_$(PKG_VERS)_$(PKG_ARCH).tar.xz $(BIN_DIR)/*
@printf "\nFind tarball at $(DIST_DIR)\n\n"
deb: tarball
@$(DOCKER_BUILD) -t $(PKG_NAME):$@ -f Dockerfile.$@ $(CURDIR)
@$(DOCKER_RUN) -ti -v $(DIST_DIR):/dist:Z -v $(BUILD_DIR):/build:Z $(PKG_NAME):$@
@printf "\nFind packages at $(DIST_DIR)\n\n"
rpm: tarball
@$(DOCKER_BUILD) -t $(PKG_NAME):$@ -f Dockerfile.$@ $(CURDIR)
@$(DOCKER_RUN) -ti -v $(DIST_DIR):/dist:Z -v $(BUILD_DIR):/build:Z $(PKG_NAME):$@
@printf "\nFind packages at $(DIST_DIR)\n\n"