Skip to content

Commit

Permalink
Add static & containerized targets to Makefile.
Browse files Browse the repository at this point in the history
Signed-off-by: Max Goltzsche <max.goltzsche@gmail.com>
  • Loading branch information
mgoltzsche committed Sep 4, 2019
1 parent fac48d0 commit 58ce137
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ else ifeq ($(shell $(PKG_CONFIG) --exists libsystemd && echo "0" || echo "1"), 0
override CFLAGS += $(shell $(PKG_CONFIG) --cflags libsystemd) -D USE_JOURNALD=0
endif

define DOCKERFILE
FROM alpine:latest
RUN apk add --update --no-cache bash make git gcc pkgconf libc-dev glib-dev glib-static
COPY . /go/src/$(PROJECT)
WORKDIR /go/src/$(PROJECT)
RUN make static
endef
export DOCKERFILE

containerized: bin
$(eval PODMAN ?= $(if $(shell podman -v),podman,docker))
echo "$$DOCKERFILE" | $(PODMAN) build --force-rm -t conmon-build -f - .
CTR=`$(PODMAN) create conmon-build` \
&& $(PODMAN) cp $$CTR:/go/src/$(PROJECT)/bin/conmon bin/conmon \
&& $(PODMAN) rm $$CTR

static:
$(MAKE) git-vars bin/conmon PKG_CONFIG='$(PKG_CONFIG) --static' CFLAGS='-static' LDFLAGS='$(LDFLAGS) -s -w -static' LIBS='$(LIBS)'

bin/conmon: src/conmon.o src/cmsg.o src/ctr_logging.o src/utils.o | bin
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)

Expand Down

0 comments on commit 58ce137

Please sign in to comment.