diff --git a/Makefile b/Makefile index 76bd725..bf4ebc6 100644 --- a/Makefile +++ b/Makefile @@ -113,6 +113,12 @@ ifeq (Darwin,$(shell uname -s)) LDFLAGS:=-framework CoreServices endif +# FreeBSD inotify for file watching. + +ifeq (FreeBSD,$(shell uname -s)) +LIBS+=-linotify +endif + # Bison flags. # --version prints info to stdout if the -W flags are accepted, else stderr. diff --git a/src/filewatcher.cpp b/src/filewatcher.cpp index 140bc8f..7442ee4 100644 --- a/src/filewatcher.cpp +++ b/src/filewatcher.cpp @@ -25,9 +25,12 @@ #include #include -#ifdef __linux__ +#if defined( __linux__) || defined(__FreeBSD__) +#ifdef __linux__ # include +#endif +# include # include # include # include @@ -87,7 +90,7 @@ std::string FileWatcherImpl::WaitFile(unsigned a_timeout_ms) fds[0].fd = m_fd; fds[0].events = POLLIN; - nfds = poll(fds, LENGTH(fds), a_timeout_ms); + nfds = poll(fds, LENGTH(fds), (int) a_timeout_ms); if (nfds < 0) { std::cerr << "poll: " << strerror(errno) << ".\n"; throw std::runtime_error(__func__);