github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/mergeCode/runc/Makefile (about)

     1  .PHONY: dbuild man \
     2  	    localtest localunittest localintegration \
     3  	    test unittest integration
     4  
     5  PREFIX := $(DESTDIR)/usr/local
     6  BINDIR := $(PREFIX)/sbin
     7  GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
     8  GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g")
     9  RUNC_IMAGE := runc_dev$(if $(GIT_BRANCH_CLEAN),:$(GIT_BRANCH_CLEAN))
    10  PROJECT := github.com/opencontainers/runc
    11  TEST_DOCKERFILE := script/test_Dockerfile
    12  BUILDTAGS := seccomp
    13  COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true)
    14  COMMIT := $(if $(shell git status --porcelain --untracked-files=no),"${COMMIT_NO}-dirty","${COMMIT_NO}")
    15  RUNC_LINK := $(CURDIR)/Godeps/_workspace/src/github.com/opencontainers/runc
    16  export GOPATH := $(CURDIR)/Godeps/_workspace
    17  
    18  MAN_DIR := $(CURDIR)/man/man8
    19  MAN_PAGES = $(shell ls $(MAN_DIR)/*.8)
    20  MAN_PAGES_BASE = $(notdir $(MAN_PAGES))
    21  MAN_INSTALL_PATH := ${PREFIX}/share/man/man8/
    22  
    23  RELEASE_DIR := $(CURDIR)/release
    24  
    25  VERSION := ${shell cat ./VERSION}
    26  
    27  SHELL := $(shell command -v bash 2>/dev/null)
    28  
    29  all: $(RUNC_LINK)
    30  	go build -i -ldflags "-X main.gitCommit=${COMMIT} -X main.version=${VERSION}" -tags "$(BUILDTAGS)" -o runc .
    31  
    32  static: $(RUNC_LINK)
    33  	CGO_ENABLED=1 go build -i -tags "$(BUILDTAGS) cgo static_build" -ldflags "-w -extldflags -static -X main.gitCommit=${COMMIT} -X main.version=${VERSION}" -o runc .
    34  
    35  release: $(RUNC_LINK)
    36  	@flag_list=(seccomp selinux apparmor static ambient); \
    37  	unset expression; \
    38  	for flag in "$${flag_list[@]}"; do \
    39  		expression+="' '{'',$${flag}}"; \
    40  	done; \
    41  	eval profile_list=("$$expression"); \
    42  	for profile in "$${profile_list[@]}"; do \
    43  		output=${RELEASE_DIR}/runc; \
    44  		for flag in $$profile; do \
    45  			output+=."$$flag"; \
    46  		done; \
    47  		tags="$$profile"; \
    48  		ldflags="-X main.gitCommit=${COMMIT} -X main.version=${VERSION}"; \
    49  		CGO_ENABLED=; \
    50  		[[ "$$profile" =~ static ]] && { \
    51  			tags="$${tags/static/static_build}"; \
    52  			tags+=" cgo"; \
    53  			ldflags+=" -w -extldflags -static"; \
    54  			CGO_ENABLED=1; \
    55  		}; \
    56  		echo "Building target: $$output"; \
    57  		rm -rf "${GOPATH}/pkg"; \
    58  		go build -i -ldflags "$$ldflags" -tags "$$tags" -o "$$output" .; \
    59  	done
    60  
    61  $(RUNC_LINK):
    62  	ln -sfn $(CURDIR) $(RUNC_LINK)
    63  
    64  dbuild: runcimage
    65  	docker run --rm -v $(CURDIR):/go/src/$(PROJECT) --privileged $(RUNC_IMAGE) make
    66  
    67  lint:
    68  	go vet ./...
    69  	go fmt ./...
    70  
    71  man:
    72  	man/md2man-all.sh
    73  
    74  runcimage:
    75  	docker build -t $(RUNC_IMAGE) .
    76  
    77  test:
    78  	make unittest integration
    79  
    80  localtest:
    81  	make localunittest localintegration
    82  
    83  unittest: runcimage
    84  	docker run -e TESTFLAGS -ti --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_IMAGE) make localunittest
    85  
    86  localunittest: all
    87  	go test -timeout 3m -tags "$(BUILDTAGS)" ${TESTFLAGS} -v ./...
    88  
    89  integration: runcimage
    90  	docker run -e TESTFLAGS -t --privileged --rm -v $(CURDIR):/go/src/$(PROJECT) $(RUNC_IMAGE) make localintegration
    91  
    92  localintegration: all
    93  	bats -t tests/integration${TESTFLAGS}
    94  
    95  install:
    96  	install -D -m0755 runc $(BINDIR)/runc
    97  
    98  install-bash:
    99  	install -D -m0644 contrib/completions/bash/runc $(PREFIX)/share/bash-completion/completions/runc
   100  
   101  install-man:
   102  	install -d -m 755 $(MAN_INSTALL_PATH)
   103  	install -m 644 $(MAN_PAGES) $(MAN_INSTALL_PATH)
   104  
   105  uninstall:
   106  	rm -f $(BINDIR)/runc
   107  
   108  uninstall-bash:
   109  	rm -f $(PREFIX)/share/bash-completion/completions/runc
   110  
   111  uninstall-man:
   112  	rm -f $(addprefix $(MAN_INSTALL_PATH),$(MAN_PAGES_BASE))
   113  
   114  clean:
   115  	rm -f runc
   116  	rm -f $(RUNC_LINK)
   117  	rm -rf $(GOPATH)/pkg
   118  	rm -rf $(RELEASE_DIR)
   119  
   120  validate:
   121  	script/validate-gofmt
   122  	go vet ./...
   123  
   124  ci: validate localtest