<commit_before>CC?=gcc
CFLAGS?=-g -O2
CFLAGS+=-Wall -Wextra -Wno-unused-parameter
LIBS+=-lrt
SRCDIR=src
TESTDIR=tests
LIB_OBJS=bitstring.o encparams.o hash.o idxgen.o key.o mgf.o ntru.o poly.o rand.o sha1.o sha2.o
TEST_OBJS=test_bitstring.o test_hash.o test_idxgen.o test_key.o test_ntru.o test.o test_poly.o test_util.o
VERSION=0.2
INST_PFX=/usr
INST_HEADERS=ntru.h types.h key.h encparams.h hash.h rand.h err.h

LIB_OBJS_PATHS=$(patsubst %,$(SRCDIR)/%,$(LIB_OBJS))
TEST_OBJS_PATHS=$(patsubst %,$(TESTDIR)/%,$(TEST_OBJS))
DIST_NAME=libntru-$(VERSION)

.PHONY: all
all: lib

.PHONY: lib
lib: $(LIB_OBJS_PATHS)
	$(CC) $(CFLAGS) $(CPPFLAGS) -shared -Wl,-soname,libntru.so -o libntru.so $(LIB_OBJS_PATHS) $(LDFLAGS) $(LIBS)

.PHONY: install
install: lib
	test -d $(INST_PFX) || mkdir -p $(INST_PFX)
	test -d $(INST_PFX)/lib || mkdir $(INST_PFX)/lib
	test -d $(INST_PFX)/include/libntru || mkdir -p $(INST_PFX)/include/libntru
	test -d $(INST_PFX)/share/doc/libntru || mkdir -p $(INST_PFX)/share/doc/libntru
	install -m 0755 libntru.so $(INST_PFX)/lib/libntru.so
	install -m 0644 README.md $(INST_PFX)/share/doc/libntru/README.md
	for header in $(INST_HEADERS); do \
	    install -m 0644 $(SRCDIR)/$$header $(INST_PFX)/include/libntru/; \
	done

.PHONY: uninstall
uninstall:
	rm -f $(INST_PFX)/lib/libntru.so
	rm -f $(INST_PFX)/share/doc/libntru/README.md
	rmdir $(INST_PFX)/share/doc/libntru/
	for header in $(INST_HEADERS); do \
	    rm $(INST_PFX)/include/libntru/$$header; \
	done
	rmdir $(INST_PFX)/include/libntru/

.PHONY: dist
dist:
	rm -rf $(DIST_NAME)
	mkdir $(DIST_NAME)
	mkdir $(DIST_NAME)/$(SRCDIR)
	mkdir $(DIST_NAME)/$(TESTDIR)
	cp Makefile Makefile.win Makefile.osx README.md LICENSE PATENTS $(DIST_NAME)
	cp $(SRCDIR)/*.c $(DIST_NAME)/$(SRCDIR)
	cp $(SRCDIR)/*.h $(DIST_NAME)/$(SRCDIR)
	cp $(TESTDIR)/*.c $(DIST_NAME)/$(TESTDIR)
	cp $(TESTDIR)/*.h $(DIST_NAME)/$(TESTDIR)
	tar cf $(DIST_NAME).tar.xz $(DIST_NAME) --lzma
	rm -rf $(DIST_NAME)

test: lib $(TEST_OBJS_PATHS)
	$(CC) $(CFLAGS) $(CPPFLAGS) -o test $(TEST_OBJS_PATHS) $(LDFLAGS) -L. -lntru -lm<commit_msg>Allow more control over install procedure<commit_after>CC?=gcc
CFLAGS?=-g -O2
CFLAGS+=-Wall -Wextra -Wno-unused-parameter
LIBS+=-lrt
SRCDIR=src
TESTDIR=tests
LIB_OBJS=bitstring.o encparams.o hash.o idxgen.o key.o mgf.o ntru.o poly.o rand.o sha1.o sha2.o
TEST_OBJS=test_bitstring.o test_hash.o test_idxgen.o test_key.o test_ntru.o test.o test_poly.o test_util.o
VERSION=0.2
INST_PFX=/usr
INST_LIBDIR=$(INST_PFX)/lib
INST_INCLUDE=$(INST_PFX)/include/libntru
INST_DOCDIR=$(INST_PFX)/share/doc/libntru
INST_HEADERS=ntru.h types.h key.h encparams.h hash.h rand.h err.h

LIB_OBJS_PATHS=$(patsubst %,$(SRCDIR)/%,$(LIB_OBJS))
TEST_OBJS_PATHS=$(patsubst %,$(TESTDIR)/%,$(TEST_OBJS))
DIST_NAME=libntru-$(VERSION)

.PHONY: all
all: lib

.PHONY: lib
lib: $(LIB_OBJS_PATHS)
	$(CC) $(CFLAGS) $(CPPFLAGS) -shared -Wl,-soname,libntru.so -o libntru.so $(LIB_OBJS_PATHS) $(LDFLAGS) $(LIBS)

.PHONY: install
install: lib
	test -d "$(DESTDIR)$(INST_PFX)" || mkdir -p "$(DESTDIR)$(INST_PFX)"
	test -d "$(DESTDIR)$(INST_LIBDIR)" || mkdir "$(DESTDIR)$(INST_LIBDIR)"
	test -d "$(DESTDIR)$(INST_INCLUDE)" || mkdir -p "$(DESTDIR)$(INST_INCLUDE)"
	test -d "$(DESTDIR)$(INST_DOCDIR)" || mkdir -p "$(DESTDIR)$(INST_DOCDIR)"
	install -m 0755 libntru.so "$(DESTDIR)$(INST_LIBDIR)/libntru.so"
	install -m 0644 README.md "$(DESTDIR)$(INST_DOCDIR)/README.md"
	for header in $(INST_HEADERS) ; do \
	    install -m 0644 "$(SRCDIR)/$$header" "$(DESTDIR)$(INST_INCLUDE)/" ; \
	done

.PHONY: uninstall
uninstall:
	rm -f "$(DESTDIR)$(INST_LIBDIR)/libntru.so"
	rm -f "$(DESTDIR)$(INST_DOCDIR)/README.md"
	rmdir "$(DESTDIR)$(INST_DOCDIR)/"
	for header in $(INST_HEADERS) ; do \
	    rm "$(DESTDIR)$(INST_INCLUDE)/$$header" ; \
	done
	rmdir "$(DESTDIR)$(INST_INCLUDE)/"

.PHONY: dist
dist:
	rm -rf $(DIST_NAME)
	mkdir $(DIST_NAME)
	mkdir $(DIST_NAME)/$(SRCDIR)
	mkdir $(DIST_NAME)/$(TESTDIR)
	cp Makefile Makefile.win Makefile.osx README.md LICENSE PATENTS $(DIST_NAME)
	cp $(SRCDIR)/*.c $(DIST_NAME)/$(SRCDIR)
	cp $(SRCDIR)/*.h $(DIST_NAME)/$(SRCDIR)
	cp $(TESTDIR)/*.c $(DIST_NAME)/$(TESTDIR)
	cp $(TESTDIR)/*.h $(DIST_NAME)/$(TESTDIR)
	tar cf $(DIST_NAME).tar.xz $(DIST_NAME) --lzma
	rm -rf $(DIST_NAME)

test: lib $(TEST_OBJS_PATHS)
	$(CC) $(CFLAGS) $(CPPFLAGS) -o test $(TEST_OBJS_PATHS) $(LDFLAGS) -L. -lntru -lm
{'fraction_non_alphanumeric': 0.19232536764705882, 'fraction_numerical': 0.0078125, 'mean_word_length': 4.94672131147541, 'pattern_counts': {'":': 0, '<': 3, '<?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': '385746', 'n_tokens_mistral': 2028, 'n_tokens_neox': 1914, 'n_words': 371}