Merge pull request #63 from hiliev/macos-patches

Add support for macOS
This commit is contained in:
Fufu Fang 2021-05-27 20:15:52 +01:00 committed by GitHub
commit fbaf6b948a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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;