<commit_before>
ROOT_DIR := .

CC := gcc
CFLAGS := -std=gnu99
LIBCO_VER := libco
# Use sjlj for clang on x86

#CFLAGS += -arch i386
CFLAGS += -g -O2 -Wno-unused-result
#CFLAGS += -g -O0
#CFLAGS += -DNDEBUG -Wno-unused-but-set-variable
CFLAGS += -DSQLITE_DEBUG -DHTTP_PARSER_DEBUG
#CFLAGS += -DSQLITE_ENABLE_SQLLOG

BUILD_DIR := $(ROOT_DIR)/build
SRC_DIR := $(ROOT_DIR)/src
DEPS_DIR := $(ROOT_DIR)/deps

# TODO: Isn't there a way to have it find everything automatically?

HEADERS := \
	$(SRC_DIR)/common.h \
	$(SRC_DIR)/async.h \
	$(SRC_DIR)/bcrypt.h \
	$(SRC_DIR)/EarthFS.h \
	$(SRC_DIR)/URIList.h \
	$(SRC_DIR)/Template.h \
	$(SRC_DIR)/sqlite3f.h \
	$(SRC_DIR)/strndup.h \
	$(SRC_DIR)/http/status.h \
	$(SRC_DIR)/http/Headers.h \
	$(SRC_DIR)/http/HTTPMessage.h \
	$(SRC_DIR)/http/HTTPServer.h \
	$(SRC_DIR)/http/MultipartForm.h \
	$(SRC_DIR)/http/QueryString.h \
	$(DEPS_DIR)/libco/libco.h \
	$(DEPS_DIR)/crypt_blowfish-1.0.4/ow-crypt.h \
	$(DEPS_DIR)/http_parser/http_parser.h \
	$(DEPS_DIR)/multipart-parser-c/multipart_parser.h \
	$(DEPS_DIR)/sqlite/sqlite3.h

OBJECTS := \
	$(BUILD_DIR)/main.o \
	$(BUILD_DIR)/EFSRepo.o \
	$(BUILD_DIR)/EFSSession.o \
	$(BUILD_DIR)/EFSSubmission.o \
	$(BUILD_DIR)/EFSHasher.o \
	$(BUILD_DIR)/EFSMetaFile.o \
	$(BUILD_DIR)/EFSFilter.o \
	$(BUILD_DIR)/EFSJSONFilterParser.o \
	$(BUILD_DIR)/EFSUserFilterParser.o \
	$(BUILD_DIR)/EFSPull.o \
	$(BUILD_DIR)/EFSServer.o \
	$(BUILD_DIR)/Template.o \
	$(BUILD_DIR)/URIList.o \
	$(BUILD_DIR)/sqlite3f.o \
	$(BUILD_DIR)/strndup.o \
	$(BUILD_DIR)/async.o \
	$(BUILD_DIR)/async_fs.o \
	$(BUILD_DIR)/async_mutex.o \
	$(BUILD_DIR)/async_rwlock.o \
	$(BUILD_DIR)/async_sqlite.o \
	$(BUILD_DIR)/bcrypt.o \
	$(BUILD_DIR)/http/Headers.o \
	$(BUILD_DIR)/http/HTTPMessage.o \
	$(BUILD_DIR)/http/HTTPServer.o \
	$(BUILD_DIR)/http/MultipartForm.o \
	$(BUILD_DIR)/http/QueryString.o \
	$(BUILD_DIR)/crypt/crypt_blowfish.o \
	$(BUILD_DIR)/crypt/crypt_gensalt.o \
	$(BUILD_DIR)/crypt/wrapper.o \
	$(BUILD_DIR)/crypt/x86.S.o \
	$(BUILD_DIR)/http_parser.o \
	$(BUILD_DIR)/multipart_parser.o \
	$(BUILD_DIR)/sqlite/sqlite3.o

OBJECTS += $(BUILD_DIR)/libco/$(LIBCO_VER).o
#HEADERS += $(DEPS_DIR)/libcoro/coro.h
#OBJECTS += $(BUILD_DIR)/libcoro/coro.o $(BUILD_DIR)/libco_coro.o
#CFLAGS += -DCORO_USE_VALGRIND

# DEBUG
#OBJECTS += \
#	$(BUILD_DIR)/sqlite/test_sqllog.o

OBJECTS += \
	$(BUILD_DIR)/Blog.o

TEST_OBJECTS := \
	$(BUILD_DIR)/async.o \
	$(BUILD_DIR)/sqlite_async.o \
	$(BUILD_DIR)/libco.o \
	$(BUILD_DIR)/sqlite3.o

LIBUV_DIR := $(DEPS_DIR)/uv/out/Debug/obj.target
#LIBUV_DIR := $(DEPS_DIR)/uv/build/Release

LIBS := -luv -lcrypto -lyajl -lpthread
LIBS += -lrt

.DEFAULT_GOAL := all

.PHONY: all
all: $(BUILD_DIR)/earthfs

.PHONY: libuv
libuv:
	@ cd $(DEPS_DIR)/uv && ./gyp_uv.py -f make -Dtarget_arch=i686 > /dev/null
	@ make -C $(DEPS_DIR)/uv/out -s

$(BUILD_DIR)/earthfs: $(OBJECTS) | libuv
	@- mkdir -p $(dir $@)
	$(CC) -o $@ $(OBJECTS) $(CFLAGS) -L$(LIBUV_DIR) $(LIBS)

$(BUILD_DIR)/crypt/%.S.o: $(DEPS_DIR)/crypt_blowfish-1.0.4/%.S<commit_msg>Another approach to building libuv, because order-only prereqs suck.<commit_after>
ROOT_DIR := .

CC := gcc
CFLAGS := -std=gnu99
LIBCO_VER := libco
# Use sjlj for clang on x86

#CFLAGS += -arch i386
CFLAGS += -g -O2 -Wno-unused-result
#CFLAGS += -g -O0
#CFLAGS += -DNDEBUG -Wno-unused-but-set-variable
CFLAGS += -DSQLITE_DEBUG -DHTTP_PARSER_DEBUG
#CFLAGS += -DSQLITE_ENABLE_SQLLOG

BUILD_DIR := $(ROOT_DIR)/build
SRC_DIR := $(ROOT_DIR)/src
DEPS_DIR := $(ROOT_DIR)/deps

# TODO: Isn't there a way to have it find everything automatically?

HEADERS := \
	$(SRC_DIR)/common.h \
	$(SRC_DIR)/async.h \
	$(SRC_DIR)/bcrypt.h \
	$(SRC_DIR)/EarthFS.h \
	$(SRC_DIR)/URIList.h \
	$(SRC_DIR)/Template.h \
	$(SRC_DIR)/sqlite3f.h \
	$(SRC_DIR)/strndup.h \
	$(SRC_DIR)/http/status.h \
	$(SRC_DIR)/http/Headers.h \
	$(SRC_DIR)/http/HTTPMessage.h \
	$(SRC_DIR)/http/HTTPServer.h \
	$(SRC_DIR)/http/MultipartForm.h \
	$(SRC_DIR)/http/QueryString.h \
	$(DEPS_DIR)/libco/libco.h \
	$(DEPS_DIR)/crypt_blowfish-1.0.4/ow-crypt.h \
	$(DEPS_DIR)/http_parser/http_parser.h \
	$(DEPS_DIR)/multipart-parser-c/multipart_parser.h \
	$(DEPS_DIR)/sqlite/sqlite3.h

OBJECTS := \
	$(BUILD_DIR)/main.o \
	$(BUILD_DIR)/EFSRepo.o \
	$(BUILD_DIR)/EFSSession.o \
	$(BUILD_DIR)/EFSSubmission.o \
	$(BUILD_DIR)/EFSHasher.o \
	$(BUILD_DIR)/EFSMetaFile.o \
	$(BUILD_DIR)/EFSFilter.o \
	$(BUILD_DIR)/EFSJSONFilterParser.o \
	$(BUILD_DIR)/EFSUserFilterParser.o \
	$(BUILD_DIR)/EFSPull.o \
	$(BUILD_DIR)/EFSServer.o \
	$(BUILD_DIR)/Template.o \
	$(BUILD_DIR)/URIList.o \
	$(BUILD_DIR)/sqlite3f.o \
	$(BUILD_DIR)/strndup.o \
	$(BUILD_DIR)/async.o \
	$(BUILD_DIR)/async_fs.o \
	$(BUILD_DIR)/async_mutex.o \
	$(BUILD_DIR)/async_rwlock.o \
	$(BUILD_DIR)/async_sqlite.o \
	$(BUILD_DIR)/bcrypt.o \
	$(BUILD_DIR)/http/Headers.o \
	$(BUILD_DIR)/http/HTTPMessage.o \
	$(BUILD_DIR)/http/HTTPServer.o \
	$(BUILD_DIR)/http/MultipartForm.o \
	$(BUILD_DIR)/http/QueryString.o \
	$(BUILD_DIR)/crypt/crypt_blowfish.o \
	$(BUILD_DIR)/crypt/crypt_gensalt.o \
	$(BUILD_DIR)/crypt/wrapper.o \
	$(BUILD_DIR)/crypt/x86.S.o \
	$(BUILD_DIR)/http_parser.o \
	$(BUILD_DIR)/multipart_parser.o \
	$(BUILD_DIR)/sqlite/sqlite3.o

OBJECTS += $(BUILD_DIR)/libco/$(LIBCO_VER).o
#HEADERS += $(DEPS_DIR)/libcoro/coro.h
#OBJECTS += $(BUILD_DIR)/libcoro/coro.o $(BUILD_DIR)/libco_coro.o
#CFLAGS += -DCORO_USE_VALGRIND

# DEBUG
#OBJECTS += \
#	$(BUILD_DIR)/sqlite/test_sqllog.o

OBJECTS += \
	$(BUILD_DIR)/Blog.o

TEST_OBJECTS := \
	$(BUILD_DIR)/async.o \
	$(BUILD_DIR)/sqlite_async.o \
	$(BUILD_DIR)/libco.o \
	$(BUILD_DIR)/sqlite3.o

LIBUV_DIR := $(DEPS_DIR)/uv/out/Debug/obj.target
#LIBUV_DIR := $(DEPS_DIR)/uv/build/Release

LIBS := -luv -lcrypto -lyajl -lpthread
LIBS += -lrt

.DEFAULT_GOAL := all

.PHONY: all
all: $(BUILD_DIR)/earthfs

#.PHONY: libuv
#libuv:
#	@ cd $(DEPS_DIR)/uv && ./gyp_uv.py -f make -Dtarget_arch=i686 > /dev/null
#	@ make -C $(DEPS_DIR)/uv/out -s

$(LIBUV_DIR)/libuv.a: UNUSED := $(shell cd $(DEPS_DIR)/uv; ./gyp_uv.py -f make -Dtarget_arch=i686; make -C out)

$(BUILD_DIR)/earthfs: $(OBJECTS) $(LIBUV_DIR)/libuv.a
	@- mkdir -p $(dir $@)
	$(CC) -o $@ $(OBJECTS) $(CFLAGS) -L$(LIBUV_DIR) $(LIBS)

$(BUILD_DIR)/crypt/%.S.o: $(DEPS_DIR)/crypt_blowfish-1.0.4/%.S
{'fraction_non_alphanumeric': 0.20430798906928146, 'fraction_numerical': 0.008519530622086482, 'mean_word_length': 3.857142857142857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1899432', 'n_tokens_mistral': 2857, 'n_tokens_neox': 2803, 'n_words': 353}