diff --git a/INSTALL.md b/INSTALL.md index 7a8a3bd91..5cae9c1d4 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -34,6 +34,10 @@ Please refer to instructions provided by the repository. - lablgtk3 and its prerequisites (ocamlfind, GTK 3 and its dependencies) +##### Optional, on BSDs + +- libinotify (optional, for building unison-fsmonitor) + ##### Optional, for building the user manual - LaTeX diff --git a/src/Makefile.OCaml b/src/Makefile.OCaml index a0e12b2c8..1662c9ab5 100644 --- a/src/Makefile.OCaml +++ b/src/Makefile.OCaml @@ -324,6 +324,20 @@ ifeq ($(OSARCH),Linux) FSMDIR = fsmonitor/inotify endif +ifneq ($(findstring $(OSARCH),FreeBSD OpenBSD NetBSD DragonFly),) + LIBINOTIFY_LIB:=-cclib '$(shell pkg-config --libs libinotify 2> /dev/null || printf ' -linotify')' + LIBINOTIFY_INC:=-ccopt '$(shell pkg-config --cflags libinotify 2> /dev/null)' + FOUND_LIBINOTIFY := $(shell { printf '' > inotifytest__.ml ;\ + $(CAMLC) $(CAMLCFLAGS) $(CAMLLDFLAGS) $(LIBINOTIFY_LIB) \ + -o inotifytest__ inotifytest__.ml > /dev/null 2>&1 && printf true ; } ;\ + rm -f inotifytest__.ml inotifytest__.cm[oix] inotifytest__.o inotifytest__ > /dev/null 2>&1) + ifeq ($(FOUND_LIBINOTIFY), true) + FSMDIR = fsmonitor/inotify + $(NAME_FSM)$(EXEC_EXT): CAMLCFLAGS += $(LIBINOTIFY_INC) + $(NAME_FSM)$(EXEC_EXT): CLIBS += $(LIBINOTIFY_LIB) + endif +endif + ifeq ($(OSARCH),SunOS) FSMDIR = fsmonitor/solaris endif