<commit_before>################################################################################
#
#	lib-util : A Utility Library
#
#	Copyright (c) 2016-2017 <NAME>
#	You should have received a copy of the licence terms with this software. If
#	not, please visit the project homepage at:
#	https://github.com/ammon0/lib-util
#
################################################################################

# Change these variables to point to the appropriate installation directories
INSTALLDIR:=$(HOME)/prg
LIBDIR:=$(INSTALLDIR)/lib
INCDIR:=$(INSTALLDIR)/include/util

# My code builds without warnings--ALWAYS
CWARNINGS:=	-Wall -Wextra -pedantic \
	-Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations \
	-Wredundant-decls -Werror=implicit-function-declaration -Wnested-externs \
	-Wshadow -Wbad-function-cast \
	-Wcast-align \
	-Wdeclaration-after-statement -Werror=uninitialized \
	-Winline \
	-Wswitch-default -Wswitch-enum \
	-Wsuggest-attribute=pure -Wsuggest-attribute=const \
	-Wsuggest-attribute=noreturn -Wsuggest-attribute=format \
	-Wtrampolines -Wstack-protector \
	-Wwrite-strings \
	-Wc++-compat \
	-Wconversion -Wdisabled-optimization \
	-Wpadded

CFLAGS  := $(CWARNINGS)   --std=c11   -g -O3 -I./

headers:= \
util/data.h util/input.h util/msg.h \
util/hash.h util/types.h util/flags.h

libraries:= libdata.a libinput.a libmsg.a
tests    := test-hash test-input test-data test-msg

allfiles:= $(headers) data.c test-data.c input.c test-input.c msg.c
CLEANFILES:= *.o *.a test-data test-input test-hash test-msg


.PHONEY: install all

all: $(libraries)

install: $(libraries) $(headers)
	install -d $(LIBDIR) $(INCDIR)
	for f in $(libraries); do install -C $$f $(LIBDIR); done
	for f in $(headers)  ; do install -C $$f $(INCDIR); done

test-hash: util/hash.h test-hash.c data.o input.o msg.o
	$(CC) $(CFLAGS) -Wno-conversion -Wno-pointer-sign -o $@ test-hash.c data.o input.o msg.o -lm
	chmod +x $@

test-input: util/input.h test-input.c libinput.a
	$(CC) $(CFLAGS) -o $@ -L./ test-input.c -linput
	chmod +x $@

test-data: util/data.h test-data.c libdata.a libmsg.a
	$(CC) $(CFLAGS) -o $@ -L./ test-data.c -ldata -lmsg
	chmod +x $@

test-msg: util/msg.h test-msg.c libmsg.a
	$(CC) $(CFLAGS) -o $@ -L./ test-msg.c -lmsg
	chmod +x $@

msg.o: msg.c util/msg.h util/flags.h
	$(CC) $(CFLAGS) -Wno-conversion -c $<

lib%.a: %.o
	ar rcs $@ $<

%.o: %.c util/%.h
	$(CC) $(CFLAGS) -c $<


################################## UTILITIES ###################################

.PHONEY: clean todolist docs very-clean count

docs: Doxyfile $(headers) README.md
	doxygen Doxyfile

clean:
	rm -f $(CLEANFILES)

very-clean: clean
	rm -r ./docs

todolist:
	-@for file in $(allfiles:Makefile=); do fgrep -H -e TODO -e FIXME $$file; done; true

count:
	cat $(allfiles) |line_count

<commit_msg>Changed makefile to build libraries as shared objects.<commit_after>################################################################################
#
#	lib-util : A Utility Library
#
#	Copyright (c) 2016-2017 <NAME>
#	You should have received a copy of the licence terms with this software. If
#	not, please visit the project homepage at:
#	https://github.com/ammon0/lib-util
#
################################################################################

# Change these variables to point to the appropriate installation directories
INSTALLDIR:=$(HOME)/prg
LIBDIR:=$(INSTALLDIR)/lib/util
INCDIR:=$(INSTALLDIR)/include/util

# My code builds without warnings--ALWAYS
CWARNINGS:=	-Wall -Wextra -pedantic \
	-Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations \
	-Wredundant-decls -Werror=implicit-function-declaration -Wnested-externs \
	-Wshadow -Wbad-function-cast \
	-Wcast-align \
	-Wdeclaration-after-statement -Werror=uninitialized \
	-Winline \
	-Wswitch-default -Wswitch-enum \
	-Wsuggest-attribute=pure -Wsuggest-attribute=const \
	-Wsuggest-attribute=noreturn -Wsuggest-attribute=format \
	-Wtrampolines -Wstack-protector \
	-Wwrite-strings \
	-Wc++-compat \
	-Wconversion -Wdisabled-optimization \
	-Wpadded

CFLAGS  := $(CWARNINGS) --std=c11 -g -O3 -I./

headers:= \
util/data.h util/input.h util/msg.h \
util/hash.h util/types.h util/flags.h

libraries:= libdata.so libinput.so libmsg.so
tests    := test-hash test-input test-data test-msg

allfiles:= $(headers) data.c test-data.c input.c test-input.c msg.c
cleanfiles:= *.o *.a *.so test-data test-input test-hash test-msg


.PHONEY: install libs all

all: libs test-hash test-input test-data test-msg
libs: $(libraries)

install: $(libraries) $(headers)
	install -d $(LIBDIR) $(INCDIR)
	for f in $(libraries); do install -C $$f $(LIBDIR); done
	for f in $(headers)  ; do install -C $$f $(INCDIR); done

test-hash: util/hash.h test-hash.c data.o input.o msg.o
	$(CC) $(CFLAGS) -Wno-conversion -Wno-pointer-sign -o $@ test-hash.c data.o input.o msg.o -lm
	chmod +x $@

test-input: util/input.h test-input.c libinput.so
	$(CC) $(CFLAGS) -o $@ -L./ test-input.c -linput
	chmod +x $@

test-data: util/data.h test-data.c libdata.so libmsg.so
	$(CC) $(CFLAGS) -o $@ -L./ test-data.c -ldata -lmsg
	chmod +x $@

test-msg: util/msg.h test-msg.c libmsg.so
	$(CC) $(CFLAGS) -o $@ -L./ test-msg.c -lmsg
	chmod +x $@

msg.o: msg.c util/msg.h util/flags.h
	$(CC) $(CFLAGS) -Wno-conversion -c -fpic -o $@ $<

lib%.so: %.o
	$(CC) $(CFLAGS) -shared -o $@ $^
#ar rcs $@ $^

%.o: %.c util/%.h
	$(CC) $(CFLAGS) -c -fpic -o $@ $<


################################## UTILITIES ###################################

.PHONEY: clean todolist docs very-clean count

docs: Doxyfile $(headers) README.md
	doxygen Doxyfile

clean:
	rm -f $(cleanfiles)

very-clean: clean
	rm -r ./docs

todolist:
	-@for file in $(allfiles:Makefile=); do fgrep -H -e TODO -e FIXME $$file; done; true

count:
	cat $(allfiles) |line_count


{'fraction_non_alphanumeric': 0.23030303030303031, 'fraction_numerical': 0.004155844155844156, 'mean_word_length': 3.7696118909991743, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '577554', 'n_tokens_mistral': 2209, 'n_tokens_neox': 2097, 'n_words': 545}