#!/usr/bin/make -f HOME = $(shell cd "$(dir $(lastword $(MAKEFILE_LIST)))" && git rev-parse --show-toplevel) export HOME $(foreach v,$(filter XDG_%,$(.VARIABLES)),$(eval undefine $v)) LANG = C export LANG $(foreach v,$(filter LC_%,$(.VARIABLES)),$(eval undefine $v)) CFLAGS += -std=c99 -Wall -Wextra -Werror -Wno-unused-parameter dirs = \ $(HOME)/packages/pkgdest \ $(HOME)/packages/srcdest \ $(HOME)/packages/srcpkgdest \ $(HOME)/packages/logdest \ $(HOME)/packages/builddir all: \ $(HOME)/.local/bin/autobuild \ $(HOME)/.ssh/id_rsa \ $(HOME)/.ssh/id_rsa.pub \ $(HOME)/.gnupg/private-keys-v1.d \ $(HOME)/packages/abslibre \ $(dirs) $(HOME)/.local/bin/autobuild: %: %.c cd $(@D) && $(LINK.c) $(notdir $^) $(LOADLIBES) $(LDLIBS) -o $(@F) && chmod 6755 $(@F) $(HOME)/.ssh/id_% $(HOME)/.ssh/id_%.pub: ssh-keygen -N '' -f $(@D)/id_$* # We really don't want gpg `agent-socket` to be # `${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent` if `$(HOME) != $(shell echo # ~$(USER))`. So just adjust XDG_RUNTIME_DIR, right? Nope! GnuPG # 2.2 willfully ignores XDG_RUNTIME_DIR and instead hard-codes the # value that systemd sets XDG_RUNTIME_DIR to. # # However, if `$(GNUPGHOME) != $(HOME)/.gnupg`, then GnuPG will # instead set `agent-socket` it to # `${XDG_RUNTIME_DIR}/gnupg/d.XXXXXXXXXXXXXXXXXXXXXXXX/S.gpg-agent` # where XXX is a hash of GNUPGHOME. Perfect! This is actually really # robust behavior, that it should probably use all the time. # Unfortunately, we need to set HOME to some BS value to trigger it. # # GnuPG: Broken by defaultâ„¢ $(HOME)/.gnupg/private-keys-v1.d: | $(HOME)/.config/git/config chmod 700 $(@D) printf '%s\n' \ 'Key-Type: default' \ 'Subkey-Type: default' \ "Name-Real: $$(git config user.name)" \ "Name-Email: $$(git config user.email)" \ 'Expire-Date: 0' \ '%no-protection' \ '%commit' \ | HOME=/var/empty GNUPGHOME=$(HOME)/.gnupg gpg --gen-key --batch $(HOME)/packages/abslibre: createworkdir $(dirs): %: mkdir -p -- $@ .DELETE_ON_ERROR: