From e553463dc4d239dff7cb982f8181f4733c1a1c1c Mon Sep 17 00:00:00 2001 From: Hristo Iliev Date: Thu, 27 May 2021 21:49:51 +0300 Subject: [PATCH] Patches to build on macOS --- Makefile | 11 ++++++++++- README.md | 13 +++++++++++++ src/fuse_local.c | 4 ++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0053ba4..133b917 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,19 @@ CFLAGS += -O2 -Wall -Wextra -Wshadow -rdynamic -D_GNU_SOURCE\ -D_FILE_OFFSET_BITS=64 -DVERSION=\"$(VERSION)\"\ `pkg-config --cflags-only-I gumbo libcurl fuse uuid expat` LDFLAGS += `pkg-config --libs-only-L gumbo libcurl fuse uuid expat` -LIBS = -pthread -lgumbo -lcurl -lfuse -lcrypto -luuid -lexpat +LIBS = -pthread -lgumbo -lcurl -lfuse -lcrypto -lexpat COBJS = main.o network.o fuse_local.o link.o cache.o util.o sonic.o OS := $(shell uname) +ifeq ($(OS),Darwin) + BREW_PREFIX := $(shell brew --prefix) + CFLAGS += -I$(BREW_PREFIX)/opt/openssl/include \ + -I$(BREW_PREFIX)/opt/curl/include + LDFLAGS += -L$(BREW_PREFIX)/opt/openssl/lib \ + -L$(BREW_PREFIX)/opt/curl/lib +else + LIBS += -luuid +endif ifeq ($(OS),FreeBSD) LIBS += -lexecinfo endif diff --git a/README.md b/README.md index 0492bee..cc97c17 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,19 @@ You can then build + install with: Alternatively, you may use the FreeBSD [ports(7)](https://man.freebsd.org/ports/7) infrastructure to build HTTPDirFS from source with the modifications you need. +### macOS +You need to install macFUSE, cURL, gumbo, and OpenSSL from Homebrew: + + brew install macfuse curl gumbo-parser openssl pkg-config + +Build and install: + + make + sudo make install + +Apple's command-line build tools are usually installed as part of setting up Homebrew. +HTTPDirFS will be installed in ``/usr/local``. + ## Usage ./httpdirfs -f --cache $URL $MOUNT_POINT diff --git a/src/fuse_local.c b/src/fuse_local.c index 0ef4cd3..a427dac 100644 --- a/src/fuse_local.c +++ b/src/fuse_local.c @@ -42,7 +42,11 @@ static int fs_getattr(const char *path, struct stat *stbuf) } struct timespec spec; spec.tv_sec = link->time; +#if defined(__APPLE__) && defined(__MACH__) + stbuf->st_mtimespec = spec; +#else stbuf->st_mtim = spec; +#endif switch (link->type) { case LINK_DIR: stbuf->st_mode = S_IFDIR | 0755;