Skip to content

Commit

Permalink
autotools-ize the build
Browse files Browse the repository at this point in the history
  • Loading branch information
jikamens committed Sep 27, 2023
1 parent 5f61aac commit eac21ab
Show file tree
Hide file tree
Showing 10 changed files with 9,557 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ doc/html
*.c~
*.h~

# autotools
autom4te.cache

#Others
mnt
27 changes: 12 additions & 15 deletions Makefile → Makefile.am
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
VERSION = 1.2.5

CFLAGS += -g -O2 -Wall -Wextra -Wshadow \
CFLAGS = -g -O2 -Wall -Wextra -Wshadow \
-Wno-analyzer-file-leak \
-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`
LDFLAGS = `pkg-config --libs-only-L gumbo libcurl fuse uuid expat`
LIBS = -pthread -lgumbo -lcurl -lfuse -lcrypto -lexpat
COBJS = main.o network.o fuse_local.o link.o cache.o util.o sonic.o log.o\
config.o memcache.o

OS := $(shell uname)
ifeq ($(OS),Darwin)
if OS_DARWIN
BREW_PREFIX := $(shell brew --prefix)
CFLAGS += -I$(BREW_PREFIX)/opt/openssl/include \
-I$(BREW_PREFIX)/opt/curl/include
Expand All @@ -19,35 +16,35 @@ ifeq ($(OS),Darwin)
else
LIBS += -luuid
endif
ifeq ($(OS),FreeBSD)
if OS_FREEBSD
LIBS += -lexecinfo
endif

prefix ?= /usr/local

all: httpdirfs

%.o: src/%.c
%.o: $(srcdir)/src/%.c
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -c -o $@ $<

httpdirfs: $(COBJS)
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)

install:
ifeq ($(OS),Linux)
if OS_LINUX
install -m 755 -D httpdirfs \
$(DESTDIR)$(prefix)/bin/httpdirfs
install -m 644 -D doc/man/httpdirfs.1 \
$(DESTDIR)$(prefix)/share/man/man1/httpdirfs.1
endif
ifeq ($(OS),FreeBSD)
if OS_FREEBSD
install -m 755 httpdirfs \
$(DESTDIR)$(prefix)/bin/httpdirfs
gzip -f -k doc/man/httpdirfs.1
install -m 644 doc/man/httpdirfs.1.gz \
$(DESTDIR)$(prefix)/man/man1/httpdirfs.1.gz
endif
ifeq ($(OS),Darwin)
if OS_DARWIN
install -d $(DESTDIR)$(prefix)/bin
install -m 755 httpdirfs \
$(DESTDIR)$(prefix)/bin/httpdirfs
Expand Down Expand Up @@ -80,18 +77,18 @@ distclean: clean

uninstall:
-rm -f $(DESTDIR)$(prefix)/bin/httpdirfs
ifeq ($(OS),Linux)
if OS_LINUX
-rm -f $(DESTDIR)$(prefix)/share/man/man1/httpdirfs.1
endif
ifeq ($(OS),FreeBSD)
if OS_FREEBSD
-rm -f $(DESTDIR)$(prefix)/man/man1/httpdirfs.1.gz
endif
ifeq ($(OS),Darwin)
if OS_DARWIN
-rm -f $(DESTDIR)$(prefix)/share/man/man1/httpdirfs.1
endif

depend: .depend
.depend: src/*.c
.depend: $(srcdir)/src/*.c
rm -f ./.depend
$(CC) $(CFLAGS) -MM $^ -MF ./.depend;
include .depend
Expand Down
Loading

0 comments on commit eac21ab

Please sign in to comment.