-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMakefile
More file actions
69 lines (61 loc) · 2.48 KB
/
Makefile
File metadata and controls
69 lines (61 loc) · 2.48 KB
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
.PHONY: extract-kernel-name build-driver build-image build
WORKSPACE_DIR ?= $(shell pwd)
KERNEL_FLAVOR ?= cloud
TARGET_ARCH ?= amd64
DOCKER_CONTEXT ?= $(shell pwd)
IMAGE_PATH ?= ghcr.io/gardenlinux/gardenlinux-nvidia-installer/driver
DRIVER_MAJOR_VERS = $(firstword $(subst ., ,$(DRIVER_VERSION)))
build: build-driver build-image
ifndef GL_VERSION
$(error GL_VERSION is not set. Please set it before running make.)
endif
ifndef DRIVER_VERSION
$(error DRIVER_VERSION is not set. Please set it before running make.)
endif
ifndef KERNEL_TYPE
$(error KERNEL_TYPE is not set. Please set it to open or proprietary before running make.)
endif
extract-kernel-name:
$(eval KERNEL_NAME := $(shell docker run --rm \
-v "$(PWD):/workspace" \
-w /workspace \
ghcr.io/gardenlinux/gardenlinux/kmodbuild:$(TARGET_ARCH)-$(GL_VERSION) \
./resources/extract_kernel_name.sh "$(KERNEL_FLAVOR)"))
build-driver: extract-kernel-name
mkdir -p $(WORKSPACE_DIR)/out ;\
if [ ! -f $(WORKSPACE_DIR)/out/nvidia/driver-$(DRIVER_VERSION)-$(KERNEL_NAME).tar.gz ]; then \
docker run --rm \
-v $(WORKSPACE_DIR):/workspace \
-v $(WORKSPACE_DIR)/out:/out \
--platform=linux/${TARGET_ARCH} \
-w /workspace \
--env TARGET_ARCH=$(TARGET_ARCH) \
--env GL_VERSION=$(GL_VERSION) \
--env DRIVER_VERSION=$(DRIVER_VERSION) \
--env KERNEL_NAME=$(KERNEL_NAME) \
--env KERNEL_TYPE=$(KERNEL_TYPE) \
ghcr.io/gardenlinux/gardenlinux/kmodbuild:${TARGET_ARCH}-${GL_VERSION} \
bash ./resources/compile.sh ;\
fi
build-image: extract-kernel-name
$(eval TAG1 := "$(DRIVER_MAJOR_VERS)-$(KERNEL_NAME)-gardenlinux$(GL_VERSION)")
$(eval TAG2 := "$(DRIVER_MAJOR_VERS)-$(KERNEL_NAME)-gardenlinux0")
$(eval TAG3 := "$(DRIVER_VERSION)-$(KERNEL_NAME)-gardenlinux0")
@DOCKER_BUILDKIT=1 docker build \
--build-arg GL_VERSION=$(GL_VERSION) \
--build-arg DRIVER_VERSION=$(DRIVER_VERSION) \
--build-arg TARGET_ARCH=$(TARGET_ARCH) \
--build-arg KERNEL_NAME=$(KERNEL_NAME) \
--build-arg KERNEL_TYPE=$(KERNEL_TYPE) \
--platform=linux/${TARGET_ARCH} \
-t $(IMAGE_PATH):$(TAG1) \
-t $(IMAGE_PATH):$(TAG2) \
-t $(IMAGE_PATH):$(TAG3) \
-f Dockerfile $(DOCKER_CONTEXT) > /dev/null
@echo $(TAG1)
@echo $(TAG2)
@echo $(TAG3)
clean:
rm -rf $(WORKSPACE_DIR)/out/nvidia/driver-$(DRIVER_VERSION)-$(KERNEL_TYPE)-$(KERNEL_NAME).tar.gz
clean-all:
rm -rf $(WORKSPACE_DIR)/out/