-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
49 lines (38 loc) · 1.21 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
PREFIX ?= /usr
BINDIR ?= $(PREFIX)/bin
LIBEXECDIR ?= $(PREFIX)/libexec
CFLAGS ?= -O2
CFLAGS += -std=c99 -Wall -Wextra -Wno-unused-parameter -fno-strict-aliasing
CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DLIBEXECDIR=\"$(LIBEXECDIR)\"
SRCS := main.c enter.c userns.c mount.c cp.c setarch.c usage.c signal.c
OBJS := $(subst .c,.o,$(SRCS))
BINS := bst bst--userns-helper
ifeq ($(shell id -u),0)
SUDO =
else
SUDO = sudo
endif
ifeq ($(NO_SETCAP),)
SETCAP = $(SUDO) setcap
else
SETCAP = :
endif
all: $(BINS)
generate: usage.txt
(echo "/* Copyright (c) 2020 Arista Networks, Inc. All rights reserved."; \
echo " Arista Networks, Inc. Confidential and Proprietary. */"; \
echo ""; \
echo "/* This file is generated from usage.txt. Do not edit. */"; \
xxd -i usage.txt) > usage.c
bst: $(OBJS)
$(LINK.o) -o $@ $^ -lcap
bst--userns-helper: userns-helper.o
$(LINK.o) -o $@ $^
$(SETCAP) cap_setuid,cap_setgid+ep $@
install: $(BINS)
install -m 755 -D bst $(DESTDIR)$(BINDIR)/bst
install -m 755 -D bst--userns-helper $(DESTDIR)$(LIBEXECDIR)/bst--userns-helper
$(SETCAP) cap_setuid,cap_setgid+ep $(DESTDIR)$(LIBEXECDIR)/bst--userns-helper
clean:
$(RM) $(BINS) $(OBJS) userns-helper.o
.PHONY: all clean install generate