<commit_before>APP = echessd

VERSION = $(shell cat version)

.PHONY: all compile doc clean eunit dialyze all-tests \
    debian-install debian-chown debian-uninstall

all: $(APP)

COPTS = {outdir, ebin}, {i, \"include\"}, warn_unused_function, \
 warn_bif_clash, warn_deprecated_function, warn_obsolete_guard, verbose, \
 warn_shadow_vars, warn_export_vars, warn_unused_records, \
 warn_unused_import, warn_export_all, warnings_as_errors

ifdef DEBUG
COPTS := $(COPTS), debug_info
endif

ifdef TEST
COPTS := $(COPTS), {d, 'TEST'}
endif

ifdef TRACE
COPTS := $(COPTS), {d, 'TRACE'}
endif

OTPREL = $(shell erl -noshell -eval 'io:format(erlang:system_info(otp_release)),halt()')
ifeq ($(shell expr $(OTPREL) '<' R14B02), 1)
COPTS := $(COPTS), {d, 'WITHOUT_INETS_HEADER'}
endif

compile:
	mkdir -p ebin
	sed "s/{{VERSION}}/$(VERSION)/" src/$(APP).app.in > ebin/$(APP).app
	echo '["src/*"].' > Emakefile
	erl -noinput -eval "up_to_date=make:all([$(COPTS)]),halt()"

$(APP): compile
	rm -f -- $(APP).zip
	zip -j $(APP) ebin/*
	zip $(APP) priv/$(APP).lang priv/$(APP).styles priv/www/*
	echo '#!/usr/bin/env escript' > $(APP)
	echo '%%!-smp -kernel inet_dist_use_interface {127,0,0,1}' >> $(APP)
	cat $(APP).zip >> $(APP)
	rm -f -- $(APP).zip
	chmod 755 $(APP)

EDOC_OPTS = {application, $(APP)}, {preprocess, true}
html:
	sed "s/{{VERSION}}/$(VERSION)/" doc/overview.edoc.in > doc/overview.edoc
	erl -noinput -eval 'edoc:application($(APP),".",[$(EDOC_OPTS)]),halt()'

eunit:
	$(MAKE) TEST=y clean compile
	erl -noinput -pa ebin \
		-eval 'ok=eunit:test({application,$(APP)},[verbose]),halt()'

PLT = .dialyzer_plt
DIALYZER_OPTS = -Wunmatched_returns -Werror_handling

dialyze: $(PLT)
	dialyzer --plt $< -r . $(DIALYZER_OPTS) --src
	$(MAKE) DEBUG=y clean compile
	dialyzer --plt $< -r . $(DIALYZER_OPTS)

$(PLT):
	dialyzer --build_plt --output_plt $@ \
		--apps erts inets kernel stdlib crypto compiler mnesia

all-tests:
	$(MAKE) eunit
	$(MAKE) dialyze

clean:
	rm -rf -- ebin doc/*.html doc/*.css doc/*.png doc/edoc-info \
	    $(APP).zip $(APP) erl_crash.dump Emakefile doc/overview.edoc \
	    *.log *.log.* tmp_file
	find . -type f -name '*~' -delete

## ----------------------------------------------------------------------
## installation/deinstallation section

debian-install:
	install -m 755 -d $(DESTDIR)/etc
	install -m 644 echessd.conf $(DESTDIR)/etc
	install -m 755 -d $(DESTDIR)/etc/init.d
	install -m 755 pkg.d/debian/initd.sh $(DESTDIR)/etc/init.d/echessd
	install -m 755 -d $(DESTDIR)/usr/sbin
	install -m 755 echessd $(DESTDIR)/usr/sbin
	install -m 755 pkg.d/wrapper.sh $(DESTDIR)/usr/sbin/echessd-wrapper
	install -m 755 -d $(DESTDIR)/var/lib/echessd
	install -m 755 -d $(DESTDIR)/var/run/echessd
	install -m 755 -d $(DESTDIR)/var/log/echessd

debian-chown:
	getent passwd echessd || \
	    adduser --system --group --no-create-home echessd
	chown root:echessd $(DESTDIR)/etc/echessd.conf
	chmod 0640 $(DESTDIR)/etc/echessd.conf
	chown -R echessd: $(DESTDIR)/var/lib/echessd
	chown -R echessd: $(DESTDIR)/var/run/echessd
	chown -R echessd: $(DESTDIR)/var/log/echessd

debian-uninstall:
	rm -rf -- $(DESTDIR)/etc/echessd.conf \
	    $(DESTDIR)/usr/sbin/echessd \
	    $(DESTDIR)/usr/sbin/echessd-wrapper \
	    $(DESTDIR)/etc/init.d/echessd \
	    $(DESTDIR)/var/run/echessd
<commit_msg>makefile: add recipes for GraphViz documents<commit_after>APP = echessd

VERSION = $(shell cat version)

.PHONY: all compile doc clean eunit dialyze all-tests \
    debian-install debian-chown debian-uninstall

all: $(APP)

COPTS = {outdir, ebin}, {i, \"include\"}, warn_unused_function, \
 warn_bif_clash, warn_deprecated_function, warn_obsolete_guard, verbose, \
 warn_shadow_vars, warn_export_vars, warn_unused_records, \
 warn_unused_import, warn_export_all, warnings_as_errors

ifdef DEBUG
COPTS := $(COPTS), debug_info
endif

ifdef TEST
COPTS := $(COPTS), {d, 'TEST'}
endif

ifdef TRACE
COPTS := $(COPTS), {d, 'TRACE'}
endif

OTPREL = $(shell erl -noshell -eval 'io:format(erlang:system_info(otp_release)),halt()')
ifeq ($(shell expr $(OTPREL) '<' R14B02), 1)
COPTS := $(COPTS), {d, 'WITHOUT_INETS_HEADER'}
endif

compile:
	mkdir -p ebin
	sed "s/{{VERSION}}/$(VERSION)/" src/$(APP).app.in > ebin/$(APP).app
	echo '["src/*"].' > Emakefile
	erl -noinput -eval "up_to_date=make:all([$(COPTS)]),halt()"

$(APP): compile
	rm -f -- $(APP).zip
	zip -j $(APP) ebin/*
	zip $(APP) priv/$(APP).lang priv/$(APP).styles priv/www/*
	echo '#!/usr/bin/env escript' > $(APP)
	echo '%%!-smp -kernel inet_dist_use_interface {127,0,0,1}' >> $(APP)
	cat $(APP).zip >> $(APP)
	rm -f -- $(APP).zip
	chmod 755 $(APP)

FIGURES = $(patsubst %.dot, %.png, $(wildcard doc/*.dot))

EDOC_OPTS = {application, $(APP)}, {preprocess, true}
html: $(FIGURES)
	sed "s/{{VERSION}}/$(VERSION)/" doc/overview.edoc.in > doc/overview.edoc
	erl -noinput -eval 'edoc:application($(APP),".",[$(EDOC_OPTS)]),halt()'

%.png: %.dot
	dot -T png $< > $@

eunit:
	$(MAKE) TEST=y clean compile
	erl -noinput -pa ebin \
		-eval 'ok=eunit:test({application,$(APP)},[verbose]),halt()'

PLT = .dialyzer_plt
DIALYZER_OPTS = -Wunmatched_returns -Werror_handling

dialyze: $(PLT)
	dialyzer --plt $< -r . $(DIALYZER_OPTS) --src
	$(MAKE) DEBUG=y clean compile
	dialyzer --plt $< -r . $(DIALYZER_OPTS)

$(PLT):
	dialyzer --build_plt --output_plt $@ \
		--apps erts inets kernel stdlib crypto compiler mnesia

all-tests:
	$(MAKE) eunit
	$(MAKE) dialyze

clean:
	rm -rf -- ebin doc/*.html doc/*.css doc/*.png doc/edoc-info \
	    $(APP).zip $(APP) erl_crash.dump Emakefile doc/overview.edoc \
	    *.log *.log.* tmp_file
	find . -type f -name '*~' -delete

## ----------------------------------------------------------------------
## installation/deinstallation section

debian-install:
	install -m 755 -d $(DESTDIR)/etc
	install -m 644 echessd.conf $(DESTDIR)/etc
	install -m 755 -d $(DESTDIR)/etc/init.d
	install -m 755 pkg.d/debian/initd.sh $(DESTDIR)/etc/init.d/echessd
	install -m 755 -d $(DESTDIR)/usr/sbin
	install -m 755 echessd $(DESTDIR)/usr/sbin
	install -m 755 pkg.d/wrapper.sh $(DESTDIR)/usr/sbin/echessd-wrapper
	install -m 755 -d $(DESTDIR)/var/lib/echessd
	install -m 755 -d $(DESTDIR)/var/run/echessd
	install -m 755 -d $(DESTDIR)/var/log/echessd

debian-chown:
	getent passwd echessd || \
	    adduser --system --group --no-create-home echessd
	chown root:echessd $(DESTDIR)/etc/echessd.conf
	chmod 0640 $(DESTDIR)/etc/echessd.conf
	chown -R echessd: $(DESTDIR)/var/lib/echessd
	chown -R echessd: $(DESTDIR)/var/run/echessd
	chown -R echessd: $(DESTDIR)/var/log/echessd

debian-uninstall:
	rm -rf -- $(DESTDIR)/etc/echessd.conf \
	    $(DESTDIR)/usr/sbin/echessd \
	    $(DESTDIR)/usr/sbin/echessd-wrapper \
	    $(DESTDIR)/etc/init.d/echessd \
	    $(DESTDIR)/var/run/echessd

{'fraction_non_alphanumeric': 0.20278890372348315, 'fraction_numerical': 0.014241210502892745, 'mean_word_length': 3.5309139784946235, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2901010', 'n_tokens_mistral': 2938, 'n_tokens_neox': 2721, 'n_words': 599}