# l2bridge -- the raw L2 bridge ([system_avb-25], [system_avb-28]), built from source.
#   make                 builds l2bridge.new (the tests use it; the installed l2bridge keeps its capability)
#   make install-hint    prints what the owner runs to install it (a rebuilt binary has no capability):
#                          mv l2bridge.new l2bridge && sudo setcap cap_net_raw+ep l2bridge
#   make l2bridge        the first install only (no l2bridge yet): builds l2bridge itself
CFLAGS ?= -O2 -g
CFLAGS += -Wall -Wextra -Werror -std=c11

l2bridge.new: l2bridge.c
	$(CC) $(CFLAGS) -o $@ $<

l2bridge:
	@test ! -e $@ || { echo "l2bridge exists (and may carry cap_net_raw): make builds l2bridge.new"; exit 1; }
	$(CC) $(CFLAGS) -o $@ l2bridge.c

install-hint: l2bridge.new
	@echo "cd $(CURDIR) && mv l2bridge.new l2bridge && sudo setcap cap_net_raw+ep $(CURDIR)/l2bridge"

clean:
	rm -f l2bridge.new

.PHONY: install-hint clean
