<commit_before>BIN=event-compiler

DISABLED_WARNINGS=switch
CFLAGS=-g -Wall -std=gnu99 -Ilibcollect $(patsubst %, -Wno-%, $(DISABLED_WARNINGS))
LDFLAGS=-Llibcollect
LDLIBS=-lcollect
YACC=lemon/lemon
LEX=flex

SOURCES=src/event-compiler.c src/compiler.c src/lexer.l src/parser.y src/ast.c
COBJECTS=$(patsubst %.c, %.o, $(SOURCES))
LOBJECTS=$(patsubst %.l, %.o, $(COBJECTS))
OBJECTS=$(patsubst %.y, %.o, $(LOBJECTS))

.PHONY: all clean lemon libcollect getexternals

all: $(BIN)

$(BIN): $(OBJECTS) src/lexer.c libcollect
	$(CC) $(CFLAGS) -o $@ $(OBJECTS) $(LDFLAGS) $(LDLIBS)

src/event-compiler.o: src/event-compiler.c src/lexer.c

src/lexer.c: src/lexer.l src/parser.c
	$(LEX) --header-file=src/lexer.h -o $@ $<

src/parser.c: src/parser.y lemon
	$(YACC) $<

TEST_DEPS=$(filter-out src/%.l, $(filter-out src/%.y, $(filter-out src/event-compiler.c, $(SOURCES)))) src/lexer.c src/parser.c
TEST_SOURCES=$(wildcard tests/*.c)
tests/testsuite: $(TEST_SOURCES) $(TEST_DEPS) libcollect
	tests/generate.py tests
	$(CC) -Isrc -L. $(CFLAGS) -Wno-unused-function -o $@ $(TEST_SOURCES) $(TEST_DEPS) $(LDFLAGS) $(LDLIBS)

test: tests/testsuite
	tests/testsuite
	valgrind --leak-check=full --error-exitcode=1 --suppressions=tests/valgrind.supp tests/testsuite

clean:
	rm -f $(BIN) $(OBJECTS) src/lexer.c src/lexer.h src/parser.c src/parser.h src/parser.out
	rm -rf tests/testsuite tests/testsuite.dSYM tests/.clarcache tests/clar.suite

libcollect:
	@- make -C libcollect

lemon:
	@- make -C lemon

getexternals:
	git submodule init
	git submodule update<commit_msg>Enabled parent pointers for ast<commit_after>BIN=event-compiler

DISABLED_WARNINGS=switch
CFLAGS=-g -Wall -std=gnu99 -Ilibcollect $(patsubst %, -Wno-%, $(DISABLED_WARNINGS))
LDFLAGS=-Llibcollect
LDLIBS=-lcollect
YACC=lemon/lemon
LEX=flex

SOURCES=src/event-compiler.c src/compiler.c src/lexer.l src/parser.y src/ast.c
COBJECTS=$(patsubst %.c, %.o, $(SOURCES))
LOBJECTS=$(patsubst %.l, %.o, $(COBJECTS))
OBJECTS=$(patsubst %.y, %.o, $(LOBJECTS))

.PHONY: all clean lemon libcollect getexternals

all: $(BIN)

$(BIN): $(OBJECTS) src/lexer.c libcollect
	$(CC) $(CFLAGS) -o $@ $(OBJECTS) $(LDFLAGS) $(LDLIBS)

src/event-compiler.o: src/event-compiler.c src/lexer.c

src/lexer.c: src/lexer.l src/parser.c
	$(LEX) --header-file=src/lexer.h -o $@ $<

src/parser.c: src/parser.y lemon
	$(YACC) $<

TEST_DEPS=$(filter-out src/%.l, $(filter-out src/%.y, $(filter-out src/event-compiler.c, $(SOURCES)))) src/lexer.c src/parser.c
TEST_SOURCES=$(wildcard tests/*.c)
tests/testsuite: $(TEST_SOURCES) $(TEST_DEPS) libcollect
	tests/generate.py tests
	$(CC) -Isrc -L. $(CFLAGS) -Wno-unused-function -o $@ $(TEST_SOURCES) $(TEST_DEPS) $(LDFLAGS) $(LDLIBS)

test: tests/testsuite
	tests/testsuite
	valgrind --leak-check=full --error-exitcode=1 --suppressions=tests/valgrind.supp tests/testsuite

clean:
	rm -f $(BIN) $(OBJECTS) src/lexer.c src/lexer.h src/parser.c src/parser.h src/parser.out
	rm -rf tests/testsuite tests/testsuite.dSYM tests/.clarcache tests/clar.suite

libcollect:
	@- CFLAGS=-DTREE_PARENT_POINTERS make -C libcollect

lemon:
	@- make -C lemon

getexternals:
	git submodule init
	git submodule update
{'fraction_non_alphanumeric': 0.17997465145754118, 'fraction_numerical': 0.0019011406844106464, 'mean_word_length': 4.607460035523979, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1574297', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1280, 'n_words': 258}