From 52832eb46d6bcfd027caa83efa99fd53cfec3307 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B5ivo=20Leedj=C3=A4rv?= Date: Sat, 13 May 2023 20:32:23 +0200 Subject: [PATCH] Build inotify fsmonitor on BSDs Check for existence of libinotify on some hardcoded paths (in addition to the default include and library paths and any paths added by CFLAGS or LDFLAGS) and if found then build inotify fsmonitor. --- INSTALL.md | 4 ++++ src/Makefile.OCaml | 14 ++++++++++++++ 2 files changed, 18 insertions(+) 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