<commit_before>
CC ?= clang
CFLAGS ?= -O3 -DNDEBUG

CXX ?= clang++
CPPFLAGS = -Ilua/src -Isrc -MMD -MP
CXXFLAGS ?= -O3 -std=c++11 -stdlib=libc++ -fno-exceptions -DNDEBUG
CXXLIBFLAGS ?= -stdlib=libc++

VPATH = lua/src:src:build:unittest

LUA_SOURCES = \
  lapi.c lauxlib.c lbaselib.c lcode.c \
  ldblib.c ldebug.c ldo.c ldump.c \
  lfunc.c lgc.c linit.c liolib.c \
  llex.c lmathlib.c lmem.c loadlib.c \
  lobject.c lopcodes.c loslib.c lparser.c \
  lstate.c lstring.c lstrlib.c ltable.c \
  ltablib.c ltm.c lundump.c lvm.c \
  lzio.c

LIBTUNDRA_SOURCES = \
	BinaryWriter.cpp BuildQueue.cpp Common.cpp DagGenerator.cpp \
	Driver.cpp FileInfo.cpp Hash.cpp HashTable.cpp \
	IncludeScanner.cpp JsonParse.cpp MemAllocHeap.cpp \
	MemAllocLinear.cpp MemoryMappedFile.cpp PathUtil.cpp \
	ScanCache.cpp Scanner.cpp SignalHandler.cpp StatCache.cpp \
	TargetSelect.cpp Thread.cpp dlmalloc.c TerminalIo.cpp \
	ExecUnix.cpp

T2LUA_SOURCES = LuaMain.cpp LuaInterface.cpp LuaInterpolate.cpp LuaJsonWriter.cpp

T2INSPECT_SOURCES = InspectMain.cpp

UNITTEST_SOURCES = \
	TestHarness.cpp Test_BitFuncs.cpp Test_Buffer.cpp Test_Djb2.cpp Test_Hash.cpp \
	Test_IncludeScanner.cpp Test_Json.cpp Test_MemAllocLinear.cpp Test_Pow2.cpp \
	Test_TargetSelect.cpp test_PathUtil.cpp

TUNDRA_SOURCES = Main.cpp

LUA_OBJECTS = $(addprefix build/,$(LUA_SOURCES:.c=.o))
LIBTUNDRA_OBJECTS = $(addprefix build/,$(LIBTUNDRA_SOURCES:.cpp=.o))
LIBTUNDRA_OBJECTS := $(LIBTUNDRA_OBJECTS:.c=.o)
T2LUA_OBJECTS = $(addprefix build/,$(T2LUA_SOURCES:.cpp=.o))
T2INSPECT_OBJECTS = $(addprefix build/,$(T2INSPECT_SOURCES:.cpp=.o))
UNITTEST_OBJECTS = $(addprefix build/,$(UNITTEST_SOURCES:.cpp=.o))
TUNDRA_OBJECTS = $(addprefix build/,$(TUNDRA_SOURCES:.cpp=.o))

ALL_SOURCES = $(TUNDRA_SOURCES) $(LIBTUNDRA_SOURCES) $(LUA_SOURCES) $(T2LUA_SOURCES) $(T2INSPECT_SOURCES)
ALL_DEPS = $(ALL_SOURCES:.cpp=.d)
ALL_DEPS := $(addprefix build/,$(ALL_DEPS:.c=.d))

all: build build/tundra2 build/t2-lua build/t2-inspect build/t2-unittest

build:
	mkdir build

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

build/%.o: %.cpp
	$(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $<

build/libtundralua.a: $(LUA_OBJECTS)
	$(AR) -r $@ $^

build/libtundra.a: $(LIBTUNDRA_OBJECTS)
	$(AR) -r $@ $^

build/tundra2: $(TUNDRA_OBJECTS) build/libtundra.a
	$(CXX) -o $@ $(CXXLIBFLAGS) $(TUNDRA_OBJECTS) -Lbuild -ltundra

build/t2-lua: $(T2LUA_OBJECTS) build/libtundra.a build/libtundralua.a
	$(CXX) -o $@ $(CXXLIBFLAGS) $(T2LUA_OBJECTS) -Lbuild -ltundra -ltundralua

build/t2-inspect: $(T2INSPECT_OBJECTS) build/libtundra.a
	$(CXX) -o $@ $(CXXLIBFLAGS) $(T2INSPECT_OBJECTS) -Lbuild -ltundra

build/t2-unittest: $(UNITTEST_OBJECTS) build/libtundra.a
	$(CXX) -o $@ $(CXXLIBFLAGS) $(UNITTEST_OBJECTS) -Lbuild -ltundra

.PHONY: clean
clean:
	rm -rf build

-include $(ALL_DEPS)<commit_msg>Replace hardcoded library dependency lines with LDFLAGS. For the BSDs adjust LDFLAGS to use libpthread for pthread_create().<commit_after>
UNAME := $(shell uname)

CC ?= clang
CFLAGS ?= -O3 -DNDEBUG

CXX ?= clang++
CPPFLAGS = -Ilua/src -Isrc -MMD -MP
CXXFLAGS ?= -O3 -std=c++11 -stdlib=libc++ -fno-exceptions -DNDEBUG
CXXLIBFLAGS ?= -stdlib=libc++
LDFLAGS ?= -Lbuild -ltundra
ifeq ($(UNAME), $(filter $(UNAME), FreeBSD NetBSD OpenBSD))
LDFLAGS += -lpthread
endif

VPATH = lua/src:src:build:unittest

LUA_SOURCES = \
  lapi.c lauxlib.c lbaselib.c lcode.c \
  ldblib.c ldebug.c ldo.c ldump.c \
  lfunc.c lgc.c linit.c liolib.c \
  llex.c lmathlib.c lmem.c loadlib.c \
  lobject.c lopcodes.c loslib.c lparser.c \
  lstate.c lstring.c lstrlib.c ltable.c \
  ltablib.c ltm.c lundump.c lvm.c \
  lzio.c

LIBTUNDRA_SOURCES = \
	BinaryWriter.cpp BuildQueue.cpp Common.cpp DagGenerator.cpp \
	Driver.cpp FileInfo.cpp Hash.cpp HashTable.cpp \
	IncludeScanner.cpp JsonParse.cpp MemAllocHeap.cpp \
	MemAllocLinear.cpp MemoryMappedFile.cpp PathUtil.cpp \
	ScanCache.cpp Scanner.cpp SignalHandler.cpp StatCache.cpp \
	TargetSelect.cpp Thread.cpp dlmalloc.c TerminalIo.cpp \
	ExecUnix.cpp

T2LUA_SOURCES = LuaMain.cpp LuaInterface.cpp LuaInterpolate.cpp LuaJsonWriter.cpp

T2INSPECT_SOURCES = InspectMain.cpp

UNITTEST_SOURCES = \
	TestHarness.cpp Test_BitFuncs.cpp Test_Buffer.cpp Test_Djb2.cpp Test_Hash.cpp \
	Test_IncludeScanner.cpp Test_Json.cpp Test_MemAllocLinear.cpp Test_Pow2.cpp \
	Test_TargetSelect.cpp test_PathUtil.cpp

TUNDRA_SOURCES = Main.cpp

LUA_OBJECTS = $(addprefix build/,$(LUA_SOURCES:.c=.o))
LIBTUNDRA_OBJECTS = $(addprefix build/,$(LIBTUNDRA_SOURCES:.cpp=.o))
LIBTUNDRA_OBJECTS := $(LIBTUNDRA_OBJECTS:.c=.o)
T2LUA_OBJECTS = $(addprefix build/,$(T2LUA_SOURCES:.cpp=.o))
T2INSPECT_OBJECTS = $(addprefix build/,$(T2INSPECT_SOURCES:.cpp=.o))
UNITTEST_OBJECTS = $(addprefix build/,$(UNITTEST_SOURCES:.cpp=.o))
TUNDRA_OBJECTS = $(addprefix build/,$(TUNDRA_SOURCES:.cpp=.o))

ALL_SOURCES = $(TUNDRA_SOURCES) $(LIBTUNDRA_SOURCES) $(LUA_SOURCES) $(T2LUA_SOURCES) $(T2INSPECT_SOURCES)
ALL_DEPS = $(ALL_SOURCES:.cpp=.d)
ALL_DEPS := $(addprefix build/,$(ALL_DEPS:.c=.d))

all: build build/tundra2 build/t2-lua build/t2-inspect build/t2-unittest

build:
	mkdir build

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

build/%.o: %.cpp
	$(CXX) -c -o $@ $(CPPFLAGS) $(CXXFLAGS) $<

build/libtundralua.a: $(LUA_OBJECTS)
	$(AR) -r $@ $^

build/libtundra.a: $(LIBTUNDRA_OBJECTS)
	$(AR) -r $@ $^

build/tundra2: $(TUNDRA_OBJECTS) build/libtundra.a
	$(CXX) -o $@ $(CXXLIBFLAGS) $(TUNDRA_OBJECTS) $(LDFLAGS)

build/t2-lua: $(T2LUA_OBJECTS) build/libtundra.a build/libtundralua.a
	$(CXX) -o $@ $(CXXLIBFLAGS) $(T2LUA_OBJECTS) $(LDFLAGS) -ltundralua

build/t2-inspect: $(T2INSPECT_OBJECTS) build/libtundra.a
	$(CXX) -o $@ $(CXXLIBFLAGS) $(T2INSPECT_OBJECTS) $(LDFLAGS)

build/t2-unittest: $(UNITTEST_OBJECTS) build/libtundra.a
	$(CXX) -o $@ $(CXXLIBFLAGS) $(UNITTEST_OBJECTS) $(LDFLAGS)

.PHONY: clean
clean:
	rm -rf build

-include $(ALL_DEPS)
{'fraction_non_alphanumeric': 0.15580639644262015, 'fraction_numerical': 0.008893449632290064, 'mean_word_length': 4.688715953307393, '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': '3641503', 'n_tokens_mistral': 2690, 'n_tokens_neox': 2497, 'n_words': 439}