<commit_before>
PROJECT_VERSION ?= 99.70
R_VERSION = 3.0
REPO_PATH_WIN = bin/windows/contrib/$(R_VERSION)
REPO_PATH_MAC = bin/macosx/contrib/$(R_VERSION)
TMP_BUILD_DIR = tmp_build
ifneq ($(OS),Windows_NT)
OS := $(shell uname)
else
# For windows NT the shell is odd.  Cygwin 'shell uname' returns CYGWIN_NT-6.1-WOW64
# which is not really what we want.  The normal CMD shell does something else.
# So don't ask for 'uname' if we already got Windows_NT
endif

H2O_WRAPPER_SOURCE_FILE = h2o_$(PROJECT_VERSION).tar.gz
H2O_WRAPPER_LINUX_FILE = h2o_$(PROJECT_VERSION)_R_x86_64-pc-linux-gnu.tar.gz
H2O_WRAPPER_MAC_FILE = h2o_$(PROJECT_VERSION).tgz
H2O_WRAPPER_WINDOWS_FILE = h2o_$(PROJECT_VERSION).zip

H2O_RCLIENT_SOURCE_FILE = h2oRClient_$(PROJECT_VERSION).tar.gz
H2O_RCLIENT_LINUX_FILE = h2oRClient_$(PROJECT_VERSION)_R_x86_64-pc-linux-gnu.tar.gz
H2O_RCLIENT_MAC_FILE = h2oRClient_$(PROJECT_VERSION).tgz
H2O_RCLIENT_WINDOWS_FILE = h2oRClient_$(PROJECT_VERSION).zip

ifeq ($(OS),Linux)
H2O_RCLIENT_PKG_FILE = $(H2O_RCLIENT_LINUX_FILE)
H2O_WRAPPER_PKG_FILE = $(H2O_WRAPPER_LINUX_FILE)
endif
ifeq ($(OS),Darwin)
H2O_RCLIENT_PKG_FILE = $(H2O_RCLIENT_MAC_FILE)
H2O_WRAPPER_PKG_FILE = $(H2O_WRAPPER_MAC_FILE)
endif
ifeq ($(OS),Windows_NT)
H2O_RCLIENT_PKG_FILE = $(H2O_RCLIENT_WINDOWS_FILE)
H2O_WRAPPER_PKG_FILE = $(H2O_WRAPPER_WINDOWS_FILE)
endif

# Do a best-effort attempt to see if the R user has pdflatex installed
# and avoid running it if they don't.
#
# But use the '-' to ignore failures and continue the build even if it does fail.
PDFLATEX=$(shell which pdflatex)

build_outer:
	sed 's/SUBST_PROJECT_VERSION/$(PROJECT_VERSION)/' h2o-DESCRIPTION.template > h2o-package/DESCRIPTION
	sed 's/SUBST_PROJECT_VERSION/$(PROJECT_VERSION)/' h2o-package.template > h2o-package/man/h2o-package.Rd
ifeq ($(PDFLATEX),)
	@echo pdflatex not found, skipping pdf generation...
else
	-R CMD Rd2pdf --force --output="h2o-package/h2o_package.pdf" --title="Package 'h2o'" --no-index --no-preview h2o-package/man 1> /dev/null
endif
	mkdir -p h2o-package/inst/java/
	cp -f ../target/h2o.jar h2o-package/inst/java/h2o.jar
	R CMD build h2o-package

	# Create file with description of all packages
	cp -p h2o-package/DESCRIPTION PACKAGES
	gzip -c PACKAGES > PACKAGES.gz

	# Add to repo in target directory
	mkdir -p ../target/R/src/contrib
	cp -p README.txt ../target/R
	mv $(H2O_WRAPPER_SOURCE_FILE) ../target/R/src/contrib
	cp -p PACKAGES PACKAGES.gz ../target/R/src/contrib

	# Build binary for each OS
	rm -rf $(TMP_BUILD_DIR)
	mkdir -p $(TMP_BUILD_DIR)
	R CMD INSTALL -l $(TMP_BUILD_DIR) --build h2o-package

ifneq ($(OS),Windows_NT)
	rm -rf h2o
	tar zxvf $(H2O_WRAPPER_PKG_FILE)
	zip -r $(H2O_WRAPPER_WINDOWS_FILE) h2o

	# Create repo subdirectory for MacOSX
	mkdir -p ../target/R/$(REPO_PATH_MAC)
	mv $(H2O_WRAPPER_PKG_FILE) ../target/R/$(REPO_PATH_MAC)/$(H2O_WRAPPER_MAC_FILE)
	cp -p PACKAGES PACKAGES.gz ../target/R/$(REPO_PATH_MAC)

	rm -rf ../target/R/bin/macosx/contrib/2.15 ../target/R/bin/macosx/contrib/2.14 ../target/R/bin/macosx/contrib/2.13
	cp -r ../target/R/$(REPO_PATH_MAC) ../target/R/bin/macosx/contrib/2.15
	cp -r ../target/R/$(REPO_PATH_MAC) ../target/R/bin/macosx/contrib/2.14 
	cp -r ../target/R/$(REPO_PATH_MAC) ../target/R/bin/macosx/contrib/2.13
endif

	# Create repo subdirectory for Windows
	mkdir -p ../target/R/$(REPO_PATH_WIN)
	mv $(H2O_WRAPPER_WINDOWS_FILE) ../target/R/$(REPO_PATH_WIN)
	mv PACKAGES PACKAGES.gz ../target/R/$(REPO_PATH_WIN)

	rm -rf ../target/R/bin/windows/contrib/2.15 ../target/R/bin/windows/contrib/2.14 ../target/R/bin/windows/contrib/2.13
	cp -r ../target/R/$(REPO_PATH_WIN) ../target/R/bin/windows/contrib/2.15
	cp -r ../target/R/$(REPO_PATH_WIN) ../target/R/bin/windows/contrib/2.14 
	cp -r ../target/R/$(REPO_PATH_WIN) ../target/R/bin/windows/contrib/2.13

	R CMD REMOVE -l $(TMP_BUILD_DIR) h2o
	rm -rf $(TMP_BUILD_DIR)

build_inner:
	sed 's/SUBST_PROJECT_VERSION/$(PROJECT_VERSION)/' h2oRClient-DESCRIPTION.template > h2oRClient-package/DESCRIPTION
	sed 's/SUBST_PROJECT_VERSION/$(PROJECT_VERSION)/' h2oRClient-package.template > h2oRClient-package/man/h2oRClient-package.Rd
ifeq ($(PDFLATEX),)
	@echo pdflatex not found, skipping pdf generation...
else
	-R CMD Rd2pdf --force --output="h2oRClient-package/h2oRClient_package.pdf" --title="Package 'h2oRClient'" --no-index --no-preview h2oRClient-package/man 1> /dev/null
endif
	R CMD build h2oRClient-package
	echo h2oRClient_$(PROJECT_VERSION).tar.gz > info.txt
ifeq ($(OS),Windows_NT)
	md5deep h2oRClient_$(PROJECT_VERSION).tar.gz | cut -d' ' -f1 >> info.txt
else
	openssl md5 h2oRClient_$(PROJECT_VERSION).tar.gz | sed 's/.*= //' >> info.txt
endif

	# Create file with description of all packages
	cp -p h2oRClient-package/DESCRIPTION PACKAGES
	gzip -c PACKAGES > PACKAGES.gz

	# Add to resources directory
	mkdir -p ../lib/resources/R/src/contrib
	mv info.txt ../lib/resources/R/info.txt
	mv $(H2O_RCLIENT_SOURCE_FILE) ../lib/resources/R/src/contrib
	cp -p PACKAGES PACKAGES.gz ../lib/resources/R/src/contrib

	# Build binary for each OS
	rm -rf $(TMP_BUILD_DIR)
	mkdir -p $(TMP_BUILD_DIR)
	R CMD INSTALL -l $(TMP_BUILD_DIR) --build h2oRClient-package

ifneq ($(OS),Windows_NT)
	rm -rf h2oRClient
	tar zxvf $(H2O_RCLIENT_PKG_FILE)
	zip -r $(H2O_RCLIENT_WINDOWS_FILE) h2oRClient

	# Create repo subdirectory for MacOSX
	mkdir -p ../lib/resources/R/$(REPO_PATH_MAC)
	mv $(H2O_RCLIENT_PKG_FILE) ../lib/resources/R/$(REPO_PATH_MAC)/$(H2O_RCLIENT_MAC_FILE)
	cp -p PACKAGES PACKAGES.gz ../lib/resources/R/$(REPO_PATH_MAC)
endif

	# Create repo subdirectory for Windows
	mkdir -p ../lib/resources/R/$(REPO_PATH_WIN)
	mv $(H2O_RCLIENT_WINDOWS_FILE) ../lib/resources/R/$(REPO_PATH_WIN)
	mv PACKAGES PACKAGES.gz ../lib/resources/R/$(REPO_PATH_WIN)

	# Create temporary directory for jarring later
	mkdir -p ../r_pack_tmp/resources
	cp -r ../lib/resources/R ../r_pack_tmp/resources

	R CMD REMOVE -l $(TMP_BUILD_DIR) h2oRClient
	rm -rf $(TMP_BUILD_DIR)

clean:
	rm -f h2oRClient-package/DESCRIPTION
	rm -f h2oRClient-package/h2oRClient_package.pdf
	rm -f h2oRClient-package/man/h2oRClient-package.Rd
	rm -f h2oRClient_*.tar.gz
	rm -f h2oRClient_*.tgz
	rm -f h2oRClient_*.zip
	rm -f h2o-package/DESCRIPTION
	rm -f h2o-package/h2o_package.pdf
	rm -f h2o-package/man/h2o-package.Rd
	rm -f h2o-package/inst/java/h2o.jar
	rm -f h2o_*.tar.gz
	rm -f h2o_*.tgz
	rm -f h2o_*.zip
	rm -rf ../lib/resources/R<commit_msg>Modify make to work on 32-bit Linux OS<commit_after>
PROJECT_VERSION ?= 99.70
R_VERSION = 3.0
REPO_PATH_WIN = bin/windows/contrib/$(R_VERSION)
REPO_PATH_MAC = bin/macosx/contrib/$(R_VERSION)
TMP_BUILD_DIR = tmp_build
ifneq ($(OS),Windows_NT)
OS := $(shell uname)
else
# For windows NT the shell is odd.  Cygwin 'shell uname' returns CYGWIN_NT-6.1-WOW64
# which is not really what we want.  The normal CMD shell does something else.
# So don't ask for 'uname' if we already got Windows_NT
endif

H2O_WRAPPER_SOURCE_FILE = h2o_$(PROJECT_VERSION).tar.gz
H2O_WRAPPER_LINUX_FILE = h2o_$(PROJECT_VERSION)_R_$(UNAME_P)-pc-linux-gnu.tar.gz
H2O_WRAPPER_MAC_FILE = h2o_$(PROJECT_VERSION).tgz
H2O_WRAPPER_WINDOWS_FILE = h2o_$(PROJECT_VERSION).zip

H2O_RCLIENT_SOURCE_FILE = h2oRClient_$(PROJECT_VERSION).tar.gz
H2O_RCLIENT_LINUX_FILE = h2oRClient_$(PROJECT_VERSION)_R_$(UNAME_P)-pc-linux-gnu.tar.gz
H2O_RCLIENT_MAC_FILE = h2oRClient_$(PROJECT_VERSION).tgz
H2O_RCLIENT_WINDOWS_FILE = h2oRClient_$(PROJECT_VERSION).zip

ifeq ($(OS),Linux)
H2O_RCLIENT_PKG_FILE = $(H2O_RCLIENT_LINUX_FILE)
H2O_WRAPPER_PKG_FILE = $(H2O_WRAPPER_LINUX_FILE)
endif
ifeq ($(OS),Darwin)
H2O_RCLIENT_PKG_FILE = $(H2O_RCLIENT_MAC_FILE)
H2O_WRAPPER_PKG_FILE = $(H2O_WRAPPER_MAC_FILE)
endif
ifeq ($(OS),Windows_NT)
H2O_RCLIENT_PKG_FILE = $(H2O_RCLIENT_WINDOWS_FILE)
H2O_WRAPPER_PKG_FILE = $(H2O_WRAPPER_WINDOWS_FILE)
endif

# Do a best-effort attempt to see if the R user has pdflatex installed
# and avoid running it if they don't.
#
# But use the '-' to ignore failures and continue the build even if it does fail.
PDFLATEX=$(shell which pdflatex)

build_outer:
	sed 's/SUBST_PROJECT_VERSION/$(PROJECT_VERSION)/' h2o-DESCRIPTION.template > h2o-package/DESCRIPTION
	sed 's/SUBST_PROJECT_VERSION/$(PROJECT_VERSION)/' h2o-package.template > h2o-package/man/h2o-package.Rd
ifeq ($(PDFLATEX),)
	@echo pdflatex not found, skipping pdf generation...
else
	-R CMD Rd2pdf --force --output="h2o-package/h2o_package.pdf" --title="Package 'h2o'" --no-index --no-preview h2o-package/man 1> /dev/null
endif
	mkdir -p h2o-package/inst/java/
	cp -f ../target/h2o.jar h2o-package/inst/java/h2o.jar
	R CMD build h2o-package

	# Create file with description of all packages
	cp -p h2o-package/DESCRIPTION PACKAGES
	gzip -c PACKAGES > PACKAGES.gz

	# Add to repo in target directory
	mkdir -p ../target/R/src/contrib
	cp -p README.txt ../target/R
	mv $(H2O_WRAPPER_SOURCE_FILE) ../target/R/src/contrib
	cp -p PACKAGES PACKAGES.gz ../target/R/src/contrib

	# Build binary for each OS
	rm -rf $(TMP_BUILD_DIR)
	mkdir -p $(TMP_BUILD_DIR)
	R CMD INSTALL -l $(TMP_BUILD_DIR) --build h2o-package

ifneq ($(OS),Windows_NT)
	# rm -rf h2o
	tar zxvf $(H2O_WRAPPER_PKG_FILE)
	zip -r $(H2O_WRAPPER_WINDOWS_FILE) h2o
	rm -rf h2o

	# Create repo subdirectory for MacOSX
	mkdir -p ../target/R/$(REPO_PATH_MAC)
	mv $(H2O_WRAPPER_PKG_FILE) ../target/R/$(REPO_PATH_MAC)/$(H2O_WRAPPER_MAC_FILE)
	cp -p PACKAGES PACKAGES.gz ../target/R/$(REPO_PATH_MAC)

	rm -rf ../target/R/bin/macosx/contrib/2.15 ../target/R/bin/macosx/contrib/2.14 ../target/R/bin/macosx/contrib/2.13
	cp -r ../target/R/$(REPO_PATH_MAC) ../target/R/bin/macosx/contrib/2.15
	cp -r ../target/R/$(REPO_PATH_MAC) ../target/R/bin/macosx/contrib/2.14 
	cp -r ../target/R/$(REPO_PATH_MAC) ../target/R/bin/macosx/contrib/2.13
endif

	# Create repo subdirectory for Windows
	mkdir -p ../target/R/$(REPO_PATH_WIN)
	mv $(H2O_WRAPPER_WINDOWS_FILE) ../target/R/$(REPO_PATH_WIN)
	mv PACKAGES PACKAGES.gz ../target/R/$(REPO_PATH_WIN)

	rm -rf ../target/R/bin/windows/contrib/2.15 ../target/R/bin/windows/contrib/2.14 ../target/R/bin/windows/contrib/2.13
	cp -r ../target/R/$(REPO_PATH_WIN) ../target/R/bin/windows/contrib/2.15
	cp -r ../target/R/$(REPO_PATH_WIN) ../target/R/bin/windows/contrib/2.14 
	cp -r ../target/R/$(REPO_PATH_WIN) ../target/R/bin/windows/contrib/2.13

	R CMD REMOVE -l $(TMP_BUILD_DIR) h2o
	rm -rf $(TMP_BUILD_DIR)

build_inner:
	sed 's/SUBST_PROJECT_VERSION/$(PROJECT_VERSION)/' h2oRClient-DESCRIPTION.template > h2oRClient-package/DESCRIPTION
	sed 's/SUBST_PROJECT_VERSION/$(PROJECT_VERSION)/' h2oRClient-package.template > h2oRClient-package/man/h2oRClient-package.Rd
ifeq ($(PDFLATEX),)
	@echo pdflatex not found, skipping pdf generation...
else
	-R CMD Rd2pdf --force --output="h2oRClient-package/h2oRClient_package.pdf" --title="Package 'h2oRClient'" --no-index --no-preview h2oRClient-package/man 1> /dev/null
endif
	R CMD build h2oRClient-package
	echo h2oRClient_$(PROJECT_VERSION).tar.gz > info.txt
ifeq ($(OS),Windows_NT)
	md5deep h2oRClient_$(PROJECT_VERSION).tar.gz | cut -d' ' -f1 >> info.txt
else
	openssl md5 h2oRClient_$(PROJECT_VERSION).tar.gz | sed 's/.*= //' >> info.txt
endif

	# Create file with description of all packages
	cp -p h2oRClient-package/DESCRIPTION PACKAGES
	gzip -c PACKAGES > PACKAGES.gz

	# Add to resources directory
	mkdir -p ../lib/resources/R/src/contrib
	mv info.txt ../lib/resources/R/info.txt
	mv $(H2O_RCLIENT_SOURCE_FILE) ../lib/resources/R/src/contrib
	cp -p PACKAGES PACKAGES.gz ../lib/resources/R/src/contrib

	# Build binary for each OS
	rm -rf $(TMP_BUILD_DIR)
	mkdir -p $(TMP_BUILD_DIR)
	R CMD INSTALL -l $(TMP_BUILD_DIR) --build h2oRClient-package

ifneq ($(OS),Windows_NT)
	# rm -rf h2oRClient
	tar zxvf $(H2O_RCLIENT_PKG_FILE)
	zip -r $(H2O_RCLIENT_WINDOWS_FILE) h2oRClient
	rm -rf h2oRClient

	# Create repo subdirectory for MacOSX
	mkdir -p ../lib/resources/R/$(REPO_PATH_MAC)
	mv $(H2O_RCLIENT_PKG_FILE) ../lib/resources/R/$(REPO_PATH_MAC)/$(H2O_RCLIENT_MAC_FILE)
	cp -p PACKAGES PACKAGES.gz ../lib/resources/R/$(REPO_PATH_MAC)
endif

	# Create repo subdirectory for Windows
	mkdir -p ../lib/resources/R/$(REPO_PATH_WIN)
	mv $(H2O_RCLIENT_WINDOWS_FILE) ../lib/resources/R/$(REPO_PATH_WIN)
	mv PACKAGES PACKAGES.gz ../lib/resources/R/$(REPO_PATH_WIN)

	# Create temporary directory for jarring later
	mkdir -p ../r_pack_tmp/resources
	cp -r ../lib/resources/R ../r_pack_tmp/resources

	R CMD REMOVE -l $(TMP_BUILD_DIR) h2oRClient
	rm -rf $(TMP_BUILD_DIR)

clean:
	rm -f h2oRClient-package/DESCRIPTION
	rm -f h2oRClient-package/h2oRClient_package.pdf
	rm -f h2oRClient-package/man/h2oRClient-package.Rd
	rm -f h2oRClient_*.tar.gz
	rm -f h2oRClient_*.tgz
	rm -f h2oRClient_*.zip
	rm -f h2o-package/DESCRIPTION
	rm -f h2o-package/h2o_package.pdf
	rm -f h2o-package/man/h2o-package.Rd
	rm -f h2o-package/inst/java/h2o.jar
	rm -f h2o_*.tar.gz
	rm -f h2o_*.tgz
	rm -f h2o_*.zip
	rm -rf ../lib/resources/R
	rm -rf h2o
	rm -rf h2oRClient
{'fraction_non_alphanumeric': 0.13899463911118018, 'fraction_numerical': 0.024085152668790303, 'mean_word_length': 4.184051550543697, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, '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': '2785768', 'n_tokens_mistral': 5705, 'n_tokens_neox': 5474, 'n_words': 1074}