<commit_before>ifneq ($(TRAVIS_CI), 1)
	CC = gcc
endif

INCFLAGS = -I./ -I./bomalloc
DEFS = -DCOLLECT_STATS -DBOMALLOC_SYSTEM_ALLOC -DNO_HOOK -DDEBUG -DSUPPORT_THREADS
OPT_FLAGS = -O3 -fno-strict-aliasing -fno-strict-overflow -march=native
DEBUG_FLAGS = -ggdb3 -g3
CFLAGS = $(OPT_FLAGS) $(DEBUG_FLAGS) -fPIC -Wall -Wno-unused-function -Wno-deprecated-declarations $(INCFLAGS) $(DEFS)
TEST_SOURCE = $(wildcard tests/*.c) $(wildcard tests/parallel/*.c)
SOURCE = $(wildcard *.c)
ALL_SOURCE = $(TEST_SOURCE) $(SOURCE)
HEADERS = $(wildcard *.h)
TEST_BINARIES = $(basename $(TEST_SOURCE))
TEST_OBJECTS = $(patsubst %.c,%.o, $(TEST_SOURCE))
DEP = $(SOURCE:.c=.d) $(TEST_SOURCE:.c=.d)

OBJECTS = bomalloc.o memmap.o bomalloc_utils.o bomalloc_sync.o bomalloc_overrides.o
LDFLAGS = -Wl,--no-as-needed -ldl -rdynamic -lm
LIBRARY = libbomalloc.a

default: $(LIBRARY)

libbomalloc.a: $(OBJECTS)
	@echo Building library $@
	@ar rcs $@ $?
	@ranlib $@

%.d: %.c
	@echo "Creating dependency $@"
	@$(CC) $(CFLAGS) -MM -o $@ $?
-include $(DEP)


tests/parallel/stack_%: tests/parallel/stack_%.c
	@echo "Linking $@"
	@$(CC) $(CFLAGS) -pthread $? -o $@ $(LDFLAGS)

# stack tests doesn't depend on the whole system -- special case
tests/stack_%: tests/stack_%.c
	@echo "Linking $@"
	@$(CC) $(CFLAGS) $? -o $@ $(LDFLAGS)

tests/%: tests/%.o $(OBJECTS)
	@echo "Linking $@"
	@$(CC) -rdynamic $(CFLAGS) $< $(OBJECTS) -o $@ $(LDFLAGS)

%.o: %.c
	@echo "Compiling $@"
	@$(CC) $(CFLAGS) -c -o $@ $<

tests: $(TEST_OBJECTS) $(TEST_BINARIES)
# NOTE: Tests objects is listed as a dependency so make will not auto-remove them


test: $(TEST_BINARIES)
	@echo Test binaries: $(sort $(notdir $(TEST_BINARIES)))
	@ruby tests/test_runner.rb $(sort $(TEST_BINARIES))

clean:
	rm -f $(TEST_OBJECTS) $(TEST_BINARIES) $(OBJECTS) gmon.out $(LIBRARY)
clobber: clean
	rm -f $(DEP)<commit_msg>[build] Use library to link tests, remove unneeded flags<commit_after>ifneq ($(TRAVIS_CI), 1)
	CC = gcc
endif

INCFLAGS = -I./ -I./bomalloc
DEFS = -DCOLLECT_STATS -DBOMALLOC_SYSTEM_ALLOC -DNO_HOOK -DDEBUG -DSUPPORT_THREADS
OPT_FLAGS = -O3 -march=native
DEBUG_FLAGS = -ggdb3 -g3
CFLAGS = $(OPT_FLAGS) $(DEBUG_FLAGS) -fPIC -Wall -Wno-unused-function -Wno-deprecated-declarations $(INCFLAGS) $(DEFS)
TEST_SOURCE = $(wildcard tests/*.c) $(wildcard tests/parallel/*.c)
SOURCE = $(wildcard *.c)
ALL_SOURCE = $(TEST_SOURCE) $(SOURCE)
HEADERS = $(wildcard *.h)
TEST_BINARIES = $(basename $(TEST_SOURCE))
TEST_OBJECTS = $(patsubst %.c,%.o, $(TEST_SOURCE))
DEP = $(SOURCE:.c=.d) $(TEST_SOURCE:.c=.d)

OBJECTS = bomalloc.o memmap.o bomalloc_utils.o bomalloc_sync.o bomalloc_overrides.o
LDFLAGS = -Wl,--no-as-needed -ldl -rdynamic -lm
LIBRARY = libbomalloc.a

default: $(LIBRARY)

libbomalloc.a: $(OBJECTS)
	@echo Building library $@
	@ar rcs $@ $?
	@ranlib $@

%.d: %.c
	@echo "Creating dependency $@"
	@$(CC) $(CFLAGS) -MM -o $@ $?
-include $(DEP)


tests/parallel/stack_%: tests/parallel/stack_%.c
	@echo "Linking $@"
	@$(CC) $(CFLAGS) -pthread $? -o $@ $(LDFLAGS)

# stack tests doesn't depend on the whole system -- special case
tests/stack_%: tests/stack_%.c
	@echo "Linking $@"
	@$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)

tests/%: tests/%.o $(LIBRARY)
	@echo "Linking $@"
	@$(CC) -rdynamic $(CFLAGS) $^ -o $@ $(LDFLAGS)

%.o: %.c
	@echo "Compiling $@"
	@$(CC) $(CFLAGS) -c -o $@ $<

tests: $(TEST_OBJECTS) $(TEST_BINARIES)
# NOTE: Tests objects is listed as a dependency so make will not auto-remove them


test: $(TEST_BINARIES)
	@echo Test binaries: $(sort $(notdir $(TEST_BINARIES)))
	@ruby tests/test_runner.rb $(sort $(TEST_BINARIES))

clean:
	rm -f $(TEST_OBJECTS) $(TEST_BINARIES) $(OBJECTS) gmon.out $(LIBRARY)
clobber: clean
	rm -f $(DEP)
{'fraction_non_alphanumeric': 0.19326818675352878, 'fraction_numerical': 0.002171552660152009, 'mean_word_length': 4.467359050445104, 'pattern_counts': {'":': 0, '<': 6, '<?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': '5535367', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1462, 'n_words': 360}