<commit_before>-include Makefile.inc

libdir?=lib
AFS_PREFIX?=/usr
AFS_CPPFLAGS?=-I$(AFS_PREFIX)/include -DVENUS=1
AFS_LIBS?=-L$(AFS_PREFIX)/$(libdir)/afs -lsys

LBU_CPPFLAGS=
LBU_LIBS=-lglite_lbu_db -lglite_lbu_log

CC=gcc
CPPFLAGS?=-D_GNU_SOURCE -pthread $(AFS_CPPFLAGS) $(LBU_CPPFLAGS)
CFLAGS?=-W -Wall -g -O0
ifeq ($(COVERAGE),)
else
CFLAGS+=-pg -fprofile-arcs -ftest-coverage
LDFLAGS+=-pg -fprofile-arcs -ftest-coverage
endif

BINS=scan test_browse test_rmmount test_tinyafs

all: $(BINS)

scan: scan.o browse.o array.o tinyafs.o
	$(CC) $(LDFLAGS) -pthread $+ -o $@ $(AFS_LIBS) $(LBU_LIBS)

test_browse: test_browse.o browse.o array.o
	$(CC) $(LDFLAGS) $+ -o $@ $(AFS_LIBS)

test_rmmount: test_rmmount.o tinyafs.o
	$(CC) $(LDFLAGS) $+ -o $@ $(AFS_LIBS)

test_tinyafs: tinyafs.o test_tinyafs.o
	$(CC) $(LDFLAGS) $+ -o $@ $(AFS_LIBS)

clean:
	rm -fv *.o $(BINS)
	rm -fv *.gcno *.gcda gmon.out

array.o: array.h
scan.o: browse.h tinyafs.h
test_browse.o: browse.h
test_tinyafs.o: tinyafs.h
tinyafs.o: tinyafs.h<commit_msg>Separate generic part to libtinyafs.so library, enable optimizations (using -O2 C flags).<commit_after>-include Makefile.inc

prefix=/usr
libdir?=lib
AFS_PREFIX?=/usr
AFS_CPPFLAGS?=-I$(AFS_PREFIX)/include -DVENUS=1
AFS_LIBS?=-L$(AFS_PREFIX)/$(libdir)/afs -lsys

LBU_CPPFLAGS=
LBU_LIBS=-lglite_lbu_db -lglite_lbu_log

CC=gcc
CPPFLAGS?=-D_GNU_SOURCE -pthread $(AFS_CPPFLAGS) $(LBU_CPPFLAGS)
CFLAGS?=-W -Wall -g -O2
ifeq ($(COVERAGE),)
else
CFLAGS+=-pg -fprofile-arcs -ftest-coverage
LDFLAGS+=-pg -fprofile-arcs -ftest-coverage
endif

COMPILE=libtool --mode=compile $(CC) -shared $(CFLAGS) $(CPPFLAGS)
LINK=libtool --mode=link $(CC) -shared $(LDFLAGS)
INSTALL=libtool --mode=install install

BINS=scan test_browse test_rmmount test_tinyafs

all: $(BINS)

libtinyafs.la: array.lo tinyafs.lo browse.lo
	$(LINK) -pthread -rpath $(prefix)/$(libdir) $+ -o $@ $(AFS_LIBS)

scan: scan.lo libtinyafs.la
	$(LINK) $(LDFLAGS) -pthread $+ -o $@ $(LBU_LIBS)

test_browse: test_browse.lo libtinyafs.la
	$(LINK) $(LDFLAGS) $+ -o $@

test_rmmount: test_rmmount.lo libtinyafs.la
	$(LINK) $(LDFLAGS) $+ -o $@

test_tinyafs: test_tinyafs.lo libtinyafs.la
	$(LINK) $(LDFLAGS) $+ -o $@

install:
	mkdir -p $(DESTDIR)$(prefix)/$(libdir) $(DESTDIR)$(prefix)/include $(DESTDIR)$(prefix)/share/tinyafs
	$(INSTALL) libtinyafs.la $(DESTDIR)$(prefix)/$(libdir)
	$(INSTALL) *.h $(DESTDIR)$(prefix)/include
	$(INSTALL) *.sql post-import-points.pl refresh.sh $(DESTDIR)$(prefix)/share/tinyafs

clean:
	rm -rfv *.o *.lo *.la .libs/ $(BINS)
	rm -fv *.gcno *.gcda gmon.out

%.lo: %.c
	$(COMPILE) -c $<

array.lo: array.h
scan.lo: browse.h tinyafs.h
test_browse.lo: browse.h
test_tinyafs.lo: tinyafs.h
tinyafs.lo: tinyafs.h

.PHONY: all install clean
{'fraction_non_alphanumeric': 0.18208409506398537, 'fraction_numerical': 0.0018281535648994515, 'mean_word_length': 4.909287257019439, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1098131', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1207, 'n_words': 236}