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
|
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: (c) Copyright 2024,2025 Andrew Bower <andrew@bower.uk>
# Tunables
VERSION ?= 0.7.2
prefix ?= /usr/local
CFLAGS ?= -g -O2
# For zero dependencies, but no capabilities control, invoke with NO_CAP=1
# The rest
name := xchpst
CFLAGS += -MMD -MP \
-Wall -Wextra -Werror \
-std=c2x \
-D_GNU_SOURCE \
-DPROG_NAME=$(name) \
-DPROG_VERSION=$(VERSION) \
-DINST_PREFIX=$(prefix)
ifndef NO_CAP
LDLIBS = -lcap
else
CFLAGS += -DNO_CAP
endif
INSTALL = install
LN = ln -sf
DEP = $(wildcard *.d)
OBJS = xchpst.o options.o usrgrp.o env.o join.o rootfs.o mount.o \
precreate.o
ifndef NO_CAP
OBJS += caps.o
endif
bindir = $(DESTDIR)$(prefix)/bin
ALT_EXES = chpst softlimit envdir pgrphack setuidgid envuidgid setlock \
applyuidgid \
setuidgid-fromenv
.PHONY: all clean install
all: $(name) $(ALT_EXES)
-include $(DEP)
$(name): $(OBJS)
$(ALT_EXES) $(addprefix $(bindir)/,$(ALT_EXES)): $(name)
$(LN) $< $@
clean:
$(RM) $(name) $(OBJS) $(DEP) $(ALT_EXES) chpst.o
install:
$(INSTALL) -m 755 -D -t $(bindir) $(name)
$(INSTALL) -m 644 -D -t $(DESTDIR)$(prefix)/share/man/man8 $(name).8
install-extra: install $(addprefix $(bindir)/,$(ALT_EXES))
|