<commit_before>
# Make sure this is always first.
.PHONY: default
default: all

-include local.mk

CXXFLAG = -std=c++11 -Wall -Werror -g -O3
LINK.o = $(LINK.cc)

INCLUDE = -I .
LOCAL_LIBS = log/libcert.a log/libdatabase.a log/liblog.a \
             merkletree/libmerkletree.a \
             proto/libproto.a util/libutil.a
LDLIBS = -lpthread -lgflags -lglog -lssl -lcrypto -lldns -lsqlite3 \
         -lprotobuf -levent_core -levent_extra -levent_pthreads

PLATFORM := $(shell uname -s)
ifeq ($(PLATFORM), FreeBSD)
  LDLIBS += -L/usr/local/lib/event2
else
  LDLIBS += -lresolv
endif

# Need OpenSSL >= 1.0.0
ifneq ($(OPENSSLDIR),)
  INCLUDE += -I $(OPENSSLDIR)/include
  LDLIBS += -L $(OPENSSLDIR) -L $(OPENSSLDIR)/lib -Wl,-rpath,$(OPENSSLDIR) \
            -Wl,-rpath,$(OPENSSLDIR)/lib
endif

# Need libevent
ifneq ($(LIBEVENTDIR),)
  INCLUDE += -I $(LIBEVENTDIR)/include
  LDLIBS += -L $(LIBEVENTDIR)/.libs  -Wl,-rpath,$(LIBEVENTDIR)/.libs
endif

# Json library location explicitly specified - link against that.
ifneq ($(JSONCLIBDIR),)
	INCLUDE += -I $(JSONCLIBDIR)/include
	LDLIBS += -L $(JSONCLIBDIR)/lib -Wl,-rpath,$(JSONCLIBDIR)/lib -ljson-c
else
	JSON_C_CFLAGS := $(shell pkg-config --cflags json-c)
	CXXFLAG += $(JSON_C_CFLAGS)
	JSON_C_LIBS := $(shell pkg-config --libs json-c)
	LDLIBS += $(JSON_C_LIBS)
endif

# Need gmock
GMOCKDIR ?= /usr/src/gmock
INCLUDE += -I $(GMOCKDIR)/include -I $(GMOCKDIR)/gtest/include
GTESTLIB = gmock/gtest/libgtest.a
GMOCKLIB = gmock/libgmock.a

# Allow user-system overrides
INCLUDE += -I /usr/local/include
LDLIBS += -L /usr/local/lib

CXXFLAGS = $(INCLUDE) $(CXXFLAG) $(LOCAL_CXXFLAGS)

# These tests will be built and run automatically.
TESTS = \
	log/database_test \
	log/file_storage_test \
	log/frontend_signer_test \
	log/log_lookup_test \
	log/log_signer_test \
	log/logged_certificate_test \
	log/signer_verifier_test \
	log/tree_signer_test \
	merkletree/merkle_tree_test \
	merkletree/serial_hasher_test \
	merkletree/tree_hasher_test \
	monitor/database_test \
	proto/serializer_test \
	util/json_wrapper_test

# These tests will be built, but not run.
DISABLED_TESTS = \
	log/database_large_test \
	merkletree/merkle_tree_large_test

# These tests are built, but need specific flags, so you should add
# them to the end of the "test" target commands.
# TODO(pphaneuf): We should try to make those tests "just work", and
# move them to TESTS with the others.
EXTRA_TESTS = \
	log/cert_checker_test \
	log/cert_submission_handler_test \
	log/cert_test \
	log/ct_extensions_test \
	log/frontend_test

all: client/ct server/ct-server server/ct-dns-server tools/dump_cert \
     tools/dump_sth

tests: all $(TESTS) $(DISABLED_TESTS) $(EXTRA_TESTS)

.DELETE_ON_ERROR:

.PHONY: clean all test tests alltests benchmark clean

gmock/Makefile: $(GMOCKDIR)
	mkdir -p gmock && cd gmock && cmake $(GMOCKDIR)

gmock/libgmock.a: gmock/Makefile
	$(MAKE) -C gmock CPPFLAGS="$(CPPFLAGS)" CXXFLAGS="$(CXXFLAGS)" \
	  LDFLAGS="$(LDFLAGS)"

gmock/gtest/libgtest.a: gmock/libgmock.a

%/.depend: %/*.cc */*.h
	$(CXX) $(CXXFLAGS) -MM -MG $(filter %.cc,$^) | sed 's,\(.*\)\.o,$(@D)/\1.o,' >$(@).tmp
	mv $(@).tmp $@

### proto preprocessing
proto/%.pb.h proto/%.pb.cc: ../proto/%.proto
	protoc -I .. $^ --cpp_out=.

ifneq ($(MAKECMDGOALS),clean)
    include client/.depend
    include log/.depend
    include merkletree/.depend
    include monitor/.depend
    include proto/.depend
    include server/.depend
    include util/.depend
endif

### util/ targets
util/libutil.a: util/util.o util/openssl_util.o util/testing.o \
                util/json_wrapper.o util/thread_pool.o util/libevent_wrapper.o<commit_msg>Enable auto-dependencies for the tools sub-directory.<commit_after>
# Make sure this is always first.
.PHONY: default
default: all

-include local.mk

CXXFLAG = -std=c++11 -Wall -Werror -g -O3
LINK.o = $(LINK.cc)

INCLUDE = -I .
LOCAL_LIBS = log/libcert.a log/libdatabase.a log/liblog.a \
             merkletree/libmerkletree.a \
             proto/libproto.a util/libutil.a
LDLIBS = -lpthread -lgflags -lglog -lssl -lcrypto -lldns -lsqlite3 \
         -lprotobuf -levent_core -levent_extra -levent_pthreads

PLATFORM := $(shell uname -s)
ifeq ($(PLATFORM), FreeBSD)
  LDLIBS += -L/usr/local/lib/event2
else
  LDLIBS += -lresolv
endif

# Need OpenSSL >= 1.0.0
ifneq ($(OPENSSLDIR),)
  INCLUDE += -I $(OPENSSLDIR)/include
  LDLIBS += -L $(OPENSSLDIR) -L $(OPENSSLDIR)/lib -Wl,-rpath,$(OPENSSLDIR) \
            -Wl,-rpath,$(OPENSSLDIR)/lib
endif

# Need libevent
ifneq ($(LIBEVENTDIR),)
  INCLUDE += -I $(LIBEVENTDIR)/include
  LDLIBS += -L $(LIBEVENTDIR)/.libs  -Wl,-rpath,$(LIBEVENTDIR)/.libs
endif

# Json library location explicitly specified - link against that.
ifneq ($(JSONCLIBDIR),)
	INCLUDE += -I $(JSONCLIBDIR)/include
	LDLIBS += -L $(JSONCLIBDIR)/lib -Wl,-rpath,$(JSONCLIBDIR)/lib -ljson-c
else
	JSON_C_CFLAGS := $(shell pkg-config --cflags json-c)
	CXXFLAG += $(JSON_C_CFLAGS)
	JSON_C_LIBS := $(shell pkg-config --libs json-c)
	LDLIBS += $(JSON_C_LIBS)
endif

# Need gmock
GMOCKDIR ?= /usr/src/gmock
INCLUDE += -I $(GMOCKDIR)/include -I $(GMOCKDIR)/gtest/include
GTESTLIB = gmock/gtest/libgtest.a
GMOCKLIB = gmock/libgmock.a

# Allow user-system overrides
INCLUDE += -I /usr/local/include
LDLIBS += -L /usr/local/lib

CXXFLAGS = $(INCLUDE) $(CXXFLAG) $(LOCAL_CXXFLAGS)

# These tests will be built and run automatically.
TESTS = \
	log/database_test \
	log/file_storage_test \
	log/frontend_signer_test \
	log/log_lookup_test \
	log/log_signer_test \
	log/logged_certificate_test \
	log/signer_verifier_test \
	log/tree_signer_test \
	merkletree/merkle_tree_test \
	merkletree/serial_hasher_test \
	merkletree/tree_hasher_test \
	monitor/database_test \
	proto/serializer_test \
	util/json_wrapper_test

# These tests will be built, but not run.
DISABLED_TESTS = \
	log/database_large_test \
	merkletree/merkle_tree_large_test

# These tests are built, but need specific flags, so you should add
# them to the end of the "test" target commands.
# TODO(pphaneuf): We should try to make those tests "just work", and
# move them to TESTS with the others.
EXTRA_TESTS = \
	log/cert_checker_test \
	log/cert_submission_handler_test \
	log/cert_test \
	log/ct_extensions_test \
	log/frontend_test

all: client/ct server/ct-server server/ct-dns-server tools/dump_cert \
     tools/dump_sth

tests: all $(TESTS) $(DISABLED_TESTS) $(EXTRA_TESTS)

.DELETE_ON_ERROR:

.PHONY: clean all test tests alltests benchmark clean

gmock/Makefile: $(GMOCKDIR)
	mkdir -p gmock && cd gmock && cmake $(GMOCKDIR)

gmock/libgmock.a: gmock/Makefile
	$(MAKE) -C gmock CPPFLAGS="$(CPPFLAGS)" CXXFLAGS="$(CXXFLAGS)" \
	  LDFLAGS="$(LDFLAGS)"

gmock/gtest/libgtest.a: gmock/libgmock.a

%/.depend: %/*.cc */*.h
	$(CXX) $(CXXFLAGS) -MM -MG $(filter %.cc,$^) | sed 's,\(.*\)\.o,$(@D)/\1.o,' >$(@).tmp
	mv $(@).tmp $@

### proto preprocessing
proto/%.pb.h proto/%.pb.cc: ../proto/%.proto
	protoc -I .. $^ --cpp_out=.

ifneq ($(MAKECMDGOALS),clean)
    include client/.depend
    include log/.depend
    include merkletree/.depend
    include monitor/.depend
    include proto/.depend
    include server/.depend
    include tools/.depend
    include util/.depend
endif

### util/ targets
util/libutil.a: util/util.o util/openssl_util.o util/testing.o \
                util/json_wrapper.o util/thread_pool.o util/libevent_wrapper.o
{'fraction_non_alphanumeric': 0.14485854189336236, 'fraction_numerical': 0.0024483133841131663, 'mean_word_length': 3.552941176470588, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6145971', 'n_tokens_mistral': 2897, 'n_tokens_neox': 2797, 'n_words': 624}