<commit_before>CC      ?= $(firstword $(shell which gcc clang))
CFLAGS  ?= -Wall -Wextra -Werror -pedantic -O2
CFLAGS  += -std=c99 -D_POSIX_C_SOURCE=200112L
CFLAGS  += $(shell pkg-config --cflags openssl)
LDFLAGS += $(shell pkg-config --libs openssl)

OBJECTS := $(patsubst src/%.c,build/%.o,$(wildcard src/*.c))
TESTS   := $(patsubst test/%.c,build/test/%,$(wildcard test/*.c))
.SECONDARY: $(TESTS:%=%.o)

GENERATED_CONFIGS := $(patsubst test/data/template%,test/data/generated%,\
  $(wildcard test/data/template-config-files/*))

.PHONY: all test doc clean
all: build/nb

-include build/dependencies.makefile
build/dependencies.makefile:
	mkdir -p build/
	$(CC) -MM src/*.c | sed -r 's,^(\S+:),build/\1,g' > $@

build/nb: $(filter-out build/test.o,$(OBJECTS))
	$(CC) $(LDFLAGS) $^ -o $@

build/%.o:
	$(CC) $(CFLAGS) -c $< -o $@

test: $(TESTS) $(GENERATED_CONFIGS) test/data/test\ directory/.empty/
	@(cd test/data/ && \
	  for test in $(TESTS); do \
	  echo "Running $$(tput setf 6)$$test$$(tput sgr0):"; \
	  "../../$$test" || exit 1; \
	  echo; \
	  done)

build/test/%: build/test/%.o \
  $(filter-out build/main.o build/error-handling.o,$(OBJECTS))
	$(CC) $(LDFLAGS) $^ -o $@

build/test/%.o: test/%.c
	 mkdir -p build/test/ && $(CC) $(CFLAGS) -Isrc/ -c $< -o $@

test/data/generated-config-files/%: test/data/template-config-files/%
	mkdir -p "$(dir $@)" && sed -r "s,^/,$$PWD/test/data/,g" "$<" > "$@"

test/data/test\ directory/.empty/:
	mkdir -p "$@"

doc:
	doxygen

clean:
	- rm -rf build/ doc/ test/data/generated-config-files/
<commit_msg>Create empty tmp dir for each test<commit_after>CC      ?= $(firstword $(shell which gcc clang))
CFLAGS  ?= -Wall -Wextra -Werror -pedantic -O2
CFLAGS  += -std=c99 -D_POSIX_C_SOURCE=200112L
CFLAGS  += $(shell pkg-config --cflags openssl)
LDFLAGS += $(shell pkg-config --libs openssl)

OBJECTS := $(patsubst src/%.c,build/%.o,$(wildcard src/*.c))
TESTS   := $(patsubst test/%.c,build/test/%,$(wildcard test/*.c))
.SECONDARY: $(TESTS:%=%.o)

GENERATED_CONFIGS := $(patsubst test/data/template%,test/data/generated%,\
  $(wildcard test/data/template-config-files/*))

.PHONY: all test doc clean
all: build/nb

-include build/dependencies.makefile
build/dependencies.makefile:
	mkdir -p build/
	$(CC) -MM src/*.c | sed -r 's,^(\S+:),build/\1,g' > $@

build/nb: $(filter-out build/test.o,$(OBJECTS))
	$(CC) $(LDFLAGS) $^ -o $@

build/%.o:
	$(CC) $(CFLAGS) -c $< -o $@

test: $(TESTS) $(GENERATED_CONFIGS) test/data/test\ directory/.empty/
	@(cd test/data/ && \
	  for test in $(TESTS); do \
	  rm -rf tmp/; \
	  mkdir -p tmp/; \
	  echo "Running $$(tput setf 6)$$test$$(tput sgr0):"; \
	  "../../$$test" || exit 1; \
	  echo; \
	  done)

build/test/%: build/test/%.o \
  $(filter-out build/main.o build/error-handling.o,$(OBJECTS))
	$(CC) $(LDFLAGS) $^ -o $@

build/test/%.o: test/%.c
	 mkdir -p build/test/ && $(CC) $(CFLAGS) -Isrc/ -c $< -o $@

test/data/generated-config-files/%: test/data/template-config-files/%
	mkdir -p "$(dir $@)" && sed -r "s,^/,$$PWD/test/data/,g" "$<" > "$@"

test/data/test\ directory/.empty/:
	mkdir -p "$@"

doc:
	doxygen

clean:
	- rm -rf build/ doc/ test/data/generated-config-files/ test/data/tmp/

{'fraction_non_alphanumeric': 0.23742138364779874, 'fraction_numerical': 0.008176100628930818, 'mean_word_length': 3.2583668005354753, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '3324186', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1286, 'n_words': 275}