PWD = $(shell pwd)

INOTIFY_TOOLS_DIR = inotify-tools-3.20.1

PKG_BUILD_DIR = $(PWD)/$(INOTIFY_TOOLS_DIR)

.PHONY: all clean romfs

all:
	if [ ! -d $(INOTIFY_TOOLS_DIR) ]; then \
		tar xvf $(INOTIFY_TOOLS_DIR).tar.gz ;\
	fi
	cd $(INOTIFY_TOOLS_DIR) ; \
	./autogen.sh && ./configure --host=$(CROSS_HOST) --target=$(CROSS_TARGET) --prefix=$(TMPFSDIR); \
	$(MAKE)

clean:
	rm -rf $(INOTIFY_TOOLS_DIR)

romfs:
	mkdir -p $(ROMFSDIR)/bin
	$(ROMFSINST) $(PKG_BUILD_DIR)/src/.libs/inotifywait /bin/inotifywait
	$(ROMFSINST) $(PKG_BUILD_DIR)/src/.libs/inotifywatch /bin/inotifywatch
	mkdir -p $(ROMFSDIR)/lib
	cp -fpR $(PKG_BUILD_DIR)/libinotifytools/src/.libs/lib*.so* $(ROMFSDIR)/lib