From 923344d3763fea89ec8ff2fa1e811be513a5acea Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Mon, 6 Sep 2021 13:45:46 +0200 Subject: [PATCH] Add PREFIX make variable to control command output Signed-off-by: Evan Lezar --- Makefile | 5 ++++- docker/Dockerfile.amazonlinux | 4 +--- docker/Dockerfile.centos | 4 +--- docker/Dockerfile.debian | 4 +--- docker/Dockerfile.opensuse-leap | 4 +--- docker/Dockerfile.ubuntu | 4 +--- 6 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 16e86e61..27d414c8 100644 --- a/Makefile +++ b/Makefile @@ -53,9 +53,12 @@ DOCKER_TARGETS := $(patsubst %,docker-%, $(TARGETS)) GOOS ?= linux binaries: cmds +ifneq ($(PREFIX),) +cmd-%: COMMAND_BUILD_OPTIONS = -o $(PREFIX)/$(*) +endif cmds: $(CMD_TARGETS) $(CMD_TARGETS): cmd-%: - GOOS=$(GOOS) go build -ldflags "-s -w" $(MODULE)/cmd/$(*) + GOOS=$(GOOS) go build -ldflags "-s -w" $(COMMAND_BUILD_OPTIONS) $(MODULE)/cmd/$(*) build: GOOS=$(GOOS) go build ./... diff --git a/docker/Dockerfile.amazonlinux b/docker/Dockerfile.amazonlinux index 9ddbbfe5..12a6732f 100644 --- a/docker/Dockerfile.amazonlinux +++ b/docker/Dockerfile.amazonlinux @@ -40,9 +40,7 @@ RUN mkdir -p $DIST_DIR /dist WORKDIR $GOPATH/src/nvidia-container-toolkit COPY . . -RUN make cmds && \ - mv ./nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit && \ - mv ./nvidia-container-runtime $DIST_DIR/nvidia-container-runtime +RUN make PREFIX=${DIST_DIR} cmds COPY config/config.toml.amzn $DIST_DIR/config.toml diff --git a/docker/Dockerfile.centos b/docker/Dockerfile.centos index d800a3c5..94e46e4c 100644 --- a/docker/Dockerfile.centos +++ b/docker/Dockerfile.centos @@ -40,9 +40,7 @@ RUN mkdir -p $DIST_DIR /dist WORKDIR $GOPATH/src/nvidia-container-toolkit COPY . . -RUN make cmds && \ - mv ./nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit && \ - mv ./nvidia-container-runtime $DIST_DIR/nvidia-container-runtime +RUN make PREFIX=${DIST_DIR} cmds COPY config/config.toml.centos $DIST_DIR/config.toml diff --git a/docker/Dockerfile.debian b/docker/Dockerfile.debian index 93acf8aa..bafa1dbb 100644 --- a/docker/Dockerfile.debian +++ b/docker/Dockerfile.debian @@ -48,9 +48,7 @@ RUN mkdir -p $DIST_DIR /dist WORKDIR $GOPATH/src/nvidia-container-toolkit COPY . . -RUN make cmds && \ - mv ./nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit && \ - mv ./nvidia-container-runtime $DIST_DIR/nvidia-container-runtime +RUN make PREFIX=${DIST_DIR} cmds COPY config/config.toml.debian $DIST_DIR/config.toml diff --git a/docker/Dockerfile.opensuse-leap b/docker/Dockerfile.opensuse-leap index 66e047e3..6fbdab15 100644 --- a/docker/Dockerfile.opensuse-leap +++ b/docker/Dockerfile.opensuse-leap @@ -39,9 +39,7 @@ RUN mkdir -p $DIST_DIR /dist WORKDIR $GOPATH/src/nvidia-container-toolkit COPY . . -RUN make cmds && \ - mv ./nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit && \ - mv ./nvidia-container-runtime $DIST_DIR/nvidia-container-runtime +RUN make PREFIX=${DIST_DIR} cmds # Hook for Project Atomic's fork of Docker: https://github.com/projectatomic/docker/tree/docker-1.13.1-rhel#add-dockerhooks-exec-custom-hooks-for-prestartpoststop-containerspatch COPY oci-nvidia-hook $DIST_DIR/oci-nvidia-hook diff --git a/docker/Dockerfile.ubuntu b/docker/Dockerfile.ubuntu index 9bd85b46..7f2571af 100644 --- a/docker/Dockerfile.ubuntu +++ b/docker/Dockerfile.ubuntu @@ -46,9 +46,7 @@ RUN mkdir -p $DIST_DIR /dist WORKDIR $GOPATH/src/nvidia-container-toolkit COPY . . -RUN make cmds && \ - mv ./nvidia-container-toolkit $DIST_DIR/nvidia-container-toolkit && \ - mv ./nvidia-container-runtime $DIST_DIR/nvidia-container-runtime +RUN make PREFIX=${DIST_DIR} cmds COPY config/config.toml.ubuntu $DIST_DIR/config.toml