<commit_before>## Variables {{{
SHELL   := /bin/bash
NODE    ?= nodejs
SEARCH  ?= opening_hours
VERBOSE ?= 1

## Data source variables {{{
OH_RELATED_TAGS ?= related_tags.txt
STATS_FOR_BOUNDARIES ?= stats_for_boundaries.txt

API_URL_TAGINFO  ?= https://taginfo.openstreetmap.org/api
API_URL_OVERPASS ?= https://overpass-api.de/api
# GnuTLS: A TLS warning alert has been received.
# GnuTLS: received alert [112]: The server name sent was not recognized

TMP_QUERY ?= ./tmp_query.op
OVERPASS_QUERY_KEY_FILTER_CMD ?= cat
OVERPASS_QUERY_TIMEOUT ?= 4000
# OVERPASS_QUERY_TIMEOUT ?= 1000
OVERPASS_QUERY_STOP_AFTER_TIME_HOUR ?= 11
# OVERPASS_QUERY_STOP_AFTER_TIME_HOUR ?= -1
## Stop the make process gracefully after 14:00. Intended for cron which start at night.
OVERPASS_QUERY_USE_REGEX ?= 0
# Using regular expressions for querying areas is still slow
# https://github.com/drolbr/Overpass-API/issues/59#issuecomment-54013988
# Benchmarks:
# 7:54.68: make WGET_OPTIONS='' export♡ISO3166-2♡DE-SL♡2015-04-09T00:00:00.json -B OVERPASS_QUERY_USE_REGEX=1
# 0:35.04: make WGET_OPTIONS='' export♡ISO3166-2♡DE-SL♡2015-04-09T00:00:00.json -B OVERPASS_QUERY_USE_REGEX=0
# The query without regular expressions also returns more results …
# Use the log feature of real_test.js for this.

REMOVE_DATA_AFTER_STATS_GEN ?= 1
# REMOVE_DATA_AFTER_STATS_GEN ?= 0
START_DATE ?= now
# START_DATE ?= now - 1 day
DAYS_INCREMENT ?= 1
HOURS_INCREMENT ?= 1
## }}}

WGET_OPTIONS ?= --no-verbose
MAKE_OPTIONS ?= --no-print-directory
## }}}

.PHONY: default
default: list

## help {{{
.PHONY: list
# https://stackoverflow.com/a/26339924/2239985
list:
	@echo "This Makefile has the following targets:"
	@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sed 's/^/    /'
## }}}

.PHONY: dependencies-get
dependencies-get:
	npm install

.PHONY: build
build: opening_hours.min.js

.PHONY: check
check: check-diff-all check-package.json

.PHONY: benchmark
benchmark: benchmark-opening_hours.min.js

README.html: README.md

.PHONY: release
release: package.json check qa-source-code qa-https-everywhere
	git status
	read continue
	editor package.json
	json -f package.json version
	read continue
	$(MAKE) $(MAKE_OPTIONS) check-package.json
	git commit --all --message="Released version $(json -f package.json version)."
	git tag --sign --local-user C505B5C93B0DB3D338A1B6005FE92C12EE88E1F0 "v$(json -f package.json version)"
	git push --follow-tags
	npm publish
	$(MAKE) $(MAKE_OPTIONS) publish-website-on-all-servers

.PHONY: clean
clean: osm-tag-data-rm
	rm --force *.min.js
	rm --force README.html
	rm --force taginfo_sources.json

.PHONY: osm-tag-data-rm
osm-tag-data-rm: osm-tag-data-taginfo-rm osm-tag-data-overpass-rm

## Publish {{{

.PHONY: publish-website-on-all-servers
publish-website-on-all-servers: publish-website-on-ypid.de publish-website-on-openingh.openstreetmap.de

.PHONY: publish-website-on-openingh.openstreetmap.de
publish-website-on-openingh.openstreetmap.de:
	ssh gauss.osm.de './update'

.PHONY: publish-website-on-ypid.de
publish-website-on-ypid.de:
	ssh osm@ypid.de './update'

## }}}

## command line programs {{{
.PHONY: run-regex_search
run-regex_search: export.$(SEARCH).json interactive_testing.js regex_search.py
	$(NODE) ./regex_search.py "$<"

.PHONY: run-interactive_testing
run-interactive_testing: interactive_testing.js
	$(NODE) "$<"
## }}}

## Source code QA {{{
.PHONY: qa-source-code qa-https-everywhere
qa-source-code:
	git ls-files | egrep '\.js$$' | xargs sed -i 's/\([^=!]\)==\([^=]\)/\1===\2/g;s/\([^=!]\)!=\([^=]\)/\1!==\2/g;'

qa-https-everywhere:
	git ls-files -z | xargs -0 sed -i 's#http://wiki.openstreetmap.org#https://wiki.openstreetmap.org#g;s#http://open.mapquestapi.com#https://open.mapquestapi.com#g;s#http://nominatim.openstreetmap.org#https://nominatim.openstreetmap.org#g;s#http://taginfo.openstreetmap.org#https://taginfo.openstreetmap.org#g;s#http://stackoverflow.com#https://stackoverflow.com#g;s#http://www.gnu.org/#https://www.gnu.org/#g;s#http://overpass-turbo.eu/#https://overpass-turbo.eu/#g;s#http://www.openstreetmap.org/#https://www.openstreetmap.org/#g;s#http://overpass-api.de/#https://overpass-api.de/#g;'
	git ls-files -z | xargs -0 sed -i 's#http://\(\w\+\).wikipedia.org#https://\1.wikipedia.org#g;'
	test -L index.html && git checkout index.html
	# ack 'http://'
## }}}

## software testing {{{

.PHONY: check-all
check-all: check-package.json check-test check-diff-all osm-tag-data-update-check

.PHONY: check-fast
check-fast: check-diff-en-opening_hours.js

.PHONY: check-diff-all
check-diff-all: check-diff check-diff-opening_hours.min.js
<commit_msg>TLS certificates for overpass-api.de mid not be officially signed.<commit_after>## Variables {{{
SHELL   := /bin/bash
NODE    ?= nodejs
SEARCH  ?= opening_hours
VERBOSE ?= 1

## Data source variables {{{
OH_RELATED_TAGS ?= related_tags.txt
STATS_FOR_BOUNDARIES ?= stats_for_boundaries.txt

API_URL_TAGINFO  ?= https://taginfo.openstreetmap.org/api
API_URL_OVERPASS ?= http://overpass-api.de/api
# GnuTLS: A TLS warning alert has been received.
# GnuTLS: received alert [112]: The server name sent was not recognized

TMP_QUERY ?= ./tmp_query.op
OVERPASS_QUERY_KEY_FILTER_CMD ?= cat
OVERPASS_QUERY_TIMEOUT ?= 4000
# OVERPASS_QUERY_TIMEOUT ?= 1000
OVERPASS_QUERY_STOP_AFTER_TIME_HOUR ?= 11
# OVERPASS_QUERY_STOP_AFTER_TIME_HOUR ?= -1
## Stop the make process gracefully after 14:00. Intended for cron which start at night.
OVERPASS_QUERY_USE_REGEX ?= 0
# Using regular expressions for querying areas is still slow
# https://github.com/drolbr/Overpass-API/issues/59#issuecomment-54013988
# Benchmarks:
# 7:54.68: make WGET_OPTIONS='' export♡ISO3166-2♡DE-SL♡2015-04-09T00:00:00.json -B OVERPASS_QUERY_USE_REGEX=1
# 0:35.04: make WGET_OPTIONS='' export♡ISO3166-2♡DE-SL♡2015-04-09T00:00:00.json -B OVERPASS_QUERY_USE_REGEX=0
# The query without regular expressions also returns more results …
# Use the log feature of real_test.js for this.

REMOVE_DATA_AFTER_STATS_GEN ?= 1
# REMOVE_DATA_AFTER_STATS_GEN ?= 0
START_DATE ?= now
# START_DATE ?= now - 1 day
DAYS_INCREMENT ?= 1
HOURS_INCREMENT ?= 1
## }}}

WGET_OPTIONS ?= --no-verbose
MAKE_OPTIONS ?= --no-print-directory
## }}}

.PHONY: default
default: list

## help {{{
.PHONY: list
# https://stackoverflow.com/a/26339924/2239985
list:
	@echo "This Makefile has the following targets:"
	@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | sed 's/^/    /'
## }}}

.PHONY: dependencies-get
dependencies-get:
	npm install

.PHONY: build
build: opening_hours.min.js

.PHONY: check
check: check-diff-all check-package.json

.PHONY: benchmark
benchmark: benchmark-opening_hours.min.js

README.html: README.md

.PHONY: release
release: package.json check qa-source-code qa-https-everywhere
	git status
	read continue
	editor package.json
	json -f package.json version
	read continue
	$(MAKE) $(MAKE_OPTIONS) check-package.json
	git commit --all --message="Released version $(json -f package.json version)."
	git tag --sign --local-user C505B5C93B0DB3D338A1B6005FE92C12EE88E1F0 "v$(json -f package.json version)"
	git push --follow-tags
	npm publish
	$(MAKE) $(MAKE_OPTIONS) publish-website-on-all-servers

.PHONY: clean
clean: osm-tag-data-rm
	rm --force *.min.js
	rm --force README.html
	rm --force taginfo_sources.json

.PHONY: osm-tag-data-rm
osm-tag-data-rm: osm-tag-data-taginfo-rm osm-tag-data-overpass-rm

## Publish {{{

.PHONY: publish-website-on-all-servers
publish-website-on-all-servers: publish-website-on-ypid.de publish-website-on-openingh.openstreetmap.de

.PHONY: publish-website-on-openingh.openstreetmap.de
publish-website-on-openingh.openstreetmap.de:
	ssh gauss.osm.de './update'

.PHONY: publish-website-on-ypid.de
publish-website-on-ypid.de:
	ssh osm@ypid.de './update'

## }}}

## command line programs {{{
.PHONY: run-regex_search
run-regex_search: export.$(SEARCH).json interactive_testing.js regex_search.py
	$(NODE) ./regex_search.py "$<"

.PHONY: run-interactive_testing
run-interactive_testing: interactive_testing.js
	$(NODE) "$<"
## }}}

## Source code QA {{{
.PHONY: qa-source-code qa-https-everywhere
qa-source-code:
	git ls-files | egrep '\.js$$' | xargs sed -i 's/\([^=!]\)==\([^=]\)/\1===\2/g;s/\([^=!]\)!=\([^=]\)/\1!==\2/g;'

qa-https-everywhere:
	git ls-files -z | xargs -0 sed -i 's#http://wiki.openstreetmap.org#https://wiki.openstreetmap.org#g;s#http://open.mapquestapi.com#https://open.mapquestapi.com#g;s#http://nominatim.openstreetmap.org#https://nominatim.openstreetmap.org#g;s#http://taginfo.openstreetmap.org#https://taginfo.openstreetmap.org#g;s#http://stackoverflow.com#https://stackoverflow.com#g;s#http://www.gnu.org/#https://www.gnu.org/#g;s#http://overpass-turbo.eu/#https://overpass-turbo.eu/#g;s#http://www.openstreetmap.org/#https://www.openstreetmap.org/#g;'
	# git ls-files -z | xargs -0 sed -i 's#http://overpass-api.de/#https://overpass-api.de/#g;'
	git ls-files -z | xargs -0 sed -i 's#http://\(\w\+\).wikipedia.org#https://\1.wikipedia.org#g;'
	test -L index.html && git checkout index.html
	# ack 'http://'
## }}}

## software testing {{{

.PHONY: check-all
check-all: check-package.json check-test check-diff-all osm-tag-data-update-check

.PHONY: check-fast
check-fast: check-diff-en-opening_hours.js

.PHONY: check-diff-all
check-diff-all: check-diff check-diff-opening_hours.min.js

{'fraction_non_alphanumeric': 0.17153284671532848, 'fraction_numerical': 0.028050052137643378, 'mean_word_length': 4.403380281690141, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 27, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 2, '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': '7066971', 'n_tokens_mistral': 4067, 'n_tokens_neox': 3772, 'n_words': 712}