ifdef FINAL
CFLAGS := -O3
else
CFLAGS := -g
endif

DEFINES := $(shell libnet-config --defines)
LIBS := $(shell libnet-config --libs) -lpcap -lpthread
CFLAGS := $(shell libnet-config --cflags) $(CFLAGS)


prefix := /usr
sysconfdir := /etc


all: laptop-netconf

laptop-netconf: laptop-netconf.c
	gcc  $(DEFINES) $(CFLAGS) laptop-netconf.c $(LIBS) -o laptop-netconf
ifdef FINAL
	strip --remove-section=.notes --remove-section=.comments laptop-netconf
endif

clean:
	rm -f laptop-netconf

install: laptop-netconf
	install -d -o root -g root -m 0755 $(prefix)/sbin $(sysconfdir)/laptop-netconf
	install -o root -g root -m 0755 laptop-netconf $(prefix)/sbin/laptop-netconf
	install -o root -g root -m 0644 opts $(sysconfdir)/laptop-netconf/opts
	install -o root -g root -m 0755 default home office $(sysconfdir)/laptop-netconf/
