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) -D_REENTRANT


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 $(prefix)/lib/laptop-netconf
	install -o root -g root -m 0755 laptop-netconf $(prefix)/lib/laptop-netconf/laptop-netconf
	install -o root -g root -m 0755 wrapper $(prefix)/sbin/laptop-netconf
	install -o root -g root -m 0644 opts resolv.conf.home resolv.conf.office resolv.conf.default interfaces.home interfaces.office interfaces.default $(sysconfdir)/laptop-netconf/
	install -o root -g root -m 0755 default home office $(sysconfdir)/laptop-netconf/
