opensnitch/Makefile
trvon 60cd4311a8
build: daemon-only fork build + Arch packaging, kernel-matched eBPF
Add a daemon-only build path (no Python GUI) that builds the eBPF objects
against the running kernel's headers, deriving the BPF DataLayout from
clang and finalizing with opt; a structural unprivileged check target; an
install path that never clobbers existing units/config/rules; an Arch
PKGBUILD.in + prepare.sh and a test_install.sh harness. Document the
workflow and the event-loss diagnostics in README.md and ebpf_prog/README.
Gitignore the compiled ebpf_prog/*.o artifacts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-05 16:58:22 -07:00

87 lines
2.2 KiB
Makefile

.PHONY: all native all-with-ui install install-with-ui protocol protocol-go opensnitch_daemon gui daemon-only ebpf install-daemon install-ebpf check-install clean clean-with-ui run test adblocker
# Local Linux defaults: build against the running kernel, not the latest
# lexicographically sorted installed headers. All three remain overridable.
KERNEL_VER ?= $(shell uname -r)
KERNEL_DIR ?= /usr/lib/modules/$(KERNEL_VER)/build
KERNEL_HEADERS ?= $(KERNEL_DIR)
export KERNEL_VER KERNEL_DIR KERNEL_HEADERS
all: native
native: daemon-only ebpf
# The Python desktop UI is an explicit opt-in, not a native build dependency.
all-with-ui: protocol opensnitch_daemon gui ebpf
# Native-only entry points: no Python GUI/protocol/translation commands.
protocol-go:
$(MAKE) -C proto ../daemon/ui/protocol/ui.pb.go
daemon-only: protocol-go
$(MAKE) -C daemon
# These native-header objects depend on kernel/toolchain settings as well as
# local sources. Rebuild on each native build instead of reusing stale objects.
ebpf:
$(MAKE) -B -C ebpf_prog check
install-daemon:
$(MAKE) -C daemon install
install-ebpf:
$(MAKE) -C ebpf_prog install
check-install:
sh utils/packaging/test_install.sh
# Build unprivileged first; installation never reloads/restarts the service.
install: install-daemon install-ebpf
install-with-ui: install
$(MAKE) -C ui install
protocol:
@cd proto && make
opensnitch_daemon:
@cd daemon && make
gui:
@cd ui && make
clean:
$(MAKE) -C daemon clean
$(MAKE) -C ebpf_prog clean
# Also removes generated Python protocol files; use only intentionally.
clean-with-ui: clean
$(MAKE) -C proto clean
$(MAKE) -C ui clean
run:
cd ui && pip3 install --upgrade . && cd ..
opensnitch-ui --socket unix:///tmp/osui.sock &
./daemon/opensnitchd -rules-path /etc/opensnitchd/rules -ui-socket unix:///tmp/osui.sock -cpu-profile cpu.profile -mem-profile mem.profile
test:
clear
make clean
clear
mkdir -p rules
make
clear
make run
adblocker:
clear
make clean
clear
make
clear
python make_ads_rules.py
clear
cd ui && pip3 install --upgrade . && cd ..
opensnitch-ui --socket unix:///tmp/osui.sock &
./daemon/opensnitchd -rules-path /etc/opensnitchd/rules -ui-socket unix:///tmp/osui.sock