<commit_before>#
# Copyright 2017 <NAME> <<EMAIL>>
#
# Licensed under the MIT license.
#

CFLAGS	+= -std=c99 -Werror -Wall -Wextra

PREFIX	?= /usr/local

.PHONY: all
all: edidcat

.PHONY: doc
doc: edidcat.1.gz hotplug-drm.7.gz hotplug-monitor.7.gz \
     hotplug-monitor.conf.5.gz

hotplug-monitor.conf:
	( cd /sys/class/drm/card0/ && ls -1d card0-* ) | \
	sed -e 's,card0-,,' -e 's,-[A-Z],,' -e 's,-,,' | \
	sed -e 's,^,[,' -e 's,$$,]\nposition=right\n,' >$@

.PHONY: conf
conf: hotplug-monitor.conf

.PHONY: install
install:
	install -m 0755 -d $(DESTDIR)/etc/udev/rules.d/
	install -m 0644 52-drm.rules $(DESTDIR)/etc/udev/rules.d/
	sed -e 's,/usr,$(PREFIX),' \
	    -i $(DESTDIR)/etc/udev/rules.d/52-drm.rules
	install -m 0644 53-drm-connector.rules $(DESTDIR)/etc/udev/rules.d/
	sed -e 's,/usr,$(PREFIX),' \
	    -e '/SUBSYSTEM=="drm"/s#$$#, ENV{DISPLAY}="$(DISPLAY)"#' \
	    -e '/SUBSYSTEM=="drm"/s#$$#, ENV{XAUTHORITY}="$(XAUTHORITY)"#' \
	    -i $(DESTDIR)/etc/udev/rules.d/53-drm-connector.rules
	install -m 0755 -d $(DESTDIR)$(PREFIX)/bin/
	install -m 0755 edidcat $(DESTDIR)$(PREFIX)/bin/
	install -m 0755 hotplug-drm $(DESTDIR)$(PREFIX)/bin/
	install -m 0755 hotplug-monitor $(DESTDIR)$(PREFIX)/bin/
	sed -e 's,/usr,$(PREFIX),' \
	    -i $(DESTDIR)$(PREFIX)/bin/hotplug-monitor
	install -m 0755 -d $(DESTDIR)$(PREFIX)/libexec/hotplug-monitor.d/
	if [ -e "hotplug-monitor.conf.sample" ]; then \
		install -m 0755 -d $(DESTDIR)$(PREFIX)/share/hotplug-monitor/; \
		install -m 0644 hotplug-monitor.conf.sample \
		                $(DESTDIR)$(PREFIX)/share/hotplug-monitor/; \
	fi
	if [ -e "hotplug-monitor.conf" ]; then \
		install -m 0755 -d $(DESTDIR)$(PREFIX)/etc/; \
		install -m 0644 hotplug-monitor.conf $(DESTDIR)$(PREFIX)/etc/; \
	fi

.PHONY: install-doc
install-doc:
	install -d $(DESTDIR)$(PREFIX)/share/man/man1/
	install -m 644 edidcat.1.gz \
	           $(DESTDIR)$(PREFIX)/share/man/man1/
	install -d $(DESTDIR)$(PREFIX)/share/man/man5/
	install -m 644 hotplug-monitor.conf.5.gz \
	           $(DESTDIR)$(PREFIX)/share/man/man5/
	install -d $(DESTDIR)$(PREFIX)/share/man/man7/
	install -m 644 hotplug-drm.7.gz hotplug-monitor.7.gz \
	           $(DESTDIR)$(PREFIX)/share/man/man7/

.PHONY: install-bash-completion
install-bash-completion:
	completionsdir=$$(pkg-config --variable=completionsdir bash-completion); \
	if [ -n "$$completionsdir" ]; then \
		install -d $(DESTDIR)$$completionsdir/; \
		for bash in edidcat hotplug-drm hotplug-monitor; do \
			install -m 644 bash-completion/$$bash \
			        $(DESTDIR)$$completionsdir/; \
		done; \
	fi

.PHONY: uninstall
uninstall:
	for rule in 52-drm.rules 53-drm-connector.rules; do \
		rm -f $(DESTDIR)/etc/udev/rules.d/$$rule; \
	done
	for bin in edidcat hotplug-drm hotplug-monitor; do \
		rm -f $(DESTDIR)$(PREFIX)/bin/$$bin; \
	done
	rm -f $(DESTDIR)$(PREFIX)/share/hotplug-monitor/hotplug-monitor.conf.sample
	rm -f $(DESTDIR)$(PREFIX)/share/man/man1/edidcat.1.gz
	rm -f $(DESTDIR)$(PREFIX)/share/man/man5/hotplug-monitor.conf.5.gz
	for man in hotplug-drm.7.gz hotplug-monitor.7.gz; do \
		rm -f $(DESTDIR)$(PREFIX)/share/man/man7/$$man; \
	done
	completionsdir=$$(pkg-config --variable=completionsdir bash-completion); \
	for bash in edidcat hotplug-drm hotplug-monitor; do \
		rm -f $(DESTDIR)$$completionsdir/$$bash; \
	done

.PHONY: conf
conf:
	@for dir in /sys/class/drm/card0/card0-*; do \
		if [ "$$(cat $$dir/status)" = "connected" ]; then \<commit_msg>Makefile: fix generation of sample file<commit_after>#
# Copyright 2017 <NAME> <<EMAIL>>
#
# Licensed under the MIT license.
#

CFLAGS	+= -std=c99 -Werror -Wall -Wextra

PREFIX	?= /usr/local

.PHONY: all
all: edidcat

.PHONY: doc
doc: edidcat.1.gz hotplug-drm.7.gz hotplug-monitor.7.gz \
     hotplug-monitor.conf.5.gz

hotplug-monitor.conf:
	( cd /sys/class/drm/card0/ && ls -1d card0-* ) | \
	sed -e 's,card0-,,' -e 's,-[A-Z],,' -e 's,-,,' | \
	sed -e 's,^,[,' -e 's,$$,]\nposition=right\n,' >$@

.PHONY: conf
conf: hotplug-monitor.conf

.PHONY: install
install:
	install -m 0755 -d $(DESTDIR)/etc/udev/rules.d/
	install -m 0644 52-drm.rules $(DESTDIR)/etc/udev/rules.d/
	sed -e 's,/usr,$(PREFIX),' \
	    -i $(DESTDIR)/etc/udev/rules.d/52-drm.rules
	install -m 0644 53-drm-connector.rules $(DESTDIR)/etc/udev/rules.d/
	sed -e 's,/usr,$(PREFIX),' \
	    -e '/SUBSYSTEM=="drm"/s#$$#, ENV{DISPLAY}="$(DISPLAY)"#' \
	    -e '/SUBSYSTEM=="drm"/s#$$#, ENV{XAUTHORITY}="$(XAUTHORITY)"#' \
	    -i $(DESTDIR)/etc/udev/rules.d/53-drm-connector.rules
	install -m 0755 -d $(DESTDIR)$(PREFIX)/bin/
	install -m 0755 edidcat $(DESTDIR)$(PREFIX)/bin/
	install -m 0755 hotplug-drm $(DESTDIR)$(PREFIX)/bin/
	install -m 0755 hotplug-monitor $(DESTDIR)$(PREFIX)/bin/
	sed -e 's,/usr,$(PREFIX),' \
	    -i $(DESTDIR)$(PREFIX)/bin/hotplug-monitor
	install -m 0755 -d $(DESTDIR)$(PREFIX)/libexec/hotplug-monitor.d/
	if [ -e "hotplug-monitor.conf.sample" ]; then \
		install -m 0755 -d $(DESTDIR)$(PREFIX)/share/hotplug-monitor/; \
		install -m 0644 hotplug-monitor.conf.sample \
		                $(DESTDIR)$(PREFIX)/share/hotplug-monitor/; \
	fi
	if [ -e "hotplug-monitor.conf" ]; then \
		install -m 0755 -d $(DESTDIR)$(PREFIX)/etc/; \
		install -m 0644 hotplug-monitor.conf $(DESTDIR)$(PREFIX)/etc/; \
	fi

.PHONY: install-doc
install-doc:
	install -d $(DESTDIR)$(PREFIX)/share/man/man1/
	install -m 644 edidcat.1.gz \
	           $(DESTDIR)$(PREFIX)/share/man/man1/
	install -d $(DESTDIR)$(PREFIX)/share/man/man5/
	install -m 644 hotplug-monitor.conf.5.gz \
	           $(DESTDIR)$(PREFIX)/share/man/man5/
	install -d $(DESTDIR)$(PREFIX)/share/man/man7/
	install -m 644 hotplug-drm.7.gz hotplug-monitor.7.gz \
	           $(DESTDIR)$(PREFIX)/share/man/man7/

.PHONY: install-bash-completion
install-bash-completion:
	completionsdir=$$(pkg-config --variable=completionsdir bash-completion); \
	if [ -n "$$completionsdir" ]; then \
		install -d $(DESTDIR)$$completionsdir/; \
		for bash in edidcat hotplug-drm hotplug-monitor; do \
			install -m 644 bash-completion/$$bash \
			        $(DESTDIR)$$completionsdir/; \
		done; \
	fi

.PHONY: uninstall
uninstall:
	for rule in 52-drm.rules 53-drm-connector.rules; do \
		rm -f $(DESTDIR)/etc/udev/rules.d/$$rule; \
	done
	for bin in edidcat hotplug-drm hotplug-monitor; do \
		rm -f $(DESTDIR)$(PREFIX)/bin/$$bin; \
	done
	rm -f $(DESTDIR)$(PREFIX)/share/hotplug-monitor/hotplug-monitor.conf.sample
	rm -f $(DESTDIR)$(PREFIX)/share/man/man1/edidcat.1.gz
	rm -f $(DESTDIR)$(PREFIX)/share/man/man5/hotplug-monitor.conf.5.gz
	for man in hotplug-drm.7.gz hotplug-monitor.7.gz; do \
		rm -f $(DESTDIR)$(PREFIX)/share/man/man7/$$man; \
	done
	completionsdir=$$(pkg-config --variable=completionsdir bash-completion); \
	for bash in edidcat hotplug-drm hotplug-monitor; do \
		rm -f $(DESTDIR)$$completionsdir/$$bash; \
	done

.PHONY: conf
conf:
	@set -e; \
	for dir in /sys/class/drm/card0/card0-*; do \
		if [ "$$(cat $$dir/status)" = "connected" ]; then \
{'fraction_non_alphanumeric': 0.20193557706196735, 'fraction_numerical': 0.030333670374115267, 'mean_word_length': 3.1963636363636363, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '5772704', 'n_tokens_mistral': 3109, 'n_tokens_neox': 2843, 'n_words': 545}