<commit_before>TOP=$(shell pwd)/../..

LLVM_LINK_FLAGS = \
  -L/usr/local/lib \
  -lpthread \
  -lm \
  -lLLVMMCDisassembler \
  -lLLVMXCoreCodeGen \
  -lLLVMXCoreInfo \
  -lLLVMLinker \
  -lLLVMipo \
  -lLLVMInterpreter \
  -lLLVMInstrumentation \
  -lLLVMJIT \
  -lLLVMExecutionEngine \
  -lLLVMCppBackendInfo \
  -lLLVMBitWriter \
  -lLLVMX86Disassembler \
  -lLLVMX86AsmParser \
  -lLLVMX86CodeGen \
  -lLLVMX86AsmPrinter \
  -lLLVMX86Info \
  -lLLVMAsmParser \
  -lLLVMARMDisassembler \
  -lLLVMARMAsmParser \
  -lLLVMARMCodeGen \
  -lLLVMARMAsmPrinter \
  -lLLVMARMInfo \
  -lLLVMArchive \
  -lLLVMBitReader \
  -lLLVMSelectionDAG \
  -lLLVMAsmPrinter \
  -lLLVMMCParser \
  -lLLVMCodeGen \
  -lLLVMScalarOpts \
  -lLLVMInstCombine \
  -lLLVMTransformUtils \
  -lLLVMipa \
  -lLLVMAnalysis \
  -lLLVMTarget \
  -lLLVMMC \
  -lLLVMCore \
  -lLLVMSupport

JS_SOURCES=$(filter-out ejs.js,$(wildcard *.js))
EXTRA_JS_SOURCES= ../../esprima/esprima.js ../../escodegen/escodegen.js ../../estraverse/estraverse.js

bootstrap:
	@$(MAKE) make-stage1 || exit 1
	@cp ejs.js.exe ../../ejs.js.exe.stage1
	@mv ejs.js.exe ../..
	@$(MAKE) make-stage2 || exit 1
	@cp ejs.js.exe ../../ejs.js.exe.stage2
	@mv ejs.js.exe ../..
	@$(MAKE) make-stage3 || exit 1
	@cp ejs.js.exe ../../ejs.js.exe.stage3
	@mv ejs.js.exe ../..
	@echo "done, woohoo"

make-stage1: $(wildcard *.js) ejs.js
	@echo "****************************************************"
	@echo "****************************************************"
	@echo "Building stage 1 (compiling ejs-ejs with ejs-nodejs)"
	@echo "****************************************************"
	@echo "****************************************************"
	@$(MAKE) -C ..
	time NODE_PATH=$(TOP)/node-llvm/build/Release:$(TOP)/lib/generated:$(TOP)/esprima:$(TOP)/escodegen:$(TOP)/estraverse ../../ejs --record-types --leave-temp --module "../../ejs-llvm/libejsllvm-module.a,llvm,_ejs_llvm_init,$(LLVM_LINK_FLAGS)" ejs.js $(JS_SOURCES) $(EXTRA_JS_SOURCES)

make-stage2: $(wildcard *.js) ejs.js
	@echo "****************************************************"
	@echo "****************************************************"
	@echo "Building stage 2 (compiling ejs-ejs with ejs-ejs)"
	@echo "****************************************************"
	@echo "****************************************************"
	@$(MAKE) -C ..
	time `pwd`/../../ejs.js.exe --leave-temp --module "../../ejs-llvm/libejsllvm-module.a,llvm,_ejs_llvm_init,$(LLVM_LINK_FLAGS)" ejs.js $(JS_SOURCES) $(EXTRA_JS_SOURCES)

make-stage3: $(wildcard *.js) ejs.js
	@echo "****************************************************"
	@echo "****************************************************"
	@echo "Building stage 3 (compiling ejs-ejs with ejs-ejs)"
	@echo "****************************************************"
	@echo "****************************************************"
	@$(MAKE) -C ..
	time `pwd`/../../ejs.js.exe --leave-temp --module "../../ejs-llvm/libejsllvm-module.a,llvm,_ejs_llvm_init,$(LLVM_LINK_FLAGS)" ejs.js $(JS_SOURCES) $(EXTRA_JS_SOURCES)

ejs.coffee: ../../ejs
	@cp ../../ejs ejs.coffee
<commit_msg>use llvm-config, and use gmake functions to add as many bootstrap steps as we want.<commit_after>TOP=$(shell pwd)/../..

include $(TOP)/build/config.mk

LLVM_LINK_FLAGS = $(shell llvm-config$(LLVM_SUFFIX) --ldflags --libs)

JS_SOURCES=$(filter-out ejs.js,$(wildcard *.js))
EXTRA_JS_SOURCES= ../../esprima/esprima.js ../../escodegen/escodegen.js ../../estraverse/estraverse.js

make-stage1: $(wildcard *.js) ejs.js
	@echo "****************************************************"
	@echo "****************************************************"
	@echo "Building stage $(1)"
	@echo "****************************************************"
	@echo "****************************************************"
	@$(MAKE) -C ..
	time NODE_PATH=$(TOP)/node-llvm/build/Release:$(TOP)/lib/generated:$(TOP)/esprima:$(TOP)/escodegen:$(TOP)/estraverse ../../ejs --leave-temp --module "../../ejs-llvm/libejsllvm-module.a,llvm,_ejs_llvm_init,$(LLVM_LINK_FLAGS)" ejs.js $(JS_SOURCES) $(EXTRA_JS_SOURCES)

bootstrap::
	@$(MAKE) make-stage1 || exit 1
	@cp ejs.js.exe ../../ejs.js.exe.stage1
	@mv ejs.js.exe ../..

stages := $(shell seq 2 3)

define stage_template
make-stage$(1): $(wildcard *.js) ejs.js
	@echo "****************************************************"
	@echo "****************************************************"
	@echo "Building stage $(1)"
	@echo "****************************************************"
	@echo "****************************************************"
	@$(MAKE) -C ..
	time NODE_PATH=$(TOP)/node-llvm/build/Release:$(TOP)/lib/generated:$(TOP)/esprima:$(TOP)/escodegen:$(TOP)/estraverse ../../ejs.js.exe --leave-temp --module "../../ejs-llvm/libejsllvm-module.a,llvm,_ejs_llvm_init,$(LLVM_LINK_FLAGS)" ejs.js $(JS_SOURCES) $(EXTRA_JS_SOURCES)

bootstrap::
	@$(MAKE) make-stage$(1) || exit 1
	@cp ejs.js.exe ../../ejs.js.exe.stage$(1)
	@mv ejs.js.exe ../..
endef

bootstrap::

$(foreach stage,$(stages),$(eval $(call stage_template,$(stage))))

bootstrap::
	@echo "done, woohoo"

ejs.coffee: ../../ejs
	@cp ../../ejs ejs.coffee

{'fraction_non_alphanumeric': 0.3735340109460516, 'fraction_numerical': 0.007232212666145426, 'mean_word_length': 4.210794297352342, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5863433', 'n_tokens_mistral': 1965, 'n_tokens_neox': 1850, 'n_words': 284}